The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into paypal
Kiran K8d4654170d76
diff --cc apps/web/app/api/stripe/webhook/charge-succeeded.tsindex d8548c70fc,86f471af75..1870651347--- a/apps/web/app/api/stripe/webhook/charge-succeeded.ts+++ b/apps/web/app/api/stripe/webhook/charge-succeeded.ts@@@ -49,21 -50,69 +49,22 @@@ export async function chargeSucceeded(ereturn;}- for (const payout of invoice.payouts) {- const transfer = await stripe.transfers.create({- amount: payout.amount,- currency: "usd",- destination: payout.partner.stripeConnectId!,- transfer_group: invoice.id,- ...(!charge.payment_method_details?.ach_credit_transfer- ? {- source_transaction: charge.id,- }- : {}),- description: `Dub Partners payout (${payout.program.name})`,- });-- console.log("Transfer created", transfer);-- await Promise.all([- prisma.payout.update({- where: {- id: payout.id,- },- data: {- stripeTransferId: transfer.id,- status: "completed",- paidAt: new Date(),- },- }),- prisma.commission.updateMany({- where: {- payoutId: payout.id,- },- data: {- status: "paid",- },- }),- payout.partner.email &&- sendEmail({- subject: "You've been paid!",- email: payout.partner.email,- from: "Dub Partners <[email protected]>",- react: PartnerPayoutSent({- email: payout.partner.email,- program: payout.program,- payout: {- id: payout.id,- amount: payout.amount,- startDate: payout.periodStart,- endDate: payout.periodEnd,- },- }),- variant: "notifications",- }),- ]);- }-- await prisma.invoice.update({- where: {- id: invoice.id,- },- data: {- status: "completed",+ const qstashResponse = await qstash.publishJSON({+ url: `${APP_DOMAIN_WITH_NGROK}/api/cron/payouts/charge-succeeded`,+ body: {+ chargeId,+ invoiceId: invoice.id,receiptUrl: receipt_url,- paidAt: new Date(),+ achCreditTransfer: Boolean(+ charge.payment_method_details?.ach_credit_transfer,+ ),++ // paidAt: new Date(), // TODO: Fix this},});++ if (qstashResponse.messageId) {+ console.log(`Message sent to Qstash with id ${qstashResponse.messageId}`);+ } else {+ console.error("Error sending message to Qstash", qstashResponse);+ }}