Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Skip stale Stripe hold emails (#11029)

neeraj-pilot166e6441f0c9
diff --git a/server/pkg/controller/stripe.go b/server/pkg/controller/stripe.go
index 7782bb5159..92e4356da1 100644
--- a/server/pkg/controller/stripe.go
+++ b/server/pkg/controller/stripe.go
@@ -402,6 +402,11 @@ func (c *StripeController) handlePaymentIntentFailed(event stripe.Event, country
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
}
+ if isPaidStripeInvoice(invoice) {
+ log.Info("Ignoring stale payment intent failed event for paid invoice:", invoiceID)
+ return ente.StripeEventLog{UserID: userID, StripeSubscription: *stripeSubscription, Event: event}, nil
+ }
+
productID := stripeSubscription.Items.Data[0].Price.ID
// If the current subscription is not the same as the one in the webhook,
// then ignore
@@ -802,6 +807,10 @@ func usesAllowIncompleteSubscriptionUpdate(paymentMethodType stripe.PaymentMetho
return paymentMethodType == stripe.PaymentMethodTypeSepaDebit || paymentMethodType == stripe.PaymentMethodType("upi")
}
+func isPaidStripeInvoice(invoice *stripe.Invoice) bool {
+ return invoice.Paid || invoice.Status == stripe.InvoiceStatusPaid
+}
+
func getPaymentIntentErrorPaymentMethodType(paymentIntent stripe.PaymentIntent) stripe.PaymentMethodType {
if paymentIntent.LastPaymentError == nil {
return ""