#maira-paymentintent-manualcapture

1 messages ยท Page 1 of 1 (latest)

dusk saffronBOT
reef sierra
river turret
#

Hello ๐Ÿ™‚ I have used this, but still can't get through

reef sierra
#

Can you share examples of what you've tried and so on?

river turret
#

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

reef sierra
#

So what's happening with the Payment once you create it?

dusk saffronBOT
sturdy harness
#

maira-paymentintent-manualcapture

river turret
#

its holding from stripe account balance. Not from the customer card. I want to hold payment from customer card

sturdy harness