diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php
index a3f6d733fcb..f84a014d5e5 100644
--- a/htdocs/public/payment/paymentko.php
+++ b/htdocs/public/payment/paymentko.php
@@ -129,10 +129,12 @@ if (!empty($_SESSION['ipaddress'])) // To avoid to make action twice
$ipaddress = $_SESSION['ipaddress'];
$errormessage = $_SESSION['errormessage'];
- // Call trigger
- $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user);
- if ($result < 0) $error++;
- // End call triggers
+ if (is_object($object) && method_exists($object, 'call_trigger')) {
+ // Call trigger
+ $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
// Send an email
$sendemail = '';
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index b1d6c149a51..5203da2284f 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -616,8 +616,8 @@ if ($ispaymentok)
{
// Record payment
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $invoice = new Facture($db);
- $result = $invoice->fetch($tmptag['INV']);
+ $object = new Facture($db);
+ $result = $object->fetch($tmptag['INV']);
if ($result)
{
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
@@ -646,11 +646,11 @@ if ($ispaymentok)
$paiement->datepaye = $now;
if ($currencyCodeType == $conf->currency)
{
- $paiement->amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id
+ $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id
}
else
{
- $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt); // Array with all payments dispatching
+ $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching
$postactionmessages[] = 'Payment was done in a different currency that currency expected of company';
$ispostactionok = -1;
@@ -689,7 +689,7 @@ if ($ispaymentok)
if ($bankaccountid > 0)
{
$label = '(CustomerInvoicePayment)';
- if ($invoice->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
+ if ($object->type == Facture::TYPE_CREDIT_NOTE) $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
$result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
if ($result < 0)
{
@@ -748,10 +748,12 @@ if ($ispaymentok)
$currencyCodeType = $_SESSION['currencyCodeType'];
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
- // Call trigger
- $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user);
- if ($result < 0) $error++;
- // End call triggers
+ if (is_object($object) && method_exists($object, 'call_trigger')) {
+ // Call trigger
+ $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_OK', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
print $langs->trans("YourPaymentHasBeenRecorded")."
\n";
if ($TRANSACTIONID) print $langs->trans("ThisIsTransactionId", $TRANSACTIONID)."
\n";
@@ -882,10 +884,12 @@ else
$currencyCodeType = $_SESSION['currencyCodeType'];
$FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
- // Call trigger
- $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user);
- if ($result < 0) $error++;
- // End call triggers
+ if (is_object($object) && method_exists($object, 'call_trigger')) {
+ // Call trigger
+ $result = $object->call_trigger('PAYMENTONLINE_PAYMENT_KO', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
print $langs->trans('DoExpressCheckoutPaymentAPICallFailed')."
\n";
print $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n";