FIX payment not completed when using Paypal.

This commit is contained in:
Laurent Destailleur 2022-03-02 15:13:17 +01:00
parent 66b0f253b6
commit 940417efe2

View File

@ -245,7 +245,7 @@ if (!empty($conf->paypal->enabled)) {
$fulltag = $FULLTAG;
$payerID = $PAYPALPAYERID;
// Set by newpayment.php
$paymentType = $_SESSION['PaymentType'];
$paymentType = $_SESSION['PaymentType']; // Value can be 'Mark', 'Sole', 'Sale' for example
$currencyCodeType = $_SESSION['currencyCodeType'];
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
// From env
@ -406,10 +406,19 @@ if ($ispaymentok) {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0, '_payment');
@ -783,10 +792,19 @@ if ($ispaymentok) {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
@ -876,12 +894,29 @@ if ($ispaymentok) {
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
$paymentTypeId = 0;
if ($paymentmethod == 'paybox') $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
if ($paymentmethod == 'paybox') {
$paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
}
if ($paymentmethod == 'paypal') {
$paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
}
if ($paymentmethod == 'stripe') {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
if (empty($paymentType)) $paymentType = 'CB';
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
@ -986,10 +1021,19 @@ if ($ispaymentok) {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
@ -1091,10 +1135,19 @@ if ($ispaymentok) {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
@ -1272,10 +1325,19 @@ if ($ispaymentok) {
$paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
}
if (empty($paymentTypeId)) {
dol_syslog("paymentType = ".$paymentType, LOG_DEBUG, 0, '_payment');
if (empty($paymentType)) {
$paymentType = 'CB';
}
// May return nothing when paymentType means nothing
// (for example when paymentType is 'Mark', 'Sole', 'Sale', for paypal)
$paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
// If previous line has returned nothing, we force to get the ID of payment of Credit Card (hard coded code 'CB').
if (empty($paymentTypeId) || $paymentTypeId < 0) {
$paymentTypeId = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
}
}
// Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)