diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c0712da4f2b..8c1f4c9ea59 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -783,6 +783,18 @@ if ($action == 'charge' && isModEnabled('stripe')) { // Test on permission not r setEventMessages($e->getMessage(), null, 'errors'); $action = ''; } + + if ($error) { + $randomseckey = getRandomPassword(true, null, 20); + $_SESSION['paymentkosessionkey'] = $randomseckey; // key between newpayment.php to paymentko.php + + $urlko .= '&paymentkosessionkey='.urlencode($randomseckey); + } else { + $randomseckey = getRandomPassword(true, null, 20); + $_SESSION['paymentoksessionkey'] = $randomseckey; // key between newpayment.php to paymentok.php + + $urlok .= '&paymentoksessionkey='.urlencode($randomseckey); + } } // When using the PaymentIntent API architecture (mode set on by default into conf.class.php) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index f866f20826b..376ee9afafd 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -379,9 +379,13 @@ if (isModEnabled('paybox')) { // For Stripe if (isModEnabled('stripe')) { if ($paymentmethod === 'stripe') { - // TODO Add a check to validate that payment is ok. - // We can request Stripe with payment_intent and payment_intent_client_secret the sameway we do in newpayment after comment "// Get here amount and currency used for payment". - $ispaymentok = true; // We call this page only if payment is ok on payment system + // Check we are coming from the newpaymentpage + if (GETPOST('paymentoksessionkey') == $_SESSION['paymentoksessionkey']) { + // We can also request Stripe with payment_intent and payment_intent_client_secret the sameway we do in newpayment after comment "// Get here amount and currency used for payment". + $ispaymentok = true; // We call this page only if payment is ok on payment system + } else { + $ispaymentok = false; // We call this page only if payment is ok on payment system + } } }