#krishna-awate_api

1 messages ยท Page 1 of 1 (latest)

plush pelicanBOT
#

๐Ÿ‘‹ 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.

civic moon
#

Hi ๐Ÿ‘‹

Payment Intents are no longer linked directly to Invoices so you cannot get the last_invice.payment_Intent

chilly ore
#

Do I have to

expand: ["latest_invoice.confirmation_secret"]?

civic moon
#

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'],
    });
chilly ore
#

Okay I will check.

plush pelicanBOT
chilly ore
#

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?

civic moon
#

Your subscription is expecting payment.

lucid spoke
#

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?

chilly ore
#

pi_3ReZxeDBfYojrB0W1sZiqJ2f_secret_PbWZfpT7kZA1oiKc6vDW34T4R

#

clientSecret =
subscription?.latest_invoice?.confirmation_secret?.client_secret;

I am passing correct payment_intent

lucid spoke
#

true, but why are you calling confirmSetup() instead of confirmPayment(), as mentioned in the error message?

chilly ore
#

const confirmIntent =
intentType === "setup" ? stripe.confirmSetup : stripe.confirmPayment;

#

calling it for subscription

#

This is how my previous code was working

lucid spoke
#

then you need to update your code. here you are getting the client_secret of a PaymentIntent, so you need to call confirmPayment().

chilly ore
#

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

lucid spoke
#

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()

chilly ore
#

what about this

subscription.latest_invoice.payment_intent.client_secret;

lucid spoke
#

that doesn't exist anymore in the latest API version. invoices no longer have a payment_intent property.

chilly ore
#

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?

lucid spoke
#

how are you accepting payments? with the Payment Element?

chilly ore
#

Yes

lucid spoke
#

and you want to only accept card payments?

chilly ore
#

yes

chilly ore
#

I need same for one time payment.

lucid spoke
#

how do you accept one time payments? with PaymentIntents?

chilly ore
#

yes

#

paymentIntent = await stripe.paymentIntents.create(stripe_data, {
stripeAccount: stripe_account_id,
});

chilly ore
#

automatic_payment_methods: {
enabled: true,
},

shall I use this?

lucid spoke
#

it depends. this means it will accept all payment method that are enabled in your dashboard.

chilly ore
#

So to show card only I will have to disable other payment method from dashbaord?

lucid spoke
#

if you use automatic_payment_methods, then yes. if you use payment_method_types: ["card"], then no.

chilly ore
#

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,
}
);

lucid spoke
chilly ore
#

payment_settings ?

lucid spoke
#

payment_settings.payment_method_types

chilly ore
#

Thank you su much it's working

lucid spoke
#

happy to help ๐Ÿ™‚