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.

Use dubCustomerExternalId in Stripe integration for consistency

Steven Tey188badbea78f
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 5a0cf603dd..289f4e6566 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
@@ -42,7 +42,8 @@ export async function checkoutSessionCompleted(
mode: StripeMode,
) {
let charge = event.data.object as Stripe.Checkout.Session;
- let dubCustomerExternalId = charge.metadata?.dubCustomerId; // TODO: need to update to dubCustomerExternalId in the future for consistency
+ let dubCustomerExternalId =
+ charge.metadata?.dubCustomerExternalId || charge.metadata?.dubCustomerId;
const clientReferenceId = charge.client_reference_id;
const stripeAccountId = event.account as string;
const stripeCustomerId = charge.customer as string;
@@ -239,7 +240,9 @@ export async function checkoutSessionCompleted(
});
if (connectedCustomer?.metadata.dubCustomerId) {
- dubCustomerExternalId = connectedCustomer.metadata.dubCustomerId; // TODO: need to update to dubCustomerExternalId in the future for consistency
+ dubCustomerExternalId =
+ connectedCustomer.metadata.dubCustomerExternalId ||
+ connectedCustomer.metadata.dubCustomerId;
customer = await updateCustomerWithStripeCustomerId({
stripeAccountId,
dubCustomerExternalId,
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts
index 4a330a7120..3284249a89 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-created.ts
@@ -6,7 +6,9 @@ import { createNewCustomer } from "./utils/create-new-customer";
export async function customerCreated(event: Stripe.Event) {
const stripeCustomer = event.data.object as Stripe.Customer;
const stripeAccountId = event.account as string;
- const dubCustomerExternalId = stripeCustomer.metadata?.dubCustomerId; // TODO: need to update to dubCustomerExternalId in the future for consistency
+ const dubCustomerExternalId =
+ stripeCustomer.metadata?.dubCustomerExternalId ||
+ stripeCustomer.metadata?.dubCustomerId;
if (!dubCustomerExternalId) {
return "External ID not found in Stripe customer metadata, skipping...";
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-updated.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-updated.ts
index 36a97b0afd..6ad81c4a4b 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/customer-updated.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/customer-updated.ts
@@ -6,7 +6,9 @@ import { createNewCustomer } from "./utils/create-new-customer";
export async function customerUpdated(event: Stripe.Event) {
const stripeCustomer = event.data.object as Stripe.Customer;
const stripeAccountId = event.account as string;
- const dubCustomerExternalId = stripeCustomer.metadata?.dubCustomerId; // TODO: need to update to dubCustomerExternalId in the future for consistency
+ const dubCustomerExternalId =
+ stripeCustomer.metadata?.dubCustomerExternalId ||
+ stripeCustomer.metadata?.dubCustomerId;
if (!dubCustomerExternalId) {
return "External ID not found in Stripe customer metadata, skipping...";
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 e1c8490daa..6ecaf2bdbc 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
@@ -39,7 +39,9 @@ export async function invoicePaid(event: Stripe.Event, mode: StripeMode) {
mode,
});
- const dubCustomerExternalId = connectedCustomer?.metadata.dubCustomerId; // TODO: need to update to dubCustomerExternalId in the future for consistency
+ const dubCustomerExternalId =
+ connectedCustomer?.metadata.dubCustomerExternalId ||
+ connectedCustomer?.metadata.dubCustomerId;
if (dubCustomerExternalId) {
try {