Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update route.ts

Kiran Ka17ecb60cb65
diff --git a/apps/web/app/api/paypal/callback/route.ts b/apps/web/app/api/paypal/callback/route.ts
index 9b33894003..325a2126d8 100644
--- a/apps/web/app/api/paypal/callback/route.ts
+++ b/apps/web/app/api/paypal/callback/route.ts
@@ -62,15 +62,33 @@ export const GET = async (req: Request) => {
// TODO:
// Should we check if the paypal email is verified?
+ const { partner } = await prisma.partnerUser.findUniqueOrThrow({
+ where: {
+ userId_partnerId: {
+ userId: session.user.id,
+ partnerId: defaultPartnerId,
+ },
+ },
+ include: {
+ partner: true,
+ },
+ });
+
await prisma.partner.update({
where: {
id: defaultPartnerId,
},
data: {
paypalEmail: paypalUser.email,
- payoutsEnabledAt: new Date(),
+ ...(!partner.payoutsEnabledAt && {
+ payoutsEnabledAt: new Date(),
+ }),
},
});
+
+ // TODO:
+ // Send an email to the partner to inform them that their PayPal account has been connected
+
} catch (e: any) {
return handleAndReturnErrorResponse(e);
}