Browse Source

Handle cases where default payment method might not be specified

vishnukvmd 1 year ago
parent
commit
2dcf5daf54
1 changed files with 6 additions and 1 deletions
  1. 6 1
      server/pkg/controller/stripe.go

+ 6 - 1
server/pkg/controller/stripe.go

@@ -518,7 +518,12 @@ func (c *StripeController) UpdateSubscription(stripeID string, userID int64) (en
 	if err != nil {
 	if err != nil {
 		return ente.SubscriptionUpdateResponse{}, stacktrace.Propagate(err, "")
 		return ente.SubscriptionUpdateResponse{}, stacktrace.Propagate(err, "")
 	}
 	}
-	isSEPA := stripeSubscription.DefaultPaymentMethod.Type == stripe.PaymentMethodTypeSepaDebit
+	isSEPA := false
+	if stripeSubscription.DefaultPaymentMethod != nil {
+		isSEPA = stripeSubscription.DefaultPaymentMethod.Type == stripe.PaymentMethodTypeSepaDebit
+	} else {
+		log.Info("No default payment method found")
+	}
 	var paymentBehavior stripe.SubscriptionPaymentBehavior
 	var paymentBehavior stripe.SubscriptionPaymentBehavior
 	if isSEPA {
 	if isSEPA {
 		paymentBehavior = stripe.SubscriptionPaymentBehaviorAllowIncomplete
 		paymentBehavior = stripe.SubscriptionPaymentBehaviorAllowIncomplete