34if (!defined(
'NOLOGIN')) {
37if (!defined(
'NOCSRFCHECK')) {
38 define(
"NOCSRFCHECK", 1);
40if (!defined(
'NOIPCHECK')) {
41 define(
'NOIPCHECK',
'1');
43if (!defined(
'NOBROWSERNOTIF')) {
44 define(
'NOBROWSERNOTIF',
'1');
47if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
48 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
54$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
55if (is_numeric($entity)) {
56 define(
"DOLENTITY", $entity);
60require
'../../main.inc.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
64if (isModEnabled(
'paypal')) {
65 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
66 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
83$hookmanager->initHooks(array(
'newpayment'));
85$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
89$PAYPAL_API_PASSWORD =
"";
90$PAYPAL_API_SIGNATURE =
"";
91$PAYPAL_API_SANDBOX =
"";
94if (isModEnabled(
'paypal')) {
100 $PAYPALTOKEN =
GETPOST(
'TOKEN');
101 if (empty($PAYPALTOKEN)) {
102 $PAYPALTOKEN =
GETPOST(
'token');
104 $PAYPALPAYERID =
GETPOST(
'PAYERID');
105 if (empty($PAYPALPAYERID)) {
106 $PAYPALPAYERID =
GETPOST(
'PayerID');
111if (empty($FULLTAG)) {
117$suffix =
GETPOST(
"suffix",
'aZ09');
124if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
125 $paymentmethod = $reg[1];
127if (empty($paymentmethod)) {
128 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
129 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
133dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
137$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
139 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');
142$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
145if (empty($validpaymentmethod)) {
150$creditor = $mysoc->name;
151$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
152$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
162$PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
164$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
172$ws_virtuelhost =
null;
174$doactionsthenredirect = 0;
176 $doactionsthenredirect = 1;
177 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
179 $result = $website->fetch(0, $ws);
181 $ws_virtuelhost = $website->virtualhost;
182 $ws_id = $website->id;
199dol_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');
200dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
201dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
204foreach ($_POST as $k => $v) {
205 if (is_scalar($k) && is_scalar($v)) {
206 $tracepost .=
"$k=$v\n";
209dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
212foreach ($_SESSION as $k => $v) {
213 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
214 $tracesession .=
"$k=$v\n";
217dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
219dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
223 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
226$conf->dol_hide_topmenu = 1;
227$conf->dol_hide_leftmenu = 1;
231if (empty($doactionsthenredirect)) {
232 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
233 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
237 print
'<span id="dolpaymentspan"></span>'.
"\n";
238 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
243 $logosmall = $mysoc->logo_small;
244 $logo = $mysoc->logo;
245 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
255 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
256 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
257 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
258 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
259 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
265 print
'<div class="backgreypublicpayment">';
266 print
'<div class="logopublicpayment">';
267 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
271 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>';
274 } elseif ($creditor) {
275 print
'<div class="backgreypublicpayment">';
276 print
'<div class="logopublicpayment">';
282 print
'<div class="backimagepublicpayment">';
283 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
288 print
'<br><br><br>';
293$service = $paymentmethod;
296if (isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
297 if (!empty($PAYPALTOKEN)) {
300 $onlinetoken = $PAYPALTOKEN;
302 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
304 $ipaddress = $_SESSION[
'ipaddress'];
305 $currencyCodeType = $_SESSION[
'currencyCodeType'];
306 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
307 $paymentType = $_SESSION[
'PaymentType'];
309 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
312 if (!empty($paymentType)) {
313 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
317 $ack = strtoupper($resArray[
"ACK"]);
318 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
320 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
322 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, 0,
'_payment');
325 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
326 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
329 $ack = strtoupper($resArray2[
"ACK"]);
330 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
331 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
337 $object->resArray = $resArray2;
341 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
342 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
343 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
344 $NOTE = urldecode($resArray2[
"NOTE"]);
348 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
351 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
352 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
353 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
354 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
357 $ErrorCode =
"SESSIONEXPIRED";
358 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
359 $ErrorShortMsg =
"Session expired";
361 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
365 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
366 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
367 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
369 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
375if (isModEnabled(
'paybox') && $paymentmethod ===
'paybox') {
381if (isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
383 if (empty($TRANSACTIONID)) {
384 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
385 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
387 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
390 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
391 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
393 $service =
'StripeTest';
396 $service =
'StripeLive';
401 if (
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
403 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
408 if (!$error && $TRANSACTIONID) {
411 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
412 $stripe =
new Stripe($db);
413 $stripeacc = $stripe->getStripeAccount($service);
416 global $stripearrayofkeysbyenv;
417 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
420 if (empty($stripeacc)) {
421 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
423 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
427 $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;
442 $errormessage =
"Stripe API error: ".$e->getMessage();
443 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
447 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
448 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
453 $errmsg =
'Stripe API error: ' . $e->getMessage();
458 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
466 $ispaymentok =
false;
471if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
475 'paymentmethod' => $paymentmethod,
477 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
479 if (isset($hookmanager->resArray[
'ispaymentok'])) {
480 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
481 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
488if (empty($ipaddress)) {
489 $ipaddress = $_SESSION[
'ipaddress'];
491if (empty($FinalPaymentAmt)) {
492 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
494if (empty($currencyCodeType)) {
495 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
497if (empty($paymentType)) {
498 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
501if (empty($TRANSACTIONID)) {
502 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
503 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
505 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
513dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
517$appli = $mysoc->name;
523$postactionmessages = array();
526 if (empty($user->rights->societe)) {
527 $user->rights->societe =
new stdClass();
529 if (empty($user->rights->facture)) {
530 $user->rights->facture =
new stdClass();
531 $user->rights->facture->invoice_advance =
new stdClass();
533 if (empty($user->rights->adherent)) {
534 $user->rights->adherent =
new stdClass();
535 $user->rights->adherent->cotisation =
new stdClass();
537 $user->rights->societe->creer = 1;
538 $user->rights->facture->creer = 1;
539 $user->rights->facture->invoice_advance->validate = 1;
540 $user->rights->adherent->cotisation->creer = 1;
542 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
549 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
550 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
551 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
555 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
556 $result2 = $adht->fetch(
$object->typeid);
558 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
559 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
561 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
563 if ($result1 > 0 && $result2 > 0) {
564 if ($paymentmethod ==
'paybox') {
567 if ($paymentmethod ==
'paypal') {
570 if ($paymentmethod ==
'stripe') {
573 if (empty($paymentTypeId)) {
574 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
576 if (empty($paymentType)) {
581 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
584 if (empty($paymentTypeId) || $paymentTypeId < 0) {
589 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
592 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
594 if (empty($adht->caneditamount)) {
595 if (
$object->status == $object::STATUS_DRAFT) {
597 $amountbytype = $adht->amountByType(1);
601 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
611 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
613 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
615 $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 ?';
616 $postactionmessages[] = $errmsg;
617 $ispostactionok = -1;
618 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
627 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' .
getDolGlobalString(
'MEMBER_MIN_AMOUNT').
'). May be a hack to try to pay a different amount ?';
628 $postactionmessages[] = $errmsg;
629 $ispostactionok = -1;
630 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
635 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
637 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
638 $postactionmessages[] = $errmsg;
639 $ispostactionok = -1;
640 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
645 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
646 if ($result < 0 || empty(
$object->datevalid)) {
649 $postactionmessages[] = $errmsg;
650 $postactionmessages = array_merge($postactionmessages,
$object->errors);
651 $ispostactionok = -1;
652 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
657 $datesubscription =
$object->datevalid;
674 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
677 while ($datesubend < $now) {
679 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
686 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string) $mysoc->default_lang : (string)
$object->thirdparty->default_lang);
688 $amount = $FinalPaymentAmt;
689 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
690 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
694 if ($paymentmethod ==
'paybox') {
697 if ($paymentmethod ==
'paypal') {
700 if ($paymentmethod ==
'stripe') {
706 'paymentmethod' => $paymentmethod,
708 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
710 if (isset($hookmanager->resArray[
'bankaccountid'])) {
711 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
712 $accountid = $hookmanager->resArray[
'bankaccountid'];
715 if ($accountid < 0) {
717 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
718 $postactionmessages[] = $errmsg;
719 $ispostactionok = -1;
720 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
723 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
726 $emetteur_banque =
'';
729 if (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankviainvoice' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
730 $option =
'bankviainvoice';
731 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankdirect' && isModEnabled(
"bank")) {
732 $option =
'bankdirect';
733 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'invoiceonly' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
734 $option =
'invoiceonly';
736 if (empty($option)) {
747 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
749 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
753 $postactionmessages[] = $errmsg;
754 $ispostactionok = -1;
756 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
761 $autocreatethirdparty = 0;
764 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
766 $autocreatethirdparty = 1;
768 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
773 $postactionmessages[] =
$object->error;
774 $postactionmessages = array_merge($postactionmessages,
$object->errors);
775 $ispostactionok = -1;
777 if ($option ==
'bankviainvoice') {
778 $postactionmessages[] =
'Invoice, payment and bank record created';
779 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
781 if ($option ==
'bankdirect') {
782 $postactionmessages[] =
'Bank record created';
783 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
785 if ($option ==
'invoiceonly') {
786 $postactionmessages[] =
'Invoice recorded';
787 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
797 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
800 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
802 $service =
'StripeTest';
805 $service =
'StripeLive';
810 $thirdparty =
new Societe($db);
811 $thirdparty->fetch($thirdparty_id);
813 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
814 $stripe =
new Stripe($db);
817 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
819 if (!$customer && $TRANSACTIONID) {
820 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
823 global $stripearrayofkeysbyenv;
824 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
826 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
828 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
831 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
835 $stripecu = $chpi->customer;
837 if (empty($stripecu)) {
839 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
842 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
843 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
846 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
847 $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)";
848 $resql = $db->query($sql);
851 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
853 $postactionmessages[] = $errmsg;
854 $ispostactionok = -1;
859 $errmsg =
'Failed to retrieve paymentintent or charge from id';
861 $postactionmessages[] = $errmsg;
862 $ispostactionok = -1;
866 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
868 $postactionmessages[] = $errmsg;
869 $ispostactionok = -1;
886 $nuser =
new User($db);
891 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
892 $resqlcount = $db->query($sql);
894 $objcount = $db->fetch_object($resqlcount);
896 $found = $objcount->nb;
901 $result = $nuser->create_from_member($tmpuser,
$object->login);
902 $newpassword = $nuser->setPassword($user,
'');
905 $outputlangs->load(
"errors");
906 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
908 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
909 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
912 $outputlangs->load(
"errors");
913 $postactionmessages[] =
'No user created because a user linked to member already exists';
919 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
922 if (
$object->email && $sendalsoemail) {
927 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
930 $outputlangs->loadLangs(array(
"main",
"members"));
932 $arraydefaultmessage =
null;
935 if (!empty($labeltouse)) {
936 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
939 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
940 $subject = $arraydefaultmessage->topic;
941 $msg = $arraydefaultmessage->content;
944 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
946 if ($infouserlogin) {
947 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
956 $listofpaths = array();
957 $listofnames = array();
958 $listofmimes = array();
959 if (is_object(
$object->invoice)) {
960 $invoicediroutput =
$conf->facture->dir_output;
962 $file = $fileparams[
'fullname'];
964 $listofpaths = array($file);
965 $listofnames = array(basename($file));
969 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
971 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
975 $postactionmessages[] = $errmsg;
976 $ispostactionok = -1;
979 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
981 $postactionmessages[] =
'Email sent to member (without any attached document)';
989 $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.';
990 $ispostactionok = -1;
993 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
994 $ispostactionok = -1;
996 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
998 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1000 $result =
$object->fetch((
int) $tmptag[
'INV']);
1002 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1005 if ($paymentmethod ===
'paybox') {
1008 if ($paymentmethod ===
'paypal') {
1011 if ($paymentmethod ===
'stripe') {
1014 if (empty($paymentTypeId)) {
1015 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1017 if (empty($paymentType)) {
1018 $paymentType =
'CB';
1022 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1025 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1030 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1033 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1037 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1039 $paiement->datepaye = $now;
1040 if ($currencyCodeType ==
$conf->currency) {
1041 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1043 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1045 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1046 $ispostactionok = -1;
1049 $paiement->paiementid = $paymentTypeId;
1050 $paiement->num_payment =
'';
1051 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1052 $paiement->ext_payment_id = $TRANSACTIONID;
1054 $paiement->ext_payment_site = $service;
1057 $paiement_id = $paiement->create($user, 1);
1058 if ($paiement_id < 0) {
1059 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1060 $ispostactionok = -1;
1063 $postactionmessages[] =
'Payment created';
1064 $ispostactionok = 1;
1068 if (!$error && isModEnabled(
"bank")) {
1070 if ($paymentmethod ==
'paybox') {
1072 } elseif ($paymentmethod ==
'paypal') {
1074 } elseif ($paymentmethod ==
'stripe') {
1080 'paymentmethod' => $paymentmethod,
1082 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1083 if ($reshook >= 0) {
1084 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1085 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1086 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1089 if ($bankaccountid > 0) {
1090 $label =
'(CustomerInvoicePayment)';
1092 $label =
'(CustomerInvoicePaymentBack)';
1094 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1096 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1097 $ispostactionok = -1;
1100 $postactionmessages[] =
'Bank transaction of payment created';
1101 $ispostactionok = 1;
1104 $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.';
1105 $ispostactionok = -1;
1116 $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.';
1117 $ispostactionok = -1;
1120 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1121 $ispostactionok = -1;
1123 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1124 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1126 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1128 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1130 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1133 if ($paymentmethod ==
'paybox') {
1136 if ($paymentmethod ==
'paypal') {
1139 if ($paymentmethod ==
'stripe') {
1142 if (empty($paymentTypeId)) {
1143 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1145 if (empty($paymentType)) {
1146 $paymentType =
'CB';
1150 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1153 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1158 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1161 if (isModEnabled(
'invoice')) {
1162 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1165 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1167 $result = $invoice->createFromOrder($object, $user);
1169 if ($FinalPaymentAmt !=
$object->total_ttc) {
1177 $object->classifyBilled($user);
1179 $invoice->validate($user);
1182 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1184 $paiement->datepaye = $now;
1185 if ($currencyCodeType ==
$conf->currency) {
1186 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1188 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1190 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1191 $ispostactionok = -1;
1194 $paiement->paiementid = $paymentTypeId;
1195 $paiement->num_payment =
'';
1196 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1197 $paiement->ext_payment_id = $TRANSACTIONID;
1198 $paiement->ext_payment_site = $service;
1201 $paiement_id = $paiement->create($user, 1);
1202 if ($paiement_id < 0) {
1203 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1204 $ispostactionok = -1;
1207 $postactionmessages[] =
'Payment created';
1208 $ispostactionok = 1;
1212 if (!$error && isModEnabled(
"bank")) {
1214 if ($paymentmethod ==
'paybox') {
1216 } elseif ($paymentmethod ==
'paypal') {
1218 } elseif ($paymentmethod ==
'stripe') {
1224 'paymentmethod' => $paymentmethod,
1226 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1227 if ($reshook >= 0) {
1228 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1229 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1230 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1233 if ($bankaccountid > 0) {
1234 $label =
'(CustomerInvoicePayment)';
1236 $label =
'(CustomerInvoicePaymentBack)';
1238 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1240 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1241 $ispostactionok = -1;
1244 $postactionmessages[] =
'Bank transaction of payment created';
1245 $ispostactionok = 1;
1248 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1249 $ispostactionok = -1;
1254 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1255 $ispostactionok = -1;
1265 $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.';
1266 $ispostactionok = -1;
1269 $postactionmessages[] =
'Invoice module is not enable';
1270 $ispostactionok = -1;
1273 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1274 $ispostactionok = -1;
1276 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1277 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1278 $don =
new Don($db);
1279 $result = $don->fetch((
int) $tmptag[
'DON']);
1282 if ($paymentmethod ==
'paybox') {
1285 if ($paymentmethod ==
'paypal') {
1286 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1288 if ($paymentmethod ==
'stripe') {
1291 if (empty($paymentTypeId)) {
1292 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1294 if (empty($paymentType)) {
1295 $paymentType =
'CB';
1299 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1302 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1308 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1312 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1315 $totalpaid = $FinalPaymentAmt;
1317 if ($currencyCodeType ==
$conf->currency) {
1318 $paiement->amounts = array(
$object->id => $totalpaid);
1321 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1322 $ispostactionok = -1;
1326 $paiement->fk_donation = $don->id;
1327 $paiement->datep = $now;
1328 $paiement->paymenttype = $paymentTypeId;
1329 $paiement->num_payment =
'';
1330 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1331 $paiement->ext_payment_id = $TRANSACTIONID;
1332 $paiement->ext_payment_site = $service;
1335 $paiement_id = $paiement->create($user, 1);
1336 if ($paiement_id < 0) {
1337 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1338 $ispostactionok = -1;
1341 $postactionmessages[] =
'Payment created';
1342 $ispostactionok = 1;
1344 if ($totalpaid >= $don->getRemainToPay()) {
1345 $don->valid_promesse($don->id, $user->id);
1346 $don->setPaid($don->id);
1351 if (!$error && isModEnabled(
"bank")) {
1353 if ($paymentmethod ==
'paybox') {
1355 } elseif ($paymentmethod ==
'paypal') {
1357 } elseif ($paymentmethod ==
'stripe') {
1363 'paymentmethod' => $paymentmethod,
1365 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1366 if ($reshook >= 0) {
1367 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1368 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1369 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1372 if ($bankaccountid > 0) {
1373 $label =
'(DonationPayment)';
1374 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1376 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1377 $ispostactionok = -1;
1380 $postactionmessages[] =
'Bank transaction of payment created';
1381 $ispostactionok = 1;
1384 $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.';
1385 $ispostactionok = -1;
1396 $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.';
1397 $ispostactionok = -1;
1400 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1401 $ispostactionok = -1;
1406 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1408 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1409 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1410 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1412 $result =
$object->fetch((
int) $ref);
1415 if ($paymentmethod ==
'paybox') {
1418 if ($paymentmethod ==
'paypal') {
1421 if ($paymentmethod ==
'stripe') {
1424 if (empty($paymentTypeId)) {
1425 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1427 if (empty($paymentType)) {
1428 $paymentType =
'CB';
1432 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1435 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1441 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1442 $resultvalidate =
$object->validate($user);
1443 if ($resultvalidate < 0) {
1444 $postactionmessages[] =
'Cannot validate invoice';
1445 $ispostactionok = -1;
1451 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1453 $paiement->datepaye = $now;
1454 if ($currencyCodeType ==
$conf->currency) {
1455 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1457 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1459 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1460 $ispostactionok = -1;
1463 $paiement->paiementid = $paymentTypeId;
1464 $paiement->num_payment =
'';
1465 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1466 $paiement->ext_payment_id = $TRANSACTIONID;
1467 $paiement->ext_payment_site = $service;
1470 $paiement_id = $paiement->create($user, 1);
1471 if ($paiement_id < 0) {
1472 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1473 $ispostactionok = -1;
1476 $postactionmessages[] =
'Payment created';
1477 $ispostactionok = 1;
1481 if (!$error && isModEnabled(
"bank")) {
1483 if ($paymentmethod ==
'paybox') {
1485 } elseif ($paymentmethod ==
'paypal') {
1487 } elseif ($paymentmethod ==
'stripe') {
1493 'paymentmethod' => $paymentmethod,
1495 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1496 if ($reshook >= 0) {
1497 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1498 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1499 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1502 if ($bankaccountid > 0) {
1503 $label =
'(CustomerInvoicePayment)';
1505 $label =
'(CustomerInvoicePaymentBack)';
1507 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1509 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1510 $ispostactionok = -1;
1513 $postactionmessages[] =
'Bank transaction of payment created';
1514 $ispostactionok = 1;
1517 $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.';
1518 $ispostactionok = -1;
1527 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1528 if ($resultattendee < 0) {
1532 $attendeetovalidate->validate($user);
1534 $attendeetovalidate->amount = $FinalPaymentAmt;
1535 $attendeetovalidate->date_subscription =
dol_now();
1536 $attendeetovalidate->update($user);
1550 $thirdparty =
new Societe($db);
1551 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1552 if ($resultthirdparty < 0) {
1555 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1556 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1560 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string) $mysoc->default_lang : (string) $thirdparty->default_lang);
1562 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1564 $arraydefaultmessage =
null;
1566 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1568 if (!empty($idoftemplatetouse)) {
1569 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1572 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1573 $subject = $arraydefaultmessage->topic;
1574 $msg = $arraydefaultmessage->content;
1576 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1577 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1580 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1586 $sendto = $attendeetovalidate->email;
1588 if ($thirdparty->email) {
1589 $cc = $thirdparty->email ??
'';
1591 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1592 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1597 $urlback = $_SERVER[
"REQUEST_URI"];
1603 $listofpaths = array();
1604 $listofnames = array();
1605 $listofmimes = array();
1606 if (is_object($object)) {
1607 $invoicediroutput =
$conf->facture->dir_output;
1609 $file = $fileparams[
'fullname'];
1611 $listofpaths = array($file);
1612 $listofnames = array(basename($file));
1616 $trackid =
'inv'.$object->id;
1618 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1620 $result = $mailfile->sendfile();
1622 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1624 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1630 $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.';
1631 $ispostactionok = -1;
1634 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1635 $ispostactionok = -1;
1637 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1639 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1640 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1641 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1643 $result =
$object->fetch((
int) $ref);
1645 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1648 if ($paymentmethod ==
'paybox') {
1651 if ($paymentmethod ==
'paypal') {
1654 if ($paymentmethod ==
'stripe') {
1657 if (empty($paymentTypeId)) {
1658 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1660 if (empty($paymentType)) {
1661 $paymentType =
'CB';
1665 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1668 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1674 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1675 $resultvalidate =
$object->validate($user);
1676 if ($resultvalidate < 0) {
1677 $postactionmessages[] =
'Cannot validate invoice';
1678 $ispostactionok = -1;
1684 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1686 $paiement->datepaye = $now;
1687 if ($currencyCodeType ==
$conf->currency) {
1688 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1690 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1692 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1693 $ispostactionok = -1;
1696 $paiement->paiementid = $paymentTypeId;
1697 $paiement->num_payment =
'';
1698 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1699 $paiement->ext_payment_id = $TRANSACTIONID;
1700 $paiement->ext_payment_site = $service;
1703 $paiement_id = $paiement->create($user, 1);
1704 if ($paiement_id < 0) {
1705 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1706 $ispostactionok = -1;
1709 $postactionmessages[] =
'Payment created';
1710 $ispostactionok = 1;
1714 if (!$error && isModEnabled(
"bank")) {
1716 if ($paymentmethod ==
'paybox') {
1718 } elseif ($paymentmethod ==
'paypal') {
1720 } elseif ($paymentmethod ==
'stripe') {
1726 'paymentmethod' => $paymentmethod,
1728 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1729 if ($reshook >= 0) {
1730 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1731 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1732 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1735 if ($bankaccountid > 0) {
1736 $label =
'(CustomerInvoicePayment)';
1738 $label =
'(CustomerInvoicePaymentBack)';
1740 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1742 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1743 $ispostactionok = -1;
1746 $postactionmessages[] =
'Bank transaction of payment created';
1747 $ispostactionok = 1;
1750 $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.';
1751 $ispostactionok = -1;
1758 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1759 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1761 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1762 if ($resultbooth < 0) {
1766 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1767 $resultboothupdate = $booth->update($user);
1768 if ($resultboothupdate < 0) {
1771 $resultinvoice = $invoice->fetch((
int) $ref);
1772 if ($resultinvoice < 0) {
1773 $postactionmessages[] =
'Could not find the associated invoice.';
1774 $ispostactionok = -1;
1777 $thirdparty =
new Societe($db);
1778 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1779 if ($resultthirdparty < 0) {
1786 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1787 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1791 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1793 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1795 $arraydefaultmessage =
null;
1797 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1799 if (!empty($idoftemplatetouse)) {
1800 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1803 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1804 $subject = $arraydefaultmessage->topic;
1805 $msg = $arraydefaultmessage->content;
1807 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1808 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1811 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1817 $sendto = $thirdparty->email;
1819 $urlback = $_SERVER[
"REQUEST_URI"];
1822 $trackid =
'inv'.$invoice->id;
1824 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1826 $result = $mailfile->sendfile();
1828 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1830 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1845 $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.';
1846 $ispostactionok = -1;
1849 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1850 $ispostactionok = -1;
1852 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1853 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1855 $result =
$object->fetch((
int) $tmptag[
'CON']);
1857 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1860 if ($paymentmethod ==
'paybox') {
1863 if ($paymentmethod ==
'paypal') {
1866 if ($paymentmethod ==
'stripe') {
1869 if (empty($paymentTypeId)) {
1870 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1872 if (empty($paymentType)) {
1873 $paymentType =
'CB';
1877 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1880 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1885 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1886 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1889 if (isModEnabled(
'invoice')) {
1890 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1893 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1895 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1898 $invoice->validate($user);
1900 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1902 $paiement->datepaye = $now;
1903 if ($currencyCodeType ==
$conf->currency) {
1904 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1906 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1908 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1909 $ispostactionok = -1;
1912 $paiement->paiementid = $paymentTypeId;
1913 $paiement->num_payment =
'';
1914 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1915 $paiement->ext_payment_id = $TRANSACTIONID;
1916 $paiement->ext_payment_site = $service;
1919 $paiement_id = $paiement->create($user, 1);
1920 if ($paiement_id < 0) {
1921 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1922 $ispostactionok = -1;
1925 $postactionmessages[] =
'Payment created';
1926 $ispostactionok = 1;
1930 if (!$error && isModEnabled(
"bank")) {
1932 if ($paymentmethod ==
'paybox') {
1934 } elseif ($paymentmethod ==
'paypal') {
1936 } elseif ($paymentmethod ==
'stripe') {
1942 'paymentmethod' => $paymentmethod,
1944 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1945 if ($reshook >= 0) {
1946 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1947 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1948 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1951 if ($bankaccountid > 0) {
1952 $label =
'(CustomerInvoicePayment)';
1954 $label =
'(CustomerInvoicePaymentBack)';
1956 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1958 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1959 $ispostactionok = -1;
1962 $postactionmessages[] =
'Bank transaction of payment created';
1963 $ispostactionok = 1;
1966 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1967 $ispostactionok = -1;
1972 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1973 if (!empty($tmptag[
'COL'])) {
1974 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
1976 $postactionmessages[] = $msg;
1977 $ispostactionok = -1;
1987 $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.';
1988 $ispostactionok = -1;
1991 $postactionmessages[] =
'Invoice module is not enable';
1992 $ispostactionok = -1;
1995 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
1996 if (!empty($tmptag[
'COL'])) {
1997 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
1999 $postactionmessages[] = $msg;
2000 $ispostactionok = -1;
2007dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2011 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2012 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2014 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2015 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2016 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2018 if (is_object($object) && method_exists($object,
'call_trigger')) {
2019 '@phan-var-force CommonObject $object';
2021 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2026 } elseif (get_class($object) ==
'stdClass') {
2028 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2030 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2039if (empty($doactionsthenredirect)) {
2041 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2042 if ($TRANSACTIONID) {
2043 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
2047 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2051 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2057 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2058 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2059 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2060 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2061 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2063 if ($mysoc->email) {
2064 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2076 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2081 $myCompanyDefaultLang = (string) $mysoc->default_lang;
2082 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2089 $companylangs->setDefaultLang($myCompanyDefaultLang);
2090 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2092 $sendto = $sendemail;
2095 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2096 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2101 $urlback = $_SERVER[
"REQUEST_URI"];
2102 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2104 if (array_key_exists(
'MEM', $tmptag)) {
2105 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2106 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2107 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2108 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2109 } elseif (array_key_exists(
'INV', $tmptag)) {
2110 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2111 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2112 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2114 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2116 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2118 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2119 if ($ispostactionok > 0) {
2121 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2122 } elseif ($ispostactionok == 0) {
2123 $content .= $companylangs->transnoentitiesnoconv(
"None");
2125 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2126 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2128 $content .=
'<br>'.
"\n";
2129 foreach ($postactionmessages as $postactionmessage) {
2130 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2132 if ($ispostactionok < 0) {
2133 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2135 $content .=
'<br>'.
"\n";
2137 $content .=
"<br>\n";
2138 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2139 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2140 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2141 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2142 $content .=
"<br>\n";
2143 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2145 if (!empty($ErrorCode)) {
2146 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2148 if (!empty($ErrorShortMsg)) {
2149 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2151 if (!empty($ErrorLongMsg)) {
2152 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2154 if (!empty($ErrorSeverityCode)) {
2155 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2158 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2163 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2164 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2166 $result = $mailfile->sendfile();
2168 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2171 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2179 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2180 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2182 $paymentType = $_SESSION[
'PaymentType'];
2183 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2184 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2186 if (is_object($object) && method_exists($object,
'call_trigger')) {
2188 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2198 $companylangs->setDefaultLang($mysoc->default_lang);
2199 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2201 $sendto = $sendemail;
2204 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2205 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2208 $urlback = $_SERVER[
"REQUEST_URI"];
2209 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2211 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2213 $content .=
"<br><br>\n";
2214 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2215 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2216 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2217 $content .=
"<br>\n";
2218 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2224 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2225 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2227 $result = $mailfile->sendfile();
2229 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2231 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2238unset($_SESSION[
"FinalPaymentAmt"]);
2239unset($_SESSION[
"TRANSACTIONID"]);
2243if (empty($doactionsthenredirect)) {
2246 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2251if (empty($doactionsthenredirect)) {
2262if (!empty($doactionsthenredirect)) {
2266 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2269 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2270 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2272 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2275 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2276 header(
"Location: ".$ext_urlok);
2281 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2284 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2285 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2287 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2290 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2291 header(
"Location: ".$ext_urlko);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 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_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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.