#Giriraj

1 messages · Page 1 of 1 (latest)

untold harnessBOT
delicate ravine
brave arch
#

req_NfYoo0FQfDRtwo

subtle shore
#

Hi! I'm taking over this thread.

#

Give me a few minutes to look into this.

brave arch
#

ok np

subtle shore
brave arch
#

ok so, how can i remove it?

#

i m cancelling paymentintent and let me try again

subtle shore
#

Can you clarify what you are trying to do? Do you want to reuse the same payment method multiple times?

brave arch
#

yes

#

i want to reuse same payment method

#

hello @subtle shore

subtle shore
#

Then you'll get a payment method you can reuse

brave arch
#

const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'usd',
setup_future_usage:{
on_session:true,
off_session:false
}
});

#

like this right?

subtle shore
#

No

#

It's simply: setup_future_usage: "off_session or setup_future_usage: "on_session

brave arch
#

oh sorry ok got it thanks let me try

subtle shore
brave arch
#

checking

#

got this error "You cannot confirm withoff_session=truewhensetup_future_usage is also set on the PaymentIntent. The customer needs to be on-session to perform the steps which may be required to set up the PaymentMethod for future usage. Please confirm this PaymentIntent with your customer on-session."

#

but i need to capture that payment

#

here is my code
const paymentIntent = await stripe.paymentIntents.create(
{
amount: amount,
currency: "usd",
customer: customerId,
payment_method: paymentMethodId,
capture_method: 'manual',
off_session: true,
confirm: true,
setup_future_usage: "on_session"
}
);

subtle shore
#

You need to remove setup_future_usage: "on_session" here, since the payment method is already saved.

brave arch
#

removed now

subtle shore
#

Is it working?

brave arch
#

no still same issue

subtle shore
#

Can you share the request ID (req_xxx)?

brave arch
#

yes sure

#

req_qApPzNWYY5nZVa

subtle shore
brave arch
#

bcz it's requirement

subtle shore
#

The correct flow:

  1. Create a PaymentIntent like this
const paymentIntent = await stripe.paymentIntents.create({
  customer: "cus_xxx",
  amount: 2000,
  currency: 'usd',
 setup_future_usage:  'off_session'
});
  1. Confirm the PaymentIntent on the frontend, and you will get a Payment Method object you can reuse
  2. Later create a new PaymentIntent
const paymentIntent = await stripe.paymentIntents.create({
      amount: amount,
      currency: "usd",
      customer: "cus_xxx",
      payment_method: paymentMethodId,
      capture_method: 'manual',
      off_session: true,
      confirm: true,
});
brave arch
#

and i need to capture that paymentintent

#

ok thanks let me try

subtle shore
#

i just made some changes to the code above (there was some mistakes)

brave arch
#

ok

#

but that payment is success

#

i need to capture

#

i just follow only first step then payment is success from above code

subtle shore
#

Then add capture_method: 'manual' to the first PaymentIntent

brave arch
#

oh wow, it's working fine. thanks man. no need to use step 3 bcz i m updating capture from backend.

subtle shore
#

Awesome!

untold harnessBOT