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.

simplify redis key value

Steven Tey98556cf35569
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
index b0abad60dc..0d874b25be 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/checkout-session-completed.ts
@@ -216,7 +216,17 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
// Skip if invoice id is already processed
const ok = await redis.set(
`trackSale:stripe:invoiceId:${invoiceId}`, // here we assume that Stripe's invoice ID is unique across all customers
- charge,
+ {
+ timestamp: new Date().toISOString(),
+ dubCustomerId,
+ stripeCustomerId,
+ stripeAccountId,
+ invoiceId,
+ customerId: customer.id,
+ workspaceId: customer.projectId,
+ amount: charge.amount_total,
+ currency: charge.currency,
+ },
{
ex: 60 * 60 * 24 * 7,
nx: true,
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
index ed4fb8c171..b82d5c774f 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/invoice-paid.ts
@@ -67,7 +67,17 @@ export async function invoicePaid(event: Stripe.Event) {
// Skip if invoice id is already processed
const ok = await redis.set(
`trackSale:stripe:invoiceId:${invoiceId}`, // here we assume that Stripe's invoice ID is unique across all customers
- invoice,
+ {
+ timestamp: new Date().toISOString(),
+ dubCustomerId: customer.externalId,
+ stripeCustomerId,
+ stripeAccountId,
+ invoiceId,
+ customerId: customer.id,
+ workspaceId: customer.projectId,
+ amount: invoice.amount_paid,
+ currency: invoice.currency,
+ },
{
ex: 60 * 60 * 24 * 7,
nx: true,