diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index abbe1b8acf0..ceb5d6cb984 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -2359,7 +2359,7 @@ if (preg_match('/^dopayment/', $action)) { // If we chose/clicked on the payme print ''."\n"; print ''."\n"; print ''."\n"; - print ''; + print ''."\n"; print ''."\n"; print ''."\n"; print ''; @@ -2367,7 +2367,28 @@ if (preg_match('/^dopayment/', $action)) { // If we chose/clicked on the payme print ''; print ''; - if (getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') || getDolGlobalString('STRIPE_USE_NEW_CHECKOUT')) { // Use a SCA ready method + // Make some check on amount: We accept an amount that is different to allow to pay an existing invoice partially or + // to allow to pay a membership with open amount, but for a payment of an order, we have no reason to accept partial payment. + $checkamount = 1; + $tmptag = dolExplodeIntoArray($fulltag, '.', '='); + if (array_key_exists('ORD', $tmptag) && (int) $tmptag['ORD'] > 0) { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $object = new Commande($db); + $result = $object->fetch((int) $tmptag['ORD']); + if ($result > 0) { + if ($object->total_ttc != $amount) { + $checkamount = 0; + } + } else { + $checkamount = 0; + } + } + if (!$checkamount) { + dol_syslog("Hack attempt detected", LOG_WARNING); + setEventMessages('Bad value for amount. Reported as a hack attempt.', null, 'errors'); + } + + if ($checkamount && (getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION') || getDolGlobalString('STRIPE_USE_NEW_CHECKOUT'))) { // Use a SCA ready method require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $service = 'StripeLive'; @@ -2440,7 +2461,7 @@ if (preg_match('/^dopayment/', $action)) { // If we chose/clicked on the payme if (getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) { if (empty($paymentintent)) { - print '