#maira-paymentintent-manualcapture
1 messages ยท Page 1 of 1 (latest)
Hello ๐
I believe you're looking for this flow
https://stripe.com/docs/payments/place-a-hold-on-a-payment-method
Have you looked at the above docs or no?
Hello ๐ I have used this, but still can't get through
Can you share examples of what you've tried and so on?
sure
// Create a Payment Intent to hold the initial payment
app.post('/create-payment-intent', async (req, res) => {
try {
const { amount, currency, customerId } = req.body;
const paymentIntent = await stripe.paymentIntents.create({
amount,
currency,
customer: customerId,
payment_method_types: ['card'],
description: 'Ad Booking Payment Hold',
confirm: true,
capture_method: 'manual',
});
res.status(200).json({ clientSecret: paymentIntent.client_secret });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Update the Payment Intent to add more payment
app.post('/add-more-payment', async (req, res) => {
try {
const { paymentIntentId, amountToAdd } = req.body;
const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);
await stripe.paymentIntents.update(paymentIntentId, {
amount: paymentIntent.amount + amountToAdd,
});
res.status(200).json({ message: 'Additional payment added successfully.' });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Complete the booking and capture the payment
app.post('/complete-booking', async (req, res) => {
try {
const { paymentIntentId } = req.body;
await stripe.paymentIntents.capture(paymentIntentId);
res.status(200).json({ message: 'Booking completed and payment captured.' });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
this is what I have used
So what's happening with the Payment once you create it?
maira-paymentintent-manualcapture
its holding from stripe account balance. Not from the customer card. I want to hold payment from customer card
@river turret https://stripe.com/docs/payments/place-a-hold-on-a-payment-method is the end to end doc for this which my colleague covered earlier.
If you use that, it will hold funds on the customer's card until you capture those funds