#kado-kaelan-default-payment
1 messages · Page 1 of 1 (latest)
on a subscription that is
I've referred to this snippet but my payment intent comes in as null
I have already saved paymentMethod to the setupIntent
Just so I understand this:
- You collect card details and use a SetupIntent to create a PaymentMethod
- You are creating a subscription with a trial period and want that PaymentMethod to be the default payment method for that subscription?
So there are two ways to do this off the top of my head:
- When creating the subscription, you can look up the customer's PaymentMethods and use this PM as the Subscription's default_payment_method similar to what you are doing there. https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method
- On
setup_intent.succeededyou can set the Customer'sinvoice_settings.default_payment_methodto be the PM you just created. That will make it the default subscription payment method for the entire account. https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method
like so?
wait hold up modifying that now
``
const customer = await stripe.customers.update(customerId, {
invoice_settings: { default_payment_method: paymentMethod },
});
``
That looks right. I don't think the console.log line would work because I don't think it will have a payment_method property