#Giriraj
1 messages · Page 1 of 1 (latest)
Can you share the ID (req_xxx) of the failing API request? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_NfYoo0FQfDRtwo
i m following this link
https://stripe.com/docs/stripe-js/elements/payment-request-button?client=react#react-complete-payment
ok np
This PaymentMethod was already used in this PaymentIntent: https://dashboard.stripe.com/test/payments/pi_3NTKE7BSgwhLUexT0qT8LkkT
Can you clarify what you are trying to do? Do you want to reuse the same payment method multiple times?
Then you should create the PaymentIntent with setup_future_usage https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
Then you'll get a payment method you can reuse
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'usd',
setup_future_usage:{
on_session:true,
off_session:false
}
});
like this right?
No
It's simply: setup_future_usage: "off_session or setup_future_usage: "on_session
oh sorry ok got it thanks let me try
Then once the PaymentIntent is succesful, you will get a payment method object. And you can re-use it in a new PaymentIntent. See this example: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
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"
}
);
You need to remove setup_future_usage: "on_session" here, since the payment method is already saved.
removed now
Is it working?
no still same issue
Can you share the request ID (req_xxx)?
But why are you creating the Payment Method like this? https://dashboard.stripe.com/test/logs/req_d2TVsq4GO5AYlp
You don't you directly create a PaymentIntent?
bcz it's requirement
The correct flow:
- Create a PaymentIntent like this
const paymentIntent = await stripe.paymentIntents.create({
customer: "cus_xxx",
amount: 2000,
currency: 'usd',
setup_future_usage: 'off_session'
});
- Confirm the PaymentIntent on the frontend, and you will get a Payment Method object you can reuse
- 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,
});
i just made some changes to the code above (there was some mistakes)
ok
but that payment is success
i need to capture
i just follow only first step then payment is success from above code
Then add capture_method: 'manual' to the first PaymentIntent
oh wow, it's working fine. thanks man. no need to use step 3 bcz i m updating capture from backend.
Awesome!