The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add verification check for PayPal email
Kiran Kbb0847134154
diff --git a/apps/web/app/(ee)/api/paypal/callback/route.ts b/apps/web/app/(ee)/api/paypal/callback/route.tsindex 430db3ba43..6efbba4f6e 100644--- a/apps/web/app/(ee)/api/paypal/callback/route.ts+++ b/apps/web/app/(ee)/api/paypal/callback/route.ts@@ -66,8 +66,13 @@ export const GET = async (req: Request) => {token: accessToken,});- // TODO:- // Should we check if the paypal email is verified?+ if (!paypalUser.email_verified) {+ throw new DubApiError({+ code: "bad_request",+ message:+ "PayPal email address is not verified. Please verify your email address in PayPal and try again https://partners.dub.co",+ });+ }const { partner } = await prisma.partnerUser.findUniqueOrThrow({where: {@@ -95,7 +100,7 @@ export const GET = async (req: Request) => {// TODO:// Send an email to the partner to inform them that their PayPal account has been connected- } catch (e: any) {+ } catch (e) {return handleAndReturnErrorResponse(e);}diff --git a/apps/web/lib/paypal/oauth.ts b/apps/web/lib/paypal/oauth.tsindex f91f212438..30f33c60d7 100644--- a/apps/web/lib/paypal/oauth.ts+++ b/apps/web/lib/paypal/oauth.ts@@ -10,10 +10,9 @@ interface AccessToken {};}-interface UserInfo {+interface PayPalUserInfo {email: string;- verified: boolean;- email_verified: boolean;+ email_verified: boolean; // Indicates whether the user's paypal email address is verified.}const REDIRECT_URI = `${PARTNERS_DOMAIN_WITH_NGROK}/api/paypal/callback`;@@ -49,7 +48,7 @@ export class PayPalOAuth {const state = uuidv4();await redis.set(`${STATE_CACHE_PREFIX}${state}`, dubUserId, {- ex: 60 * 2, // 2 minutes+ ex: 60 * 5, // 5 minutes});return this.oauth2.authorizeURL({@@ -89,7 +88,7 @@ export class PayPalOAuth {},);- const data = (await response.json()) as UserInfo;+ const data = (await response.json()) as PayPalUserInfo;if (!response.ok) {throw new Error("Failed to fetch user info from PayPal.", {