#binayak-payment

1 messages · Page 1 of 1 (latest)

misty saffron
#

hi, do you have a bit more context?

steel current
#

here's the code snippet, please check if it is correct.
const stripe = require('stripe')('sk_test_51J7k95Cd3LRlmO28v32DBPeCbJpjoe2b8YLeayKF1bHmh1nHPOdcTSWPT6q5lOve1uTNfXm8g0Ku0Qu1zxDKH3in007t6jQqsQ');
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: currency,
payment_method_types: ['card'],
capture_method: 'manual',
type: 'card',
card: {
number: '4242424242424242',
exp_month: 9,
exp_year: 2023,
cvc: '314',
},
automatic_payment_methods: {enabled: true}
});

#

we are trying to create hold.

misty saffron
steel current
#

this is a sandbox code

#

we will refactor

#

please guide

#

the problem is we are getting error while capturing the fund.

misty saffron
#

yep because you didn't "confirm" the PaymentIntent first.

steel current
#

but we will create first, then confirm na?

misty saffron
steel current
#

sir we already have the entire setup done, we just required to hold instead of capture funds immediately.

#

just let me know if any problem is there in the code snippet I shared

#

const stripe = require('stripe')('sk_test_51J7k95Cd3LRlmO28v32DBPeCbJpjoe2b8YLeayKF1bHmh1nHPOdcTSWPT6q5lOve1uTNfXm8g0Ku0Qu1zxDKH3in007t6jQqsQ');
const paymentIntent = await stripe.paymentIntents.create({
amount: amount,
currency: currency,
payment_method_types: ['card'],
capture_method: 'manual',
automatic_payment_methods: {enabled: true}
});

misty saffron
#

there's nothing wrong with it. It creates a PaymentIntent.

steel current
#

but while capturing funds, we are getting error message as:
"message": "This PaymentIntent could not be captured because it has a status of requires_payment_method. Only a PaymentIntent with one of the following statuses may be captured: requires_capture.",

#

so any change we need to do?

misty saffron
#

you need to confirm the PaymentIntent to actually charge the customer

#

after that charge succeeds, you can capture. So like I said, it's the same existing payment integration where you make a PaymentIntent, confirm it on the frontend, handle webhooks etc. The capture is just one extra thing you do at the very end

steel current
#

okay, confirm has to done at front end?

misty saffron
#

yes.

steel current
#

cant we schedule it?

misty saffron
steel current
#

like, if customer orders today, we will create a hold tomorrow and charge after the item gets dispatched.