#alecpope
1 messages · Page 1 of 1 (latest)
Hi there, How do you collect the payment method for the subscription?
Hi, before creating the subscription I create a setup intent and if successful, I update the customer to save it as a default payment method
OK, actually the easiest way to get started with subscription is through Stripe Checkout https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=checkout , Stripe checkout will help you collect the payment method, set it as default, and pay the invoice
Oh okay, yeah that makes it easier. But if I want to use Stripe Elements, I need to pay the first payment intent?
It depends on when do you collect the payment method
If you already collected a payment method, you can just use it as the default_payment_method when creating a subscription from your backend.
If you want to collect the payment method after creating the subscription, then yes you can use PaymentElement to pay the first invoice, this flow is explained in https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
I collected the payment method before and when creating the subscription, I pass this in: DefaultPaymentMethod: &customer.InvoiceSettings.DefaultPaymentMethod.ID,. But the first invoice is not payed automatically. If I advance the time one/two days, the status goes to incomplete_expired
What's the subscription ID?
The auto_advance property of the 1st invoice is false, and that's why Stripe didn't pay it automatically. https://stripe.com/docs/invoicing/integration/automatic-advancement-collection#toggle-auto-advance
Ah, so I need to update the generated invoice with auto_advance: true after creating the subscription?
You can set allow_incomplete as the payment_behavior when creating a subscritption, this tell Stripe to immediately attempt to pay the invoice
Nice, that worked! What if the payment fails? Do I need to listen to a webhook event (invoice.payment_failed for example) and ask the user to pay via Stripe Elements/Checkout?
Yes. You can also let Stripe to send email to your customer and notify them about failed payments https://dashboard.stripe.com/settings/billing/automatic The email has a link that allows your customers to update their payment information.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.