#kado-kaelan-default-payment

1 messages · Page 1 of 1 (latest)

spark glen
brisk bear
#

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

spark glen
#

Just so I understand this:

  1. You collect card details and use a SetupIntent to create a PaymentMethod
  2. You are creating a subscription with a trial period and want that PaymentMethod to be the default payment method for that subscription?
brisk bear
#

thats right!

spark glen
#

So there are two ways to do this off the top of my head:

  1. 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
  2. On setup_intent.succeeded you can set the Customer's invoice_settings.default_payment_method to 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
brisk bear
#

like so?

#

wait hold up modifying that now

#

``
const customer = await stripe.customers.update(customerId, {
invoice_settings: { default_payment_method: paymentMethod },
});

``

spark glen
#

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

brisk bear
#

gotcha thanks!

#

then from here their card will automatically get charged until they cancel?