32if (!defined(
'NOLOGIN')) {
35if (!defined(
'NOCSRFCHECK')) {
36 define(
"NOCSRFCHECK", 1);
38if (!defined(
'NOIPCHECK')) {
39 define(
'NOIPCHECK',
'1');
41if (!defined(
'NOBROWSERNOTIF')) {
42 define(
'NOBROWSERNOTIF',
'1');
48$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
49if (is_numeric($entity)) {
50 define(
"DOLENTITY", $entity);
54require
'../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
57if (isModEnabled(
'paypal')) {
58 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
59 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
65$hookmanager->initHooks(array(
'newpayment'));
67$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal"));
70if (isModEnabled(
'paypal')) {
71 $PAYPAL_API_USER =
"";
73 $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
75 $PAYPAL_API_PASSWORD =
"";
77 $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
79 $PAYPAL_API_SIGNATURE =
"";
81 $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
83 $PAYPAL_API_SANDBOX =
"";
85 $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
96 $PAYPALTOKEN =
GETPOST(
'TOKEN');
97 if (empty($PAYPALTOKEN)) {
98 $PAYPALTOKEN =
GETPOST(
'token');
100 $PAYPALPAYERID =
GETPOST(
'PAYERID');
101 if (empty($PAYPALPAYERID)) {
102 $PAYPALPAYERID =
GETPOST(
'PayerID');
107if (empty($FULLTAG)) {
113$suffix =
GETPOST(
"suffix",
'aZ09');
114$membertypeid =
GETPOST(
"membertypeid",
'int');
120if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
121 $paymentmethod = $reg[1];
123if (empty($paymentmethod)) {
124 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
125 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
129dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
132$validpaymentmethod = array();
133if (isModEnabled(
'paypal')) {
134 $validpaymentmethod[
'paypal'] =
'paypal';
136if (isModEnabled(
'paybox')) {
137 $validpaymentmethod[
'paybox'] =
'paybox';
139if (isModEnabled(
'stripe')) {
140 $validpaymentmethod[
'stripe'] =
'stripe';
144if (empty($validpaymentmethod)) {
151$PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
153$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
173dol_syslog(
"Callback url when a payment was done. 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');
174dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
175dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
178foreach ($_POST as $k => $v) {
179 if (is_scalar($k) && is_scalar($v)) {
180 $tracepost .=
"$k - $v\n";
183dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
185foreach ($_SESSION as $k => $v) {
186 if (is_scalar($k) && is_scalar($v)) {
187 $tracesession .=
"$k - $v\n";
190dol_syslog(
"SESSION=".$tracesession, LOG_DEBUG, 0,
'_payment');
194 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
197$conf->dol_hide_topmenu = 1;
198$conf->dol_hide_leftmenu = 1;
200$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
201llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
205print
'<span id="dolpaymentspan"></span>'.
"\n";
206print
'<div id="dolpaymentdiv" class="center">'.
"\n";
211$logosmall = $mysoc->logo_small;
213$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
214if (!empty($conf->global->$paramlogo)) {
215 $logosmall = $conf->global->$paramlogo;
217 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
223if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
224 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
225 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
226} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
227 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
228 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
233 print
'<div class="backgreypublicpayment">';
234 print
'<div class="logopublicpayment">';
235 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
239 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>';
244 print
'<div class="backimagepublicpayment">';
245 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
253if (isModEnabled(
'paypal')) {
254 if ($paymentmethod ===
'paypal') {
257 $onlinetoken = $PAYPALTOKEN;
259 $payerID = $PAYPALPAYERID;
261 $currencyCodeType = $_SESSION[
'currencyCodeType'];
262 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
263 $paymentType = $_SESSION[
'PaymentType'];
265 $ipaddress = $_SESSION[
'ipaddress'];
267 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
270 if (!empty($paymentType)) {
271 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
275 $ack = strtoupper($resArray[
"ACK"]);
276 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
278 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
280 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING,
'_payment');
283 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
284 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
287 $ack = strtoupper($resArray2[
"ACK"]);
288 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
289 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
291 $object->source = $source;
293 $object->payerID = $payerID;
294 $object->fulltag = $fulltag;
295 $object->resArray = $resArray2;
299 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
300 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
301 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
302 $NOTE = urldecode($resArray2[
"NOTE"]);
306 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
309 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
310 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
311 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
312 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
315 $ErrorCode =
"SESSIONEXPIRED";
316 $ErrorLongMsg =
"Session expired. Can't retreive PaymentType. Payment has not been validated.";
317 $ErrorShortMsg =
"Session expired";
319 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
323 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
324 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
325 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
327 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
333if (isModEnabled(
'paybox')) {
334 if ($paymentmethod ===
'paybox') {
340if (isModEnabled(
'stripe')) {
341 if ($paymentmethod ===
'stripe') {
350 'paymentmethod' => $paymentmethod,
352$reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
354 if (isset($hookmanager->resArray[
'ispaymentok'])) {
355 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
356 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
362if (empty($ipaddress)) {
363 $ipaddress = $_SESSION[
'ipaddress'];
365if (empty($TRANSACTIONID)) {
366 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' :$_SESSION[
'TRANSACTIONID'];
367 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
369 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
372if (empty($FinalPaymentAmt)) {
373 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
375if (empty($currencyCodeType)) {
376 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
379if (empty($paymentType)) {
380 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
387dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
391$appli = $mysoc->name;
396$postactionmessages = array();
399 if (empty($user->rights->societe)) {
400 $user->rights->societe =
new stdClass();
402 if (empty($user->rights->facture)) {
403 $user->rights->facture =
new stdClass();
404 $user->rights->facture->invoice_advance =
new stdClass();
406 if (empty($user->rights->adherent)) {
407 $user->rights->adherent =
new stdClass();
408 $user->rights->adherent->cotisation =
new stdClass();
410 $user->rights->societe->creer = 1;
411 $user->rights->facture->creer = 1;
412 $user->rights->facture->invoice_advance->validate = 1;
413 $user->rights->adherent->cotisation->creer = 1;
415 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
422 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
423 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
424 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
428 $result1 = $object->fetch((
int) $tmptag[
'MEM']);
429 $result2 = $adht->fetch($object->typeid);
431 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
432 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
434 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
436 if ($result1 > 0 && $result2 > 0) {
438 if ($paymentmethod ==
'paybox') {
441 if ($paymentmethod ==
'paypal') {
444 if ($paymentmethod ==
'stripe') {
447 if (empty($paymentTypeId)) {
448 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
450 if (empty($paymentType)) {
455 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
458 if (empty($paymentTypeId) || $paymentTypeId < 0) {
463 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
466 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
468 if (empty($adht->caneditamount)) {
469 if ($object->status == $object::STATUS_DRAFT) {
470 $typeid = $object->typeid;
474 $amountbytype = $adht->amountByType(1);
475 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
478 $amountexpected = $conf->global->MEMBER_NEWFORM_AMOUNT;
481 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
483 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') differs from value expected for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
484 $postactionmessages[] = $errmsg;
485 $ispostactionok = -1;
486 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
493 if ($FinalPaymentAmt < $conf->global->MEMBER_MIN_AMOUNT) {
495 $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 ?';
496 $postactionmessages[] = $errmsg;
497 $ispostactionok = -1;
498 dol_syslog(
"Failed to validate member (amount lower than minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
503 if ($currencyCodeType && $currencyCodeType != $conf->currency) {
505 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.$conf->currency.
'). May be a hack to try to pay a different amount ?';
506 $postactionmessages[] = $errmsg;
507 $ispostactionok = -1;
508 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
513 $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user);
514 if ($result < 0 || empty($object->datevalid)) {
516 $errmsg = $object->error;
517 $postactionmessages[] = $errmsg;
518 $postactionmessages = array_merge($postactionmessages, $object->errors);
519 $ispostactionok = -1;
520 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
525 $datesubscription = $object->datevalid;
526 if ($object->datefin > 0) {
539 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
542 while ($datesubend < $now) {
544 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
551 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
553 $amount = $FinalPaymentAmt;
554 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
555 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
559 if ($paymentmethod ==
'paybox') {
560 $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
562 if ($paymentmethod ==
'paypal') {
563 $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
565 if ($paymentmethod ==
'stripe') {
566 $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
568 if ($accountid < 0) {
570 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
571 $postactionmessages[] = $errmsg;
572 $ispostactionok = -1;
573 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
576 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
579 $emetteur_banque =
'';
582 if (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankviainvoice' && isModEnabled(
"banque") && isModEnabled(
"societe") && isModEnabled(
'facture')) {
583 $option =
'bankviainvoice';
584 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankdirect' && isModEnabled(
"banque")) {
585 $option =
'bankdirect';
586 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'invoiceonly' && isModEnabled(
"banque") && isModEnabled(
"societe") && isModEnabled(
'facture')) {
587 $option =
'invoiceonly';
589 if (empty($option)) {
599 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
601 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
604 $errmsg = $object->error;
605 $postactionmessages[] = $errmsg;
606 $ispostactionok = -1;
608 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
614 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
616 $autocreatethirdparty = 1;
618 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
620 dol_syslog(
"Error ".$object->error.
" ".join(
',', $object->errors), LOG_DEBUG, 0,
'_payment');
623 $postactionmessages[] = $object->error;
624 $postactionmessages = array_merge($postactionmessages, $object->errors);
625 $ispostactionok = -1;
627 if ($option ==
'bankviainvoice') {
628 $postactionmessages[] =
'Invoice, payment and bank record created';
629 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
631 if ($option ==
'bankdirect') {
632 $postactionmessages[] =
'Bank record created';
633 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
635 if ($option ==
'invoiceonly') {
636 $postactionmessages[] =
'Invoice recorded';
637 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
646 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
647 $thirdparty_id = $object->fk_soc;
649 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
651 $service =
'StripeTest';
654 $service =
'StripeLive';
659 $thirdparty =
new Societe($db);
660 $thirdparty->fetch($thirdparty_id);
662 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
663 $stripe =
new Stripe($db);
666 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
668 if (!$customer && $TRANSACTIONID) {
669 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
672 global $stripearrayofkeysbyenv;
673 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
675 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
677 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
680 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
684 $stripecu = $chpi->customer;
686 if (empty($stripecu)) {
688 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
691 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
692 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
695 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
696 $sql .=
" VALUES (".((int) $object->fk_soc).
", '', '".$db->escape($stripecu).
"', 'stripe', '".$db->escape($stripearrayofkeysbyenv[$servicestatus][
'publishable_key']).
"', ".((int) $servicestatus).
", ".((int) $conf->entity).
", '".$db->idate(
dol_now()).
"', 0)";
697 $resql = $db->query($sql);
700 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
702 $postactionmessages[] = $errmsg;
703 $ispostactionok = -1;
708 $errmsg =
'Failed to retreive paymentintent or charge from id';
710 $postactionmessages[] = $errmsg;
711 $ispostactionok = -1;
715 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
717 $postactionmessages[] = $errmsg;
718 $ispostactionok = -1;
732 dol_syslog(
"Send email to customer to ".$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
735 if ($object->email && $sendalsoemail) {
740 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
743 $outputlangs->loadLangs(array(
"main",
"members"));
745 $arraydefaultmessage =
null;
746 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
748 if (!empty($labeltouse)) {
749 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
752 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
753 $subject = $arraydefaultmessage->topic;
754 $msg = $arraydefaultmessage->content;
762 $nuser =
new User($db);
765 $result = $nuser->create_from_member($tmpuser, $object->login);
766 $newpassword = $nuser->setPassword($user,
'');
769 $outputlangs->load(
"errors");
770 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
772 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
773 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
775 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
784 $listofpaths = array();
785 $listofnames = array();
786 $listofmimes = array();
787 if (is_object($object->invoice)) {
788 $invoicediroutput = $conf->facture->dir_output;
789 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
790 $file = $fileparams[
'fullname'];
792 $listofpaths = array($file);
793 $listofnames = array(basename($file));
797 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
799 $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
802 $errmsg = $object->error;
803 $postactionmessages[] = $errmsg;
804 $ispostactionok = -1;
807 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
809 $postactionmessages[] =
'Email sent to member (without any attached document)';
817 $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.';
818 $ispostactionok = -1;
821 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
822 $ispostactionok = -1;
824 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
826 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
828 $result = $object->fetch((
int) $tmptag[
'INV']);
830 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
833 if ($paymentmethod ===
'paybox') {
836 if ($paymentmethod ===
'paypal') {
839 if ($paymentmethod ===
'stripe') {
842 if (empty($paymentTypeId)) {
843 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
845 if (empty($paymentType)) {
850 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
853 if (empty($paymentTypeId) || $paymentTypeId < 0) {
858 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
861 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
865 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
867 $paiement->datepaye = $now;
868 if ($currencyCodeType == $conf->currency) {
869 $paiement->amounts = array($object->id => $FinalPaymentAmt);
871 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
873 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
874 $ispostactionok = -1;
877 $paiement->paiementid = $paymentTypeId;
878 $paiement->num_payment =
'';
879 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
880 $paiement->ext_payment_id = $TRANSACTIONID;
882 $paiement->ext_payment_site = $service;
885 $paiement_id = $paiement->create($user, 1);
886 if ($paiement_id < 0) {
887 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
888 $ispostactionok = -1;
891 $postactionmessages[] =
'Payment created';
896 if (!$error && isModEnabled(
"banque")) {
898 if ($paymentmethod ==
'paybox') {
899 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
900 } elseif ($paymentmethod ==
'paypal') {
901 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
902 } elseif ($paymentmethod ==
'stripe') {
903 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
906 if ($bankaccountid > 0) {
907 $label =
'(CustomerInvoicePayment)';
909 $label =
'(CustomerInvoicePaymentBack)';
911 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
913 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
914 $ispostactionok = -1;
917 $postactionmessages[] =
'Bank transaction of payment created';
921 $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.';
922 $ispostactionok = -1;
933 $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.';
934 $ispostactionok = -1;
937 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
938 $ispostactionok = -1;
940 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
941 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
943 $result = $object->fetch((
int) $tmptag[
'ORD']);
945 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
948 if ($paymentmethod ==
'paybox') {
951 if ($paymentmethod ==
'paypal') {
954 if ($paymentmethod ==
'stripe') {
957 if (empty($paymentTypeId)) {
958 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
960 if (empty($paymentType)) {
965 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
968 if (empty($paymentTypeId) || $paymentTypeId < 0) {
974 if (isModEnabled(
'facture')) {
975 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
976 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
978 $result = $invoice->createFromOrder($object, $user);
980 $object->classifyBilled($user);
981 $invoice->validate($user);
983 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
985 $paiement->datepaye = $now;
986 if ($currencyCodeType == $conf->currency) {
987 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
989 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
991 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
992 $ispostactionok = -1;
995 $paiement->paiementid = $paymentTypeId;
996 $paiement->num_payment =
'';
997 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
998 $paiement->ext_payment_id = $TRANSACTIONID;
999 $paiement->ext_payment_site = $service;
1002 $paiement_id = $paiement->create($user, 1);
1003 if ($paiement_id < 0) {
1004 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1005 $ispostactionok = -1;
1008 $postactionmessages[] =
'Payment created';
1009 $ispostactionok = 1;
1013 if (!$error && isModEnabled(
"banque")) {
1015 if ($paymentmethod ==
'paybox') {
1016 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1017 } elseif ($paymentmethod ==
'paypal') {
1018 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1019 } elseif ($paymentmethod ==
'stripe') {
1020 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1023 if ($bankaccountid > 0) {
1024 $label =
'(CustomerInvoicePayment)';
1026 $label =
'(CustomerInvoicePaymentBack)';
1028 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1030 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1031 $ispostactionok = -1;
1034 $postactionmessages[] =
'Bank transaction of payment created';
1035 $ispostactionok = 1;
1038 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1039 $ispostactionok = -1;
1050 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1051 $ispostactionok = -1;
1054 $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.';
1055 $ispostactionok = -1;
1058 $postactionmessages[] =
'Invoice module is not enable';
1059 $ispostactionok = -1;
1062 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1063 $ispostactionok = -1;
1065 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1066 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1067 $don =
new Don($db);
1068 $result = $don->fetch((
int) $tmptag[
'DON']);
1071 if ($paymentmethod ==
'paybox') {
1074 if ($paymentmethod ==
'paypal') {
1075 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1077 if ($paymentmethod ==
'stripe') {
1080 if (empty($paymentTypeId)) {
1081 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1083 if (empty($paymentType)) {
1084 $paymentType =
'CB';
1088 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1091 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1097 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1101 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1104 $totalpaid = $FinalPaymentAmt;
1106 if ($currencyCodeType == $conf->currency) {
1107 $paiement->amounts = array($object->id => $totalpaid);
1110 $postactionmessages[] =
'Payment donation can\'t be payed with diffent currency than '.$conf->currency;
1111 $ispostactionok = -1;
1115 $paiement->fk_donation = $don->id;
1116 $paiement->datep = $now;
1117 $paiement->paymenttype = $paymentTypeId;
1118 $paiement->num_payment =
'';
1119 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1120 $paiement->ext_payment_id = $TRANSACTIONID;
1121 $paiement->ext_payment_site = $service;
1124 $paiement_id = $paiement->create($user, 1);
1125 if ($paiement_id < 0) {
1126 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1127 $ispostactionok = -1;
1130 $postactionmessages[] =
'Payment created';
1131 $ispostactionok = 1;
1133 if ($totalpaid >= $don->getRemainToPay()) {
1134 $don->setPaid($don->id);
1139 if (!$error && isModEnabled(
"banque")) {
1141 if ($paymentmethod ==
'paybox') {
1142 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1143 } elseif ($paymentmethod ==
'paypal') {
1144 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1145 } elseif ($paymentmethod ==
'stripe') {
1146 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1149 if ($bankaccountid > 0) {
1150 $label =
'(DonationPayment)';
1151 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1153 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1154 $ispostactionok = -1;
1157 $postactionmessages[] =
'Bank transaction of payment created';
1158 $ispostactionok = 1;
1161 $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.';
1162 $ispostactionok = -1;
1173 $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.';
1174 $ispostactionok = -1;
1177 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1178 $ispostactionok = -1;
1183 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1185 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1186 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1187 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1189 $result = $object->fetch($ref);
1192 if ($paymentmethod ==
'paybox') {
1195 if ($paymentmethod ==
'paypal') {
1198 if ($paymentmethod ==
'stripe') {
1201 if (empty($paymentTypeId)) {
1202 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1204 if (empty($paymentType)) {
1205 $paymentType =
'CB';
1209 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1212 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1218 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1219 $resultvalidate = $object->validate($user);
1220 if ($resultvalidate < 0) {
1221 $postactionmessages[] =
'Cannot validate invoice';
1222 $ispostactionok = -1;
1228 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1230 $paiement->datepaye = $now;
1231 if ($currencyCodeType == $conf->currency) {
1232 $paiement->amounts = array($object->id => $FinalPaymentAmt);
1234 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
1236 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1237 $ispostactionok = -1;
1240 $paiement->paiementid = $paymentTypeId;
1241 $paiement->num_payment =
'';
1242 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1243 $paiement->ext_payment_id = $TRANSACTIONID;
1244 $paiement->ext_payment_site = $service;
1247 $paiement_id = $paiement->create($user, 1);
1248 if ($paiement_id < 0) {
1249 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1250 $ispostactionok = -1;
1253 $postactionmessages[] =
'Payment created';
1254 $ispostactionok = 1;
1258 if (!$error && isModEnabled(
"banque")) {
1260 if ($paymentmethod ==
'paybox') {
1261 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1262 } elseif ($paymentmethod ==
'paypal') {
1263 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1264 } elseif ($paymentmethod ==
'stripe') {
1265 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1268 if ($bankaccountid > 0) {
1269 $label =
'(CustomerInvoicePayment)';
1271 $label =
'(CustomerInvoicePaymentBack)';
1273 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1275 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1276 $ispostactionok = -1;
1279 $postactionmessages[] =
'Bank transaction of payment created';
1280 $ispostactionok = 1;
1283 $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.';
1284 $ispostactionok = -1;
1293 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1294 if ($resultattendee < 0) {
1298 $attendeetovalidate->validate($user);
1300 $attendeetovalidate->amount = $FinalPaymentAmt;
1301 $attendeetovalidate->date_subscription =
dol_now();
1302 $attendeetovalidate->update($user);
1316 $thirdparty =
new Societe($db);
1317 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1318 if ($resultthirdparty < 0) {
1319 setEventMessages($resultthirdparty->error, $resultthirdparty->errors,
"errors");
1321 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1322 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1325 $outputlangs =
new Translate(
'', $conf);
1326 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1328 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1330 $arraydefaultmessage =
null;
1332 $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT;
1334 if (!empty($idoftemplatetouse)) {
1335 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1338 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1339 $subject = $arraydefaultmessage->topic;
1340 $msg = $arraydefaultmessage->content;
1342 $subject =
'['.$appli.
'] '.$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1343 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1352 $sendto = $attendeetovalidate->email;
1354 if ($thirdparty->email) {
1355 $cc = $thirdparty->email;
1357 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1358 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1363 $urlback = $_SERVER[
"REQUEST_URI"];
1369 $listofpaths = array();
1370 $listofnames = array();
1371 $listofmimes = array();
1372 if (is_object($object)) {
1373 $invoicediroutput = $conf->facture->dir_output;
1374 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->ref, preg_quote($object->ref,
'/').
'[^\-]+');
1375 $file = $fileparams[
'fullname'];
1377 $listofpaths = array($file);
1378 $listofnames = array(basename($file));
1382 $trackid =
'inv'.$object->id;
1384 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1386 $result = $mailfile->sendfile();
1388 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1390 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1396 $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.';
1397 $ispostactionok = -1;
1400 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1401 $ispostactionok = -1;
1403 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1405 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1406 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1407 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1409 $result = $object->fetch($ref);
1411 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1414 if ($paymentmethod ==
'paybox') {
1417 if ($paymentmethod ==
'paypal') {
1420 if ($paymentmethod ==
'stripe') {
1423 if (empty($paymentTypeId)) {
1424 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1426 if (empty($paymentType)) {
1427 $paymentType =
'CB';
1431 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1434 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1440 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1441 $resultvalidate = $object->validate($user);
1442 if ($resultvalidate < 0) {
1443 $postactionmessages[] =
'Cannot validate invoice';
1444 $ispostactionok = -1;
1450 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1452 $paiement->datepaye = $now;
1453 if ($currencyCodeType == $conf->currency) {
1454 $paiement->amounts = array($object->id => $FinalPaymentAmt);
1456 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
1458 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1459 $ispostactionok = -1;
1462 $paiement->paiementid = $paymentTypeId;
1463 $paiement->num_payment =
'';
1464 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1465 $paiement->ext_payment_id = $TRANSACTIONID;
1466 $paiement->ext_payment_site = $service;
1469 $paiement_id = $paiement->create($user, 1);
1470 if ($paiement_id < 0) {
1471 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1472 $ispostactionok = -1;
1475 $postactionmessages[] =
'Payment created';
1476 $ispostactionok = 1;
1480 if (!$error && isModEnabled(
"banque")) {
1482 if ($paymentmethod ==
'paybox') {
1483 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1484 } elseif ($paymentmethod ==
'paypal') {
1485 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1486 } elseif ($paymentmethod ==
'stripe') {
1487 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1490 if ($bankaccountid > 0) {
1491 $label =
'(CustomerInvoicePayment)';
1493 $label =
'(CustomerInvoicePaymentBack)';
1495 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1497 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1498 $ispostactionok = -1;
1501 $postactionmessages[] =
'Bank transaction of payment created';
1502 $ispostactionok = 1;
1505 $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.';
1506 $ispostactionok = -1;
1513 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1514 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1516 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1517 if ($resultbooth < 0) {
1521 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1522 $resultboothupdate = $booth->update($user);
1523 if ($resultboothupdate<0) {
1526 $resultinvoice = $invoice->fetch($ref);
1527 if ($resultinvoice<0) {
1528 $postactionmessages[] =
'Could not find the associated invoice.';
1529 $ispostactionok = -1;
1532 $thirdparty =
new Societe($db);
1533 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1534 if ($resultthirdparty<0) {
1539 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1540 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1543 $outputlangs =
new Translate(
'', $conf);
1544 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1546 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1548 $arraydefaultmessage =
null;
1550 $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH;
1552 if (!empty($idoftemplatetouse)) {
1553 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1556 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1557 $subject = $arraydefaultmessage->topic;
1558 $msg = $arraydefaultmessage->content;
1560 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1561 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1570 $sendto = $thirdparty->email;
1571 $from = $conf->global->MAILING_EMAIL_FROM;
1572 $urlback = $_SERVER[
"REQUEST_URI"];
1575 $trackid =
'inv'.$invoice->id;
1577 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1579 $result = $mailfile->sendfile();
1581 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1583 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1598 $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.';
1599 $ispostactionok = -1;
1602 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1603 $ispostactionok = -1;
1605 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1606 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1608 $result = $object->fetch((
int) $tmptag[
'CON']);
1610 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1613 if ($paymentmethod ==
'paybox') {
1616 if ($paymentmethod ==
'paypal') {
1619 if ($paymentmethod ==
'stripe') {
1622 if (empty($paymentTypeId)) {
1623 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1625 if (empty($paymentType)) {
1626 $paymentType =
'CB';
1630 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1633 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1638 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1639 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1642 if (isModEnabled(
'facture')) {
1643 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1644 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1646 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1649 $invoice->validate($user);
1651 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1653 $paiement->datepaye = $now;
1654 if ($currencyCodeType == $conf->currency) {
1655 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1657 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1659 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1660 $ispostactionok = -1;
1663 $paiement->paiementid = $paymentTypeId;
1664 $paiement->num_payment =
'';
1665 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1666 $paiement->ext_payment_id = $TRANSACTIONID;
1667 $paiement->ext_payment_site = $service;
1670 $paiement_id = $paiement->create($user, 1);
1671 if ($paiement_id < 0) {
1672 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1673 $ispostactionok = -1;
1676 $postactionmessages[] =
'Payment created';
1677 $ispostactionok = 1;
1681 if (!$error && isModEnabled(
"banque")) {
1683 if ($paymentmethod ==
'paybox') {
1684 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1685 } elseif ($paymentmethod ==
'paypal') {
1686 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1687 } elseif ($paymentmethod ==
'stripe') {
1688 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1691 if ($bankaccountid > 0) {
1692 $label =
'(CustomerInvoicePayment)';
1694 $label =
'(CustomerInvoicePaymentBack)';
1696 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1698 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1699 $ispostactionok = -1;
1702 $postactionmessages[] =
'Bank transaction of payment created';
1703 $ispostactionok = 1;
1706 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1707 $ispostactionok = -1;
1718 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1719 if (!empty($cols)) {
1720 $msg .=
' and col '. $cols .
'.';
1722 $postactionmessages[] = $msg;
1723 $ispostactionok = -1;
1726 $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.';
1727 $ispostactionok = -1;
1730 $postactionmessages[] =
'Invoice module is not enable';
1731 $ispostactionok = -1;
1734 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
1735 if (!empty($cols)) {
1736 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
1738 $postactionmessages[] = $msg;
1739 $ispostactionok = -1;
1749 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1750 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1752 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
1753 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'': $_SESSION[
"FinalPaymentAmt"];
1754 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
1756 if (is_object($object) && method_exists($object,
'call_trigger')) {
1758 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1763 } elseif (get_class($object) ==
'stdClass') {
1765 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1767 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1773 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
1774 if ($TRANSACTIONID) {
1775 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
1778 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
1779 if (!empty($conf->global->$key)) {
1781 print $conf->global->$key;
1788 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
1792 $companylangs =
new Translate(
'', $conf);
1793 $companylangs->setDefaultLang($mysoc->default_lang);
1794 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
1796 $sendto = $sendemail;
1799 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1800 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1805 $urlback = $_SERVER[
"REQUEST_URI"];
1806 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
1808 if (array_key_exists(
'MEM', $tmptag)) {
1809 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
1810 $content .=
'<strong>'.$companylangs->trans(
"PaymentSubscription").
"</strong><br><br>\n";
1811 $content .= $companylangs->trans(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
1812 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1813 } elseif (array_key_exists(
'INV', $tmptag)) {
1814 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
1815 $content .=
'<strong>'.$companylangs->trans(
"Payment").
"</strong><br><br>\n";
1816 $content .= $companylangs->trans(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
1818 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1820 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
1822 $content .= $companylangs->transnoentities(
"PostActionAfterPayment").
' : ';
1823 if ($ispostactionok > 0) {
1825 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
1826 } elseif ($ispostactionok == 0) {
1827 $content .= $companylangs->transnoentitiesnoconv(
"None");
1829 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
1830 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
1832 $content .=
'<br>'.
"\n";
1833 foreach ($postactionmessages as $postactionmessage) {
1834 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
1836 if ($ispostactionok < 0) {
1837 $content .= $langs->transnoentities(
"ARollbackWasPerformedOnPostActions");
1839 $content .=
'<br>'.
"\n";
1841 $content .=
"<br>\n";
1842 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
1843 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
1844 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
1845 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
1846 $content .=
"<br>\n";
1847 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
1849 if (!empty($ErrorCode)) {
1850 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
1852 if (!empty($ErrorShortMsg)) {
1853 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
1855 if (!empty($ErrorLongMsg)) {
1856 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
1858 if (!empty($ErrorSeverityCode)) {
1859 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
1866 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1867 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1869 $result = $mailfile->sendfile();
1871 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1874 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1880 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1881 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1883 $paymentType = $_SESSION[
'PaymentType'];
1884 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1885 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1887 if (is_object($object) && method_exists($object,
'call_trigger')) {
1889 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
1896 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
1897 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
1898 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
1899 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
1900 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
1902 if ($mysoc->email) {
1903 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
1908 $sendemail = $conf->global->PAYMENTONLINE_SENDEMAIL;
1911 if ($paymentmethod ==
'paypal' &&
getDolGlobalString(
'PAYPAL_PAYONLINE_SENDEMAIL')) {
1912 $sendemail = $conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
1913 } elseif ($paymentmethod ==
'paybox' &&
getDolGlobalString(
'PAYBOX_PAYONLINE_SENDEMAIL')) {
1914 $sendemail = $conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
1915 } elseif ($paymentmethod ==
'stripe' &&
getDolGlobalString(
'STRIPE_PAYONLINE_SENDEMAIL')) {
1916 $sendemail = $conf->global->STRIPE_PAYONLINE_SENDEMAIL;
1921 $companylangs =
new Translate(
'', $conf);
1922 $companylangs->setDefaultLang($mysoc->default_lang);
1923 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
1925 $sendto = $sendemail;
1928 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1929 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1932 $urlback = $_SERVER[
"REQUEST_URI"];
1933 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
1935 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
1937 $content .=
"<br><br>\n";
1938 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
1939 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
1940 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
1941 $content .=
"<br>\n";
1942 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
1948 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1949 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1951 $result = $mailfile->sendfile();
1953 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1955 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1963print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag($paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
1970unset($_SESSION[
"FinalPaymentAmt"]);
1971unset($_SESSION[
"TRANSACTIONID"]);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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 contracts.
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...)
Class to manage translations.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML 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=false, $mode='')
Return file(s) into a directory (by default most recent)
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return 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...
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.