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.

add support for Stripe Adaptive Pricing

Steven Tey48fac0e45c4d
diff --git a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
index e08c37d5cd..de907fb112 100644
--- a/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
+++ b/apps/web/app/api/stripe/integration/webhook/checkout-session-completed.ts
@@ -24,7 +24,7 @@ import type Stripe from "stripe";
// Handle event "checkout.session.completed"
export async function checkoutSessionCompleted(event: Stripe.Event) {
- const charge = event.data.object as Stripe.Checkout.Session;
+ let charge = event.data.object as Stripe.Checkout.Session;
const dubCustomerId = charge.metadata?.dubCustomerId;
const clientReferenceId = charge.client_reference_id;
const stripeAccountId = event.account as string;
@@ -186,6 +186,12 @@ export async function checkoutSessionCompleted(event: Stripe.Event) {
return `Checkout session completed for Stripe customer ${stripeCustomerId} with invoice ID ${invoiceId} but amount is 0, skipping...`;
}
+ // support for Stripe Adaptive Pricing: https://docs.stripe.com/payments/checkout/adaptive-pricing
+ if (charge.currency !== "usd" && charge.currency_conversion) {
+ charge.amount_total = charge.currency_conversion.amount_total;
+ charge.currency = charge.currency_conversion.source_currency;
+ }
+
const saleData = {
...leadEvent,
event_id: nanoid(16),