#krishna-awate_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1388101905871409273
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
Payment Intents are no longer linked directly to Invoices so you cannot get the last_invice.payment_Intent
We now return a latest_invoice.confirmation_secret that you can use to initialize the Payment Element instead. We document this revised approach in our integration guide: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements#create-subscription
Do I have to
expand: ["latest_invoice.confirmation_secret"]?
Yes. Please look at the code snippets in the doc I provided. The Node.js snippet for ceating a Subscription now shows this:
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{
price: priceId,
}],
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: ['latest_invoice.confirmation_secret'],
});
Okay I will check.
StripeCheckout.jsx:81 Uncaught (in promise) IntegrationError: Your code called confirmSetup() but you passed a client_secret associated with a PaymentIntent. Did you mean to call confirmPayment() instead?
Your subscription is expecting payment.
hi! I'm taking over this thread.
the error you shared explains the problem pretty well:
Your code called confirmSetup() but you passed a client_secret associated with a PaymentIntent. Did you mean to call confirmPayment() instead?
pi_3ReZxeDBfYojrB0W1sZiqJ2f_secret_PbWZfpT7kZA1oiKc6vDW34T4R
clientSecret =
subscription?.latest_invoice?.confirmation_secret?.client_secret;
I am passing correct payment_intent
true, but why are you calling confirmSetup() instead of confirmPayment(), as mentioned in the error message?
const confirmIntent =
intentType === "setup" ? stripe.confirmSetup : stripe.confirmPayment;
calling it for subscription
This is how my previous code was working
then you need to update your code. here you are getting the client_secret of a PaymentIntent, so you need to call confirmPayment().
clientSecret = subscription.pending_setup_intent.client_secret;
do I need to use this?
or subscription?.latest_invoice?.confirmation_secret?.client_secret;
this is udpated one.
Which to use for subscription payment intent
if the first invoice of the subscription needs to be paid, you need to use subscription?.latest_invoice?.confirmation_secret?.client_secret, and call onfirmPayment()
if the first invoice of the subscription is for $0 (for example when using free trial), then there's nothing to pay. In this case you need to use the subscription.pending_setup_intent.client_secret and call confirmSetup()
what about this
subscription.latest_invoice.payment_intent.client_secret;
that doesn't exist anymore in the latest API version. invoices no longer have a payment_intent property.
Okay
Thank you so much for your help.
It's working.
Also I have one query
Is there any way to show only card checkout on UI?
how are you accepting payments? with the Payment Element?
Yes
and you want to only accept card payments?
yes
then use this when creating the Subscription: https://docs.stripe.com/api/subscriptions/object?api-version=2025-05-28.preview&lang=curl#subscription_object-payment_settings-payment_method_types
I need same for one time payment.
how do you accept one time payments? with PaymentIntents?
yes
paymentIntent = await stripe.paymentIntents.create(stripe_data, {
stripeAccount: stripe_account_id,
});
automatic_payment_methods: {
enabled: true,
},
shall I use this?
it depends. this means it will accept all payment method that are enabled in your dashboard.
So to show card only I will have to disable other payment method from dashbaord?
if you use automatic_payment_methods, then yes. if you use payment_method_types: ["card"], then no.
It's working for one-time payment
How can I do for subscription?
const subscription = await stripe.subscriptions.create(
{
customer: customer.id,
items: [{ price: price.id }],
payment_behavior: "default_incomplete",
payment_settings: {
save_default_payment_method: "on_subscription",
},
expand: ["latest_invoice.confirmation_secret"],
application_fee_percent: +service_fee,
cancel_at: sub_end_date,
description: transaction_description,
},
{
stripeAccount: stripe_account_id,
}
);
I already answered that question
then use this when creating the Subscription: https://docs.stripe.com/api/subscriptions/object?api-version=2025-05-28.preview&lang=curl#subscription_object-payment_settings-payment_method_types
payment_settings ?
payment_settings.payment_method_types
Thank you su much it's working
happy to help ๐