Merge branch '21.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
ldestailleur 2025-04-09 15:40:02 +02:00
commit eb4e5a4685
3 changed files with 39 additions and 6 deletions

View file

@ -1490,6 +1490,7 @@ class Facture extends CommonInvoice
$this->pos_source = $object->pos_source;
$this->origin = $object->element;
$this->origin_type = $object->element;
$this->origin_id = $object->id;
$this->fk_user_author = $user->id;

View file

@ -1010,6 +1010,7 @@ if (isModEnabled('paybox')) {
}
if (isModEnabled('stripe')) {
print '<!-- STRIPE_LIVE = '.getDolGlobalString('STRIPE_LIVE').' -->'."\n";
print '<!-- STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = '.getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION').' -->'."\n";
}
print '<!-- urlok = '.$urlok.' -->'."\n";
print '<!-- urlko = '.$urlko.' -->'."\n";
@ -2368,7 +2369,7 @@ if (preg_match('/^dopayment/', $action)) { // If we chose/clicked on the payme
print '<input type="hidden" name="fulltag" value="'.$FULLTAG.'">'."\n";
print '<input type="hidden" name="suffix" value="'.$suffix.'">'."\n";
print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n";
print '<input type="hidden" name="e" value="'.$entity.'" />';
print '<input type="hidden" name="e" value="'.$entity.'" />'."\n";
print '<input type="hidden" name="amount" value="'.$amount.'">'."\n";
print '<input type="hidden" name="currency" value="'.$currency.'">'."\n";
print '<input type="hidden" name="forcesandbox" value="'.GETPOSTINT('forcesandbox').'" />';
@ -2376,7 +2377,28 @@ if (preg_match('/^dopayment/', $action)) { // If we chose/clicked on the payme
print '<input type="hidden" name="thirdparty_id" value="'.GETPOSTINT('thirdparty_id').'" />';
print '<input type="hidden" name="lang" value="'.$getpostlang.'">';
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';
@ -2449,7 +2471,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 '<center>'.$langs->trans("Error").'</center>';
print '<center>'.$langs->trans("Error").' - Failed to get PaymentIntent</center>';
} else {
print '<input type="hidden" name="paymentintent_id" value="'.$paymentintent->id.'">';
//$_SESSION["paymentintent_id"] = $paymentintent->id;

View file

@ -1072,9 +1072,19 @@ if ($ispaymentok) {
$invoice = new Facture($db);
$result = $invoice->createFromOrder($object, $user);
if ($result > 0) {
$object->classifyBilled($user);
$invoice->validate($user);
// Creation of payment line
if ($FinalPaymentAmt != $object->total_ttc) {
// The amount paid can be lower than the order only if the user tried to modified the amount from the payment page. A payment has been received but it is a hack attempt
// We can add a line to reduce the amount of the invoice but with which vat ?
// TODO Test if vat on line is the same everywhere, if yes we can add
// $invoice->addline('Fix amount of invoice', $FinalPaymentAmt - $object->total_ttc, 1, $txtva);
// TODO Send a warning email.
}
$object->classifyBilled($user); // The invoice has been create from the order so total is the same, so we can classify order to billed (even if payment may be partial).
$invoice->validate($user); // This may re-classify all linked orders to billed (done previously) if amount of invoice is ok by triggers, depending on the workflow module setup.
// Creation of payment line (warning: if amount has been modified on page, the payment may be partial)
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
$paiement = new Paiement($db);
$paiement->datepaye = $now;