#ctodan
1 messages · Page 1 of 1 (latest)
You don't, because the first invoice doesn't require payment, its a trial
instead, you confirm the subscriptions pending_setup_intent to collect the payment detils, if you want to do that up front
const latestInvoice: Stripe.Invoice = subscription.latest_invoice as Stripe.Invoice
const paymentIntent: Stripe.PaymentIntent =
latestInvoice.payment_intent as Stripe.PaymentIntent
await this.stripe.paymentIntents.confirm(paymentIntent.id, {
payment_method: paymentMethodId,
mandate_data: {
customer_acceptance: {
type: "online",
accepted_at: new Date().getTime(),
online: {
ip_address: ipAddress,
user_agent: userAgent,
},
},
},
})
so this is what we currently do (with no trial period)
We'd like to make it so that the user is automatically charged at the end of the trial to an existing payment_method (unless they cancel of course)
WHen you start a subscription with a trial period, you'll find a pending_setup_intent instead:
https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But that looks like you're confirming the payment intent with a payment method you already have -- where does that payment method come from?
So first step in our set up for our app is linking a bank account with Plaid
so that gets linked to stripe via the old sources api
ok, so you always collect this up front?
ya, for context its an investing app
so plaid account is used to fund the brokerage account as well
If you have a payment method id, you can similarly confirm the pending setup intent:
https://stripe.com/docs/api/setup_intents/confirm
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But if the bank payment methis is already set up, you can provide the default_payment_method=pm_123 when creating the subscription:
https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
hmm ok, do i have to provide it in the subscription creation?
Can i not provide it in the setupIntent.confirm?
You should be able to provide it in the setup confirm, yes.