34if (!defined(
'NOLOGIN')) {
37if (!defined(
'NOCSRFCHECK')) {
38 define(
"NOCSRFCHECK", 1);
40if (!defined(
'NOIPCHECK')) {
41 define(
'NOIPCHECK',
'1');
43if (!defined(
'NOBROWSERNOTIF')) {
44 define(
'NOBROWSERNOTIF',
'1');
46if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
47 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
53$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
54if (is_numeric($entity)) {
55 define(
"DOLENTITY", $entity);
59require
'../../main.inc.php';
70require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
71require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
72require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
74 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
75 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
81$hookmanager->initHooks(array(
'newpayment'));
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paypal",
"stripe"));
87$PAYPAL_API_PASSWORD =
"";
88$PAYPAL_API_SIGNATURE =
"";
89$PAYPAL_API_SANDBOX =
"";
98 $PAYPALTOKEN =
GETPOST(
'TOKEN');
99 if (empty($PAYPALTOKEN)) {
100 $PAYPALTOKEN =
GETPOST(
'token');
102 $PAYPALPAYERID =
GETPOST(
'PAYERID');
103 if (empty($PAYPALPAYERID)) {
104 $PAYPALPAYERID =
GETPOST(
'PayerID');
109if (empty($FULLTAG)) {
115$suffix =
GETPOST(
"suffix",
'aZ09');
122if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
123 $paymentmethod = $reg[1];
125if (empty($paymentmethod)) {
126 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
127 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
131dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
135$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
137 dol_syslog(
"paymentok.php page is invoked from a website with ref ".$ws.
". It performs actions and then redirects back to this website. A page with ref paymentok must be created for this website.", LOG_DEBUG, 0,
'_payment');
140$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
143if (empty($validpaymentmethod)) {
149$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
150$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
160$PAYMENTSTATUS = $TRANSACTIONID = $LONGTRANSACTIONID = $TAXAMT = $NOTE =
'';
162$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
170$ws_virtuelhost =
null;
172$doactionsthenredirect = 0;
174 $doactionsthenredirect = 1;
175 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
177 $result = $website->fetch(0, $ws);
179 $ws_virtuelhost = $website->virtualhost;
180 $ws_id = $website->id;
197dol_syslog(
"Callback url when a payment was done. doactionsthenredirect=".$doactionsthenredirect.
" query_string=".(empty($_SERVER[
"QUERY_STRING"]) ?
'' :
dol_escape_htmltag($_SERVER[
"QUERY_STRING"])).
" script_uri=".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SCRIPT_URI"])), LOG_DEBUG, 0,
'_payment');
198dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
199dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
202foreach ($_POST as $k => $v) {
203 if (is_scalar($k) && is_scalar($v)) {
204 $tracepost .=
"$k=$v\n";
207dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
210foreach ($_SESSION as $k => $v) {
211 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
212 $tracesession .=
"$k=$v\n";
215dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
217dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
221 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
224$conf->dol_hide_topmenu = 1;
225$conf->dol_hide_leftmenu = 1;
229if (empty($doactionsthenredirect)) {
230 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
231 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
235 print
'<span id="dolpaymentspan"></span>'.
"\n";
236 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
241 $logosmall =
$mysoc->logo_small;
243 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
253 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
254 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
255 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
256 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
257 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
263 print
'<div class="backgreypublicpayment">';
264 print
'<div class="logopublicpayment">';
265 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
269 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
272 } elseif ($creditor) {
273 print
'<div class="backgreypublicpayment">';
274 print
'<div class="logopublicpayment">';
280 print
'<div class="backimagepublicpayment">';
281 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
286 print
'<br><br><br>';
291$service = $paymentmethod;
294if (
isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
295 if (!empty($PAYPALTOKEN)) {
298 $onlinetoken = $PAYPALTOKEN;
300 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
302 $ipaddress = $_SESSION[
'ipaddress'];
303 $currencyCodeType = $_SESSION[
'currencyCodeType'];
304 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
305 $paymentType = $_SESSION[
'PaymentType'];
307 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
310 if (!empty($paymentType)) {
311 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
315 $ack = strtoupper($resArray[
"ACK"]);
316 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
318 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
323 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
324 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
327 $ack = strtoupper($resArray2[
"ACK"]);
328 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
329 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
335 $object->resArray = $resArray2;
339 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
340 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
341 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
342 $NOTE = urldecode($resArray2[
"NOTE"]);
349 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
350 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
351 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
352 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
355 $ErrorCode =
"SESSIONEXPIRED";
356 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
357 $ErrorShortMsg =
"Session expired";
359 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
363 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
364 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
365 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
367 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
373if (
isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
375 if (empty($TRANSACTIONID)) {
376 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
377 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
379 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
382 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
383 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
385 $service =
'StripeTest';
388 $service =
'StripeLive';
395 if (!
GETPOST(
'payment_intent',
'alphanohtml') &&
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
397 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
402 if (!$error && $TRANSACTIONID) {
405 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
407 $stripeacc = $stripe->getStripeAccount($service);
410 global $stripearrayofkeysbyenv;
411 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
414 if (empty($stripeacc)) {
415 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
417 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
422 $zeroDecimalCurrencies = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
423 if (in_array(strtoupper($currencyCodeType), $zeroDecimalCurrencies)) {
424 $expectedAmount = (int) round($FinalPaymentAmt);
426 $expectedAmount = (int) round($FinalPaymentAmt * 100);
428 $expectedCurrency = strtolower($currencyCodeType);
430 if ((
int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
432 $errmsg =
'Stripe payment information mismatch: expected amount ' . $expectedAmount .
' and currency ' . $expectedCurrency .
', got amount ' . $paymentIntent->amount .
' and currency ' . $paymentIntent->currency;
435 if ($paymentIntent->status !==
'succeeded') {
437 $errmsg =
'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
444 if ($paymentIntent instanceof \
Stripe\PaymentIntent) {
445 $customerid = $paymentIntent->customer;
447 if (isset($stripearrayofkeysbyenv[$servicestatus][
'publishable_key'])) {
448 $pkey = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
451 if ($customerid && $pkey) {
452 $LONGTRANSACTIONID = $TRANSACTIONID.
':'.$customerid.
'@'.$pkey;
456 $errormessage =
"Stripe API error: ".$e->getMessage();
457 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
461 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
462 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
467 $errmsg =
'Stripe API error: ' . $e->getMessage();
472 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
480 $ispaymentok =
false;
485if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
489 'paymentmethod' => $paymentmethod,
491 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
493 if (isset($hookmanager->resArray[
'ispaymentok'])) {
494 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
495 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
504if (empty($ipaddress)) {
505 $ipaddress = $_SESSION[
'ipaddress'];
507if (empty($FinalPaymentAmt)) {
508 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
510if (empty($currencyCodeType)) {
511 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
513if (empty($paymentType)) {
514 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
517if (empty($TRANSACTIONID)) {
518 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
519 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
521 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
539$postactionmessages = array();
542 if (empty($user->rights->societe)) {
543 $user->rights->societe =
new stdClass();
545 if (empty($user->rights->facture)) {
546 $user->rights->facture =
new stdClass();
547 $user->rights->facture->invoice_advance =
new stdClass();
549 if (empty($user->rights->adherent)) {
550 $user->rights->adherent =
new stdClass();
551 $user->rights->adherent->cotisation =
new stdClass();
553 $user->rights->societe->creer = 1;
554 $user->rights->facture->creer = 1;
555 $user->rights->facture->invoice_advance->validate = 1;
556 $user->rights->adherent->cotisation->creer = 1;
558 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
565 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
566 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
567 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
571 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
572 $result2 = $adht->fetch(
$object->typeid);
574 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
575 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
577 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
579 if ($result1 > 0 && $result2 > 0) {
580 if ($paymentmethod ==
'paybox') {
583 if ($paymentmethod ==
'paypal') {
586 if ($paymentmethod ==
'stripe') {
589 if (empty($paymentTypeId)) {
590 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
592 if (empty($paymentType)) {
600 if (empty($paymentTypeId) || $paymentTypeId < 0) {
605 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
608 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
610 $amountbytype = $adht->amountByType(1);
611 $minimumamountbytype = $adht->minimumamountbytype(1);
612 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
614 if (empty($adht->caneditamount)) {
615 if (
$object->status == $object::STATUS_DRAFT) {
618 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
624 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), (
float) $minimumamount);
626 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
628 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') propagated by payment page differs from the expected value for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
629 $postactionmessages[] = $errmsg;
630 $ispostactionok = -1;
631 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
638 if ($FinalPaymentAmt <
getDolGlobalInt(
'MEMBER_MIN_AMOUNT') || $FinalPaymentAmt < $minimumamount) {
640 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' . max(
getDolGlobalString(
'MEMBER_MIN_AMOUNT'), $minimumamount).
'). May be a hack to try to pay a different amount ?';
641 $postactionmessages[] = $errmsg;
642 $ispostactionok = -1;
643 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
648 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
650 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
651 $postactionmessages[] = $errmsg;
652 $ispostactionok = -1;
653 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
658 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
662 $postactionmessages[] = $errmsg;
663 $postactionmessages = array_merge($postactionmessages,
$object->errors);
664 $ispostactionok = -1;
665 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
668 if (empty(
$object->datevalid)) {
669 dol_syslog(
"Member date of validation is empty. We define it", LOG_WARNING, 0,
'_payment');
671 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
672 $sql .=
" datevalid = '".$db->idate($now).
"'";
673 $sql .=
" WHERE rowid = ".((int)
$object->id);
674 $result =
$db->query($sql);
678 $errmsg =
$db->error();
679 $postactionmessages[] = $errmsg;
681 $ispostactionok = -1;
682 dol_syslog(
"Failed to set date of validation: ".$errmsg, LOG_ERR, 0,
'_payment');
688 $datesubscription =
$object->datevalid;
705 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
708 while ($datesubend < $now) {
710 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
717 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (
string)
$object->thirdparty->default_lang);
719 $amount = $FinalPaymentAmt;
720 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
721 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
725 if ($paymentmethod ==
'paybox') {
728 if ($paymentmethod ==
'paypal') {
731 if ($paymentmethod ==
'stripe') {
737 'paymentmethod' => $paymentmethod,
739 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
741 if (isset($hookmanager->resArray[
'bankaccountid'])) {
742 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
743 $accountid = $hookmanager->resArray[
'bankaccountid'];
746 if ($accountid < 0) {
748 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
749 $postactionmessages[] = $errmsg;
750 $ispostactionok = -1;
751 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
757 $emetteur_banque =
'';
761 $option =
'bankviainvoice';
763 $option =
'bankdirect';
765 $option =
'invoiceonly';
767 if (empty($option)) {
778 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
780 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
784 $postactionmessages[] = $errmsg;
785 $ispostactionok = -1;
787 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
792 $autocreatethirdparty = 0;
795 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
797 $autocreatethirdparty = 1;
799 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
804 $postactionmessages[] =
$object->error;
805 $postactionmessages = array_merge($postactionmessages,
$object->errors);
806 $ispostactionok = -1;
808 if ($option ==
'bankviainvoice') {
809 $postactionmessages[] =
'Invoice, payment and bank record created';
810 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
812 if ($option ==
'bankdirect') {
813 $postactionmessages[] =
'Bank record created';
814 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
816 if ($option ==
'invoiceonly') {
817 $postactionmessages[] =
'Invoice recorded';
818 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
828 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
831 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
833 $service =
'StripeTest';
836 $service =
'StripeLive';
842 $thirdparty->fetch($thirdparty_id);
844 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
848 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
850 if (!$customer && $TRANSACTIONID) {
851 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
854 global $stripearrayofkeysbyenv;
855 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
857 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
859 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
862 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
866 $stripecu = $chpi->customer;
868 if (empty($stripecu)) {
870 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
873 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
874 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
877 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
878 $sql .=
" VALUES (".((int) $thirdparty_id).
", '', '".
$db->escape($stripecu).
"', 'stripe', '".
$db->escape($stripearrayofkeysbyenv[$servicestatus][
'publishable_key']).
"', ".((int) $servicestatus).
", ".((int)
$conf->entity).
", '".
$db->idate(
dol_now()).
"', 0)";
879 $resql =
$db->query($sql);
882 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
884 $postactionmessages[] = $errmsg;
885 $ispostactionok = -1;
890 $errmsg =
'Failed to retrieve paymentintent or charge from id';
892 $postactionmessages[] = $errmsg;
893 $ispostactionok = -1;
897 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
899 $postactionmessages[] = $errmsg;
900 $ispostactionok = -1;
922 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
923 $resqlcount =
$db->query($sql);
925 $objcount =
$db->fetch_object($resqlcount);
927 $found = $objcount->nb;
932 $result = $nuser->create_from_member($tmpuser,
$object->login);
933 $newpassword = $nuser->setPassword($user,
'');
936 $outputlangs->load(
"errors");
937 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
939 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
940 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
943 $outputlangs->load(
"errors");
944 $postactionmessages[] =
'No user created because a user linked to member already exists';
950 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
953 if (
$object->email && $sendalsoemail) {
958 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
961 $outputlangs->loadLangs(array(
"main",
"members"));
963 $arraydefaultmessage =
null;
966 if (!empty($labeltouse)) {
967 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
970 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
971 $subject = $arraydefaultmessage->topic;
972 $msg = $arraydefaultmessage->content;
975 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
977 if ($infouserlogin) {
978 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
987 $listofpaths = array();
988 $listofnames = array();
989 $listofmimes = array();
990 if (is_object(
$object->invoice)) {
991 $invoicediroutput =
$conf->facture->dir_output;
993 $file = $fileparams[
'fullname'];
995 $listofpaths = array($file);
996 $listofnames = array(basename($file));
1000 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
1002 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
1006 $postactionmessages[] = $errmsg;
1007 $ispostactionok = -1;
1010 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
1012 $postactionmessages[] =
'Email sent to member (without any attached document)';
1020 $postactionmessages[] =
'Failed to get a valid value for "amount paid" or "payment type" to record the payment of subscription for member '.$tmptag[
'MEM'].
'. May be payment was already recorded.';
1021 $ispostactionok = -1;
1024 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1025 $ispostactionok = -1;
1027 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1029 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1032 $result =
$object->fetch((
int) $tmptag[
'INV']);
1034 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1037 if ($paymentmethod ===
'paybox') {
1040 if ($paymentmethod ===
'paypal') {
1043 if ($paymentmethod ===
'stripe') {
1046 if (empty($paymentTypeId)) {
1047 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1049 if (empty($paymentType)) {
1050 $paymentType =
'CB';
1057 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1062 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1065 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1069 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1071 $paiement->datepaye = $now;
1072 if ($currencyCodeType ==
$conf->currency) {
1073 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1075 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1077 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1078 $ispostactionok = -1;
1081 $paiement->paiementid = $paymentTypeId;
1082 $paiement->num_payment =
'';
1083 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1086 if ($LONGTRANSACTIONID) {
1087 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1089 $paiement->ext_payment_id = $TRANSACTIONID;
1091 $paiement->ext_payment_site = $service;
1095 $result =
$object->validate($user);
1097 $postactionmessages[] =
$object->error;
1098 $ispostactionok = -1;
1101 $postactionmessages[] =
'Invoice validated';
1102 $ispostactionok = 1;
1107 $paiement_id = $paiement->create($user, 1);
1108 if ($paiement_id < 0) {
1109 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1110 $ispostactionok = -1;
1113 $postactionmessages[] =
'Payment created';
1114 $ispostactionok = 1;
1120 if ($paymentmethod ==
'paybox') {
1122 } elseif ($paymentmethod ==
'paypal') {
1124 } elseif ($paymentmethod ==
'stripe') {
1130 'paymentmethod' => $paymentmethod,
1132 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1133 if ($reshook >= 0) {
1134 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1135 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1136 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1139 if ($bankaccountid > 0) {
1140 $label =
'(CustomerInvoicePayment)';
1142 $label =
'(CustomerInvoicePaymentBack)';
1144 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1146 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1147 $ispostactionok = -1;
1150 $postactionmessages[] =
'Bank transaction of payment created';
1151 $ispostactionok = 1;
1154 $postactionmessages[] =
'Setup of bank account to use in module '.$paymentmethod.
' was not set. Your payment was really executed but we failed to record it. Please contact us.';
1155 $ispostactionok = -1;
1166 $postactionmessages[] =
'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.
') or "payment type id" ('.$paymentTypeId.
') to record the payment of invoice '.$tmptag[
'INV'].
'. May be payment was already recorded.';
1167 $ispostactionok = -1;
1170 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1171 $ispostactionok = -1;
1173 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1174 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1176 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1178 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1180 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1183 if ($paymentmethod ==
'paybox') {
1186 if ($paymentmethod ==
'paypal') {
1189 if ($paymentmethod ==
'stripe') {
1192 if (empty($paymentTypeId)) {
1193 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1195 if (empty($paymentType)) {
1196 $paymentType =
'CB';
1203 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1208 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1212 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1215 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1217 $result = $invoice->createFromOrder($object, $user);
1219 if ($FinalPaymentAmt !=
$object->total_ttc) {
1227 $object->classifyBilled($user);
1229 $invoice->validate($user);
1232 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1234 $paiement->datepaye = $now;
1235 if ($currencyCodeType ==
$conf->currency) {
1236 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1238 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1240 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1241 $ispostactionok = -1;
1244 $paiement->paiementid = $paymentTypeId;
1245 $paiement->num_payment =
'';
1246 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1249 if ($LONGTRANSACTIONID) {
1250 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1252 $paiement->ext_payment_id = $TRANSACTIONID;
1254 $paiement->ext_payment_site = $service;
1257 $paiement_id = $paiement->create($user, 1);
1258 if ($paiement_id < 0) {
1259 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1260 $ispostactionok = -1;
1263 $postactionmessages[] =
'Payment created';
1264 $ispostactionok = 1;
1270 if ($paymentmethod ==
'paybox') {
1272 } elseif ($paymentmethod ==
'paypal') {
1274 } elseif ($paymentmethod ==
'stripe') {
1280 'paymentmethod' => $paymentmethod,
1282 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1283 if ($reshook >= 0) {
1284 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1285 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1286 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1289 if ($bankaccountid > 0) {
1290 $label =
'(CustomerInvoicePayment)';
1292 $label =
'(CustomerInvoicePaymentBack)';
1294 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1296 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1297 $ispostactionok = -1;
1300 $postactionmessages[] =
'Bank transaction of payment created';
1301 $ispostactionok = 1;
1304 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1305 $ispostactionok = -1;
1310 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1311 $ispostactionok = -1;
1321 $postactionmessages[] =
'Failed to get a valid value for "amount paid" (' . $FinalPaymentAmt .
') or "payment type id" (' . $paymentTypeId .
') to record the payment of order ' . $tmptag[
'ORD'] .
'. May be payment was already recorded.';
1322 $ispostactionok = -1;
1325 $postactionmessages[] =
'Invoice module is not enable';
1326 $ispostactionok = -1;
1329 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1330 $ispostactionok = -1;
1332 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1333 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1335 $result = $don->fetch((
int) $tmptag[
'DON']);
1338 if ($paymentmethod ==
'paybox') {
1341 if ($paymentmethod ==
'paypal') {
1344 if ($paymentmethod ==
'stripe') {
1347 if (empty($paymentTypeId)) {
1348 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1350 if (empty($paymentType)) {
1351 $paymentType =
'CB';
1358 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1364 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1368 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1371 $totalpaid = $FinalPaymentAmt;
1373 if ($currencyCodeType ==
$conf->currency) {
1374 $paiement->amounts = array(
$object->id => $totalpaid);
1377 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1378 $ispostactionok = -1;
1382 $paiement->fk_donation = $don->id;
1383 $paiement->datep = $now;
1384 $paiement->paymenttype = $paymentTypeId;
1385 $paiement->num_payment =
'';
1386 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1389 if ($LONGTRANSACTIONID) {
1390 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1392 $paiement->ext_payment_id = $TRANSACTIONID;
1394 $paiement->ext_payment_site = $service;
1397 $paiement_id = $paiement->create($user, 1);
1398 if ($paiement_id < 0) {
1399 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1400 $ispostactionok = -1;
1403 $postactionmessages[] =
'Payment created';
1404 $ispostactionok = 1;
1406 if ($totalpaid >= $don->getRemainToPay()) {
1407 $don->valid_promesse($don->id, $user->id);
1408 $don->setPaid($don->id);
1415 if ($paymentmethod ==
'paybox') {
1417 } elseif ($paymentmethod ==
'paypal') {
1419 } elseif ($paymentmethod ==
'stripe') {
1425 'paymentmethod' => $paymentmethod,
1427 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1428 if ($reshook >= 0) {
1429 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1430 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1431 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1434 if ($bankaccountid > 0) {
1435 $label =
'(DonationPayment)';
1436 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1438 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1439 $ispostactionok = -1;
1442 $postactionmessages[] =
'Bank transaction of payment created';
1443 $ispostactionok = 1;
1446 $postactionmessages[] =
'Setup of bank account to use in module '.$paymentmethod.
' was not set. Your payment was really executed but we failed to record it. Please contact us.';
1447 $ispostactionok = -1;
1458 $postactionmessages[] =
'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.
') or "payment type id" ('.$paymentTypeId.
') to record the payment of donation '.$tmptag[
'DON'].
'. May be payment was already recorded.';
1459 $ispostactionok = -1;
1462 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1463 $ispostactionok = -1;
1468 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1470 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1471 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1472 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1474 $result =
$object->fetch((
int) $ref);
1477 if ($paymentmethod ==
'paybox') {
1480 if ($paymentmethod ==
'paypal') {
1483 if ($paymentmethod ==
'stripe') {
1486 if (empty($paymentTypeId)) {
1487 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1489 if (empty($paymentType)) {
1490 $paymentType =
'CB';
1497 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1503 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1504 $resultvalidate =
$object->validate($user);
1505 if ($resultvalidate < 0) {
1506 $postactionmessages[] =
'Cannot validate invoice';
1507 $ispostactionok = -1;
1513 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1515 $paiement->datepaye = $now;
1516 if ($currencyCodeType ==
$conf->currency) {
1517 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1519 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1521 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1522 $ispostactionok = -1;
1525 $paiement->paiementid = $paymentTypeId;
1526 $paiement->num_payment =
'';
1527 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1530 if ($LONGTRANSACTIONID) {
1531 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1533 $paiement->ext_payment_id = $TRANSACTIONID;
1535 $paiement->ext_payment_site = $service;
1538 $paiement_id = $paiement->create($user, 1);
1539 if ($paiement_id < 0) {
1540 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1541 $ispostactionok = -1;
1544 $postactionmessages[] =
'Payment created';
1545 $ispostactionok = 1;
1551 if ($paymentmethod ==
'paybox') {
1553 } elseif ($paymentmethod ==
'paypal') {
1555 } elseif ($paymentmethod ==
'stripe') {
1561 'paymentmethod' => $paymentmethod,
1563 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1564 if ($reshook >= 0) {
1565 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1566 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1567 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1570 if ($bankaccountid > 0) {
1571 $label =
'(CustomerInvoicePayment)';
1573 $label =
'(CustomerInvoicePaymentBack)';
1575 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1577 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1578 $ispostactionok = -1;
1581 $postactionmessages[] =
'Bank transaction of payment created';
1582 $ispostactionok = 1;
1585 $postactionmessages[] =
'Setup of bank account to use in module '.$paymentmethod.
' was not set. Your payment was really executed but we failed to record it. Please contact us.';
1586 $ispostactionok = -1;
1595 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1596 if ($resultattendee < 0) {
1600 $attendeetovalidate->validate($user);
1602 $attendeetovalidate->amount = $FinalPaymentAmt;
1603 $attendeetovalidate->date_subscription =
dol_now();
1604 $attendeetovalidate->update($user);
1619 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1620 if ($resultthirdparty < 0) {
1623 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1624 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1628 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (
string) $thirdparty->default_lang);
1630 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1632 $arraydefaultmessage =
null;
1634 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1636 if (!empty($idoftemplatetouse)) {
1637 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1640 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1641 $subject = $arraydefaultmessage->topic;
1642 $msg = $arraydefaultmessage->content;
1644 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1645 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1648 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1654 $sendto = $attendeetovalidate->email;
1656 if ($thirdparty->email) {
1657 $cc = $thirdparty->email ??
'';
1659 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1660 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1665 $urlback = $_SERVER[
"REQUEST_URI"];
1671 $listofpaths = array();
1672 $listofnames = array();
1673 $listofmimes = array();
1674 if (is_object($object)) {
1675 $invoicediroutput =
$conf->facture->dir_output;
1677 $file = $fileparams[
'fullname'];
1679 $listofpaths = array($file);
1680 $listofnames = array(basename($file));
1684 $trackid =
'inv'.$object->id;
1686 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1688 $result = $mailfile->sendfile();
1690 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1692 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1698 $postactionmessages[] =
'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.
') or "payment type id" ('.$paymentTypeId.
') to record the payment of invoice '.$tmptag[
'ATT'].
'. May be payment was already recorded.';
1699 $ispostactionok = -1;
1702 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1703 $ispostactionok = -1;
1705 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1707 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1708 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1709 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1711 $result =
$object->fetch((
int) $ref);
1713 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1716 if ($paymentmethod ==
'paybox') {
1719 if ($paymentmethod ==
'paypal') {
1722 if ($paymentmethod ==
'stripe') {
1725 if (empty($paymentTypeId)) {
1726 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1728 if (empty($paymentType)) {
1729 $paymentType =
'CB';
1736 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1742 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1743 $resultvalidate =
$object->validate($user);
1744 if ($resultvalidate < 0) {
1745 $postactionmessages[] =
'Cannot validate invoice';
1746 $ispostactionok = -1;
1752 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1754 $paiement->datepaye = $now;
1755 if ($currencyCodeType ==
$conf->currency) {
1756 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1758 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1760 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1761 $ispostactionok = -1;
1764 $paiement->paiementid = $paymentTypeId;
1765 $paiement->num_payment =
'';
1766 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1769 if ($LONGTRANSACTIONID) {
1770 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1772 $paiement->ext_payment_id = $TRANSACTIONID;
1774 $paiement->ext_payment_site = $service;
1777 $paiement_id = $paiement->create($user, 1);
1778 if ($paiement_id < 0) {
1779 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1780 $ispostactionok = -1;
1783 $postactionmessages[] =
'Payment created';
1784 $ispostactionok = 1;
1790 if ($paymentmethod ==
'paybox') {
1792 } elseif ($paymentmethod ==
'paypal') {
1794 } elseif ($paymentmethod ==
'stripe') {
1800 'paymentmethod' => $paymentmethod,
1802 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1803 if ($reshook >= 0) {
1804 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1805 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1806 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1809 if ($bankaccountid > 0) {
1810 $label =
'(CustomerInvoicePayment)';
1812 $label =
'(CustomerInvoicePaymentBack)';
1814 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1816 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1817 $ispostactionok = -1;
1820 $postactionmessages[] =
'Bank transaction of payment created';
1821 $ispostactionok = 1;
1824 $postactionmessages[] =
'Setup of bank account to use in module '.$paymentmethod.
' was not set. Your payment was really executed but we failed to record it. Please contact us.';
1825 $ispostactionok = -1;
1832 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1833 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1835 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1836 if ($resultbooth < 0) {
1840 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1841 $resultboothupdate = $booth->update($user);
1842 if ($resultboothupdate < 0) {
1845 $resultinvoice = $invoice->fetch((
int) $ref);
1846 if ($resultinvoice < 0) {
1847 $postactionmessages[] =
'Could not find the associated invoice.';
1848 $ispostactionok = -1;
1852 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1853 if ($resultthirdparty < 0) {
1860 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1861 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1865 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1867 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1869 $arraydefaultmessage =
null;
1871 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1873 if (!empty($idoftemplatetouse)) {
1874 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1877 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1878 $subject = $arraydefaultmessage->topic;
1879 $msg = $arraydefaultmessage->content;
1881 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1882 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1885 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1891 $sendto = $thirdparty->email;
1893 $urlback = $_SERVER[
"REQUEST_URI"];
1896 $trackid =
'inv'.$invoice->id;
1898 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1900 $result = $mailfile->sendfile();
1902 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1904 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1919 $postactionmessages[] =
'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.
') or "payment type id" ('.$paymentTypeId.
') to record the payment of invoice '.$tmptag[
'ATT'].
'. May be payment was already recorded.';
1920 $ispostactionok = -1;
1923 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1924 $ispostactionok = -1;
1926 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1927 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1929 $result =
$object->fetch((
int) $tmptag[
'CON']);
1931 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1934 if ($paymentmethod ==
'paybox') {
1937 if ($paymentmethod ==
'paypal') {
1940 if ($paymentmethod ==
'stripe') {
1943 if (empty($paymentTypeId)) {
1944 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1946 if (empty($paymentType)) {
1947 $paymentType =
'CB';
1954 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1959 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1960 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1964 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1967 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1969 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1972 $invoice->validate($user);
1974 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1976 $paiement->datepaye = $now;
1977 if ($currencyCodeType ==
$conf->currency) {
1978 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1980 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1982 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1983 $ispostactionok = -1;
1986 $paiement->paiementid = $paymentTypeId;
1987 $paiement->num_payment =
'';
1988 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1991 if ($LONGTRANSACTIONID) {
1992 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1994 $paiement->ext_payment_id = $TRANSACTIONID;
1996 $paiement->ext_payment_site = $service;
1999 $paiement_id = $paiement->create($user, 1);
2000 if ($paiement_id < 0) {
2001 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2002 $ispostactionok = -1;
2005 $postactionmessages[] =
'Payment created';
2006 $ispostactionok = 1;
2012 if ($paymentmethod ==
'paybox') {
2014 } elseif ($paymentmethod ==
'paypal') {
2016 } elseif ($paymentmethod ==
'stripe') {
2022 'paymentmethod' => $paymentmethod,
2024 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2025 if ($reshook >= 0) {
2026 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2027 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2028 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2031 if ($bankaccountid > 0) {
2032 $label =
'(CustomerInvoicePayment)';
2034 $label =
'(CustomerInvoicePaymentBack)';
2036 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2038 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2039 $ispostactionok = -1;
2042 $postactionmessages[] =
'Bank transaction of payment created';
2043 $ispostactionok = 1;
2046 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2047 $ispostactionok = -1;
2052 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2053 if (!empty($tmptag[
'COL'])) {
2054 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2056 $postactionmessages[] = $msg;
2057 $ispostactionok = -1;
2067 $postactionmessages[] =
'Failed to get a valid value for "amount paid" (' . $FinalPaymentAmt .
') or "payment type id" (' . $paymentTypeId .
') to record the payment of contract ' . $tmptag[
'CON'] .
'. Maybe payment was already recorded.';
2068 $ispostactionok = -1;
2071 $postactionmessages[] =
'Invoice module is not enable';
2072 $ispostactionok = -1;
2075 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2076 if (!empty($tmptag[
'COL'])) {
2077 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2079 $postactionmessages[] = $msg;
2080 $ispostactionok = -1;
2087dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2091 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2092 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2094 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2095 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2096 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2098 if (is_object($object) && method_exists($object,
'call_trigger')) {
2099 '@phan-var-force CommonObject $object';
2101 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2106 } elseif (get_class($object) ==
'stdClass') {
2108 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2110 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2119if (empty($doactionsthenredirect)) {
2121 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2122 if ($TRANSACTIONID) {
2123 print $langs->trans(
"ThisIsTransactionId").
" : ".$TRANSACTIONID.
"<br><br>\n";
2127 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2131 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2137 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2138 if ($ErrorLongMsg) {
2139 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2141 if ($ErrorShortMsg) {
2142 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2145 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2147 if ($ErrorSeverityCode) {
2148 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2152 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2164 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2170 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2177 $companylangs->setDefaultLang($myCompanyDefaultLang);
2178 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2180 $sendto = $sendemail;
2183 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2184 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2189 $urlback = $_SERVER[
"REQUEST_URI"];
2190 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2192 if (array_key_exists(
'MEM', $tmptag)) {
2193 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2194 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2195 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2196 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2197 } elseif (array_key_exists(
'INV', $tmptag)) {
2198 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2199 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2200 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2202 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2204 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2206 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2207 if ($ispostactionok > 0) {
2209 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2210 } elseif ($ispostactionok == 0) {
2211 $content .= $companylangs->transnoentitiesnoconv(
"None");
2213 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2214 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2216 $content .=
'<br>'.
"\n";
2217 foreach ($postactionmessages as $postactionmessage) {
2218 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2220 if ($ispostactionok < 0) {
2221 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2223 $content .=
'<br>'.
"\n";
2225 $content .=
"<br>\n";
2226 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2227 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2228 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2229 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2230 $content .=
"<br>\n";
2231 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2233 if (!empty($ErrorCode)) {
2234 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2236 if (!empty($ErrorShortMsg)) {
2237 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2239 if (!empty($ErrorLongMsg)) {
2240 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2242 if (!empty($ErrorSeverityCode)) {
2243 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2246 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2251 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2252 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2254 $result = $mailfile->sendfile();
2256 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2259 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2267 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2268 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2270 $paymentType = $_SESSION[
'PaymentType'];
2271 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2272 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2274 if (is_object($object) && method_exists($object,
'call_trigger')) {
2276 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2286 $companylangs->setDefaultLang(
$mysoc->default_lang);
2287 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2289 $sendto = $sendemail;
2292 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2293 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2296 $urlback = $_SERVER[
"REQUEST_URI"];
2297 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2299 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2301 $content .=
"<br><br>\n";
2302 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2303 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2304 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2305 $content .=
"<br>\n";
2306 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2312 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2313 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2315 $result = $mailfile->sendfile();
2317 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2319 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2326unset($_SESSION[
"FinalPaymentAmt"]);
2327unset($_SESSION[
"TRANSACTIONID"]);
2331if (empty($doactionsthenredirect)) {
2334 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2339if (empty($doactionsthenredirect)) {
2350if (!empty($doactionsthenredirect)) {
2354 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2357 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2358 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2360 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2363 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2364 header(
"Location: ".$ext_urlok);
2369 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2372 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2373 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2375 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2378 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2379 header(
"Location: ".$ext_urlko);
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage donations.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
Class to manage translations.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_now($mode='gmt')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) formatLogObject($data)
Return a string serialized to be output on log with dol_syslog() An option allow to output log in one...
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.