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.

Stripe Integration: Account for payment_status != "paid" edge case (#3336)

Steven Teye005819d38b2
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 27b83f044d..315ee60e32 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
@@ -287,11 +287,15 @@ export async function checkoutSessionCompleted(
// should never be below 0, but just in case
if (chargeAmountTotal <= 0) {
- return `Checkout session completed for Stripe customer ${stripeCustomerId} with invoice ID ${invoiceId} but amount is 0, skipping...`;
+ return `Checkout session completed for Stripe customer ${stripeCustomerId} but amount is 0, skipping...`;
}
if (charge.mode === "setup") {
- return `Checkout session completed for Stripe customer ${stripeCustomerId} but mode is setup, skipping...`;
+ return `Checkout session completed for Stripe customer ${stripeCustomerId} but mode is "setup", skipping...`;
+ }
+
+ if (charge.payment_status !== "paid") {
+ return `Checkout session completed for Stripe customer ${stripeCustomerId} but payment_status is not "paid", skipping...`;
}
if (invoiceId) {
diff --git a/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts b/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
index c292a77b46..944c28010f 100644
--- a/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
+++ b/apps/web/app/(ee)/api/stripe/webhook/checkout-session-completed.ts
@@ -17,7 +17,10 @@ import Stripe from "stripe";
export async function checkoutSessionCompleted(event: Stripe.Event) {
const checkoutSession = event.data.object as Stripe.Checkout.Session;
- if (checkoutSession.mode === "setup") {
+ if (
+ checkoutSession.mode === "setup" ||
+ checkoutSession.payment_status !== "paid"
+ ) {
return;
}