#alecpope

1 messages · Page 1 of 1 (latest)

toxic sluiceBOT
ionic saffron
#

Hi there, How do you collect the payment method for the subscription?

latent rune
#

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

ionic saffron
latent rune
#

Oh okay, yeah that makes it easier. But if I want to use Stripe Elements, I need to pay the first payment intent?

ionic saffron
#

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.

latent rune
#

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

ionic saffron
#

What's the subscription ID?

latent rune
#

One moment, I will create one

#

sub_1NjxFDCGHYWsrZq5nUSP1oWh

ionic saffron
latent rune
#

Ah, so I need to update the generated invoice with auto_advance: true after creating the subscription?

ionic saffron
#

You can set allow_incomplete as the payment_behavior when creating a subscritption, this tell Stripe to immediately attempt to pay the invoice

latent rune
#

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?

ionic saffron