Skip to content

Commit

Permalink
paymentIntent logic update for ideal test
Browse files Browse the repository at this point in the history
  • Loading branch information
ih-abir committed Feb 8, 2024
1 parent 2682354 commit 8333c28
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/workers/dilmahtea-me-stripe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ const handlePOST = async (request, env, ctx) => {
amount: totalAmount,
currency: 'eur',
metadata: { paymentID, payment_type },
});

const confirmPaymentIntent = await stripe.paymentIntents.confirm(paymentIntent.id, {
payment_method: paymentMethod.id,
confirm: true,
return_url: successUrl,
cancel_url: cancel_url,
});

// const confirmPaymentIntent = await stripe.paymentIntents.confirm(paymentIntent.id, {
// payment_method: paymentMethod.id,
// return_url: successUrl,
// });
if (paymentIntent.next_action && paymentIntent.next_action.redirect_to_url) {
const redirectUrl = paymentIntent.next_action.redirect_to_url.url;
}

ctx.waitUntil(
createBaserowRecord(
{
Expand All @@ -136,7 +142,7 @@ const handlePOST = async (request, env, ctx) => {
}),
);

const return_url = confirmPaymentIntent.status === 'succeeded' ? successUrl : cancel_url;
const return_url = paymentIntent.status === 'succeeded' ? successUrl : cancel_url;

return Response.redirect(return_url, 303);
};
Expand Down

0 comments on commit 8333c28

Please sign in to comment.