#db-assi-subscriptions
1 messages · Page 1 of 1 (latest)
@sacred yacht hard to say without looking at a specific example but I'd assume you forgot to set either https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method or set https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
if you have a sub_xxx or subsched_xxx I can have a look
ok, so basically I create a stripe customer 'stripe.customers.create' and then I create a subscription schedule 'stripe.subscriptionSchedules.create' (I'm using the API) So I should have an intermediate step that creates a subscription with a default payment method
or adds a payment method to the customer
it would be a lot easier if you had an example! Like at some level the customer has to have some payment method to charge, so presumably you do collect one from them? So most likely it's a small oversight and that collected method is not being charged as it's not the default
yes, the user is flow is the following: user creates an account with us, then we create a user with that email in stripe, then we create a subscription schedule and finalize the invoice to generate a payment intent, the client secret it then passed onto the frontend that takes payment details, process payments... etc we have a webhook set up that triggers a successful subscription when payment is successful
can you share an example Subscription or SubscriptionSchedule ID so I can look at your logs?
sorry, the words help, but specific technical examples would be the fastest way to help you. You almost certainly just need to set a default_payment_method after processing the first payment but if I can see exactly what you're doing I can tell you exactly.
thanks
so yeah here this customer doesn't have any saved payment methods (https://dashboard.stripe.com/test/customers/cus_KCd2ptjglsWsyQ) so future payments would fail. To clarify, how did you pay the previous invoices? Was it a custom payment page where you call confirmCardPayment using Elements, or our hosted invoice page?
But yeah this is a really annoying part of SubscriptionSchedules, they don't save the PaymentMethod by default
basically there's two approaches here :
- after finalizing that first invoice like you mention, you then need to call https://stripe.com/docs/api/payment_intents/update#update_payment_intent-setup_future_usage to update the
invoice.payment_intentto havesetup_future_usage:"off_session". That tells us to actually save the card to the customer object when the payment is made. Then, later when you handle the webhook for the successful payment, you need to set either https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method or https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method so that the saved payment method is now also used by default for future payments. (https://stripe.com/docs/billing/subscriptions/elements#default-payment-method)
yes, I used confirmCardPayment using Elements
- the other option is, reverse the process. Don't create the schedule first, just create the subscription first, so do https://stripe.com/docs/billing/subscriptions/elements as normal. Then after the subscription is created, then create the Schedule for it (https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription) — might be easier as it avoids the need to have to manually add
setup_future_usageand manually finalize the invoice like in the other option
sorry, the developer experience of this part of the API is really quite poor, I'm sorry.