32 if (!defined(
'NOLOGIN')) {
35 if (!defined(
'NOCSRFCHECK')) {
36 define(
"NOCSRFCHECK", 1);
38 if (!defined(
'NOIPCHECK')) {
39 define(
'NOIPCHECK',
'1');
41 if (!defined(
'NOBROWSERNOTIF')) {
42 define(
'NOBROWSERNOTIF',
'1');
48 $entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
49 if (is_numeric($entity)) {
50 define(
"DOLENTITY", $entity);
54 require
'../../main.inc.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
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",
"stripe"));
71 $PAYPAL_API_USER =
"";
75 $PAYPAL_API_PASSWORD =
"";
79 $PAYPAL_API_SIGNATURE =
"";
83 $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');
107 if (empty($FULLTAG)) {
113 $suffix =
GETPOST(
"suffix",
'aZ09');
120 if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
121 $paymentmethod = $reg[1];
123 if (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');
129 dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
132 $ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
134 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');
137 $validpaymentmethod = array();
139 $validpaymentmethod[
'paypal'] =
'paypal';
142 $validpaymentmethod[
'paybox'] =
'paybox';
145 $validpaymentmethod[
'stripe'] =
'stripe';
149 if (empty($validpaymentmethod)) {
154 $ispaymentok =
false;
156 $PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
158 $ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
172 $doactionsthenredirect = 1;
178 dol_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');
179 dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
180 dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
183 foreach ($_POST as $k => $v) {
184 if (is_scalar($k) && is_scalar($v)) {
185 $tracepost .=
"$k - $v\n";
188 dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
190 foreach ($_SESSION as $k => $v) {
191 if (is_scalar($k) && is_scalar($v)) {
192 $tracesession .=
"$k - $v\n";
195 dol_syslog(
"SESSION=".$tracesession, LOG_DEBUG, 0,
'_payment');
199 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
202 $conf->dol_hide_topmenu = 1;
203 $conf->dol_hide_leftmenu = 1;
207 if (empty($doactionsthenredirect)) {
208 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
209 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
213 print
'<span id="dolpaymentspan"></span>'.
"\n";
214 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
219 $logosmall = $mysoc->logo_small;
220 $logo = $mysoc->logo;
221 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
222 if (!empty($conf->global->$paramlogo)) {
231 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
232 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
233 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
234 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
235 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
236 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
241 print
'<div class="backgreypublicpayment">';
242 print
'<div class="logopublicpayment">';
243 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
247 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>';
252 print
'<div class="backimagepublicpayment">';
253 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
258 print
'<br><br><br>';
264 if ($paymentmethod ===
'paypal') {
267 $onlinetoken = $PAYPALTOKEN;
269 $payerID = $PAYPALPAYERID;
271 $currencyCodeType = $_SESSION[
'currencyCodeType'];
272 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
273 $paymentType = $_SESSION[
'PaymentType'];
275 $ipaddress = $_SESSION[
'ipaddress'];
277 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
280 if (!empty($paymentType)) {
281 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
285 $ack = strtoupper($resArray[
"ACK"]);
286 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
288 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
290 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING,
'_payment');
293 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
294 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
297 $ack = strtoupper($resArray2[
"ACK"]);
298 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
299 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
305 $object->resArray = $resArray2;
309 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
310 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
311 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
312 $NOTE = urldecode($resArray2[
"NOTE"]);
316 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
319 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
320 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
321 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
322 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
325 $ErrorCode =
"SESSIONEXPIRED";
326 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
327 $ErrorShortMsg =
"Session expired";
329 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
333 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
334 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
335 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
337 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
344 if ($paymentmethod ===
'paybox') {
351 if ($paymentmethod ===
'stripe') {
360 'paymentmethod' => $paymentmethod,
362 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters,
$object, $action);
364 if (isset($hookmanager->resArray[
'ispaymentok'])) {
365 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
366 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
372 if (empty($ipaddress)) {
373 $ipaddress = $_SESSION[
'ipaddress'];
375 if (empty($TRANSACTIONID)) {
376 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' :$_SESSION[
'TRANSACTIONID'];
377 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
379 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
382 if (empty($FinalPaymentAmt)) {
383 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
385 if (empty($currencyCodeType)) {
386 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
389 if (empty($paymentType)) {
390 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
397 dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
401 $appli = $mysoc->name;
406 $postactionmessages = array();
409 if (empty($user->rights->societe)) {
410 $user->rights->societe =
new stdClass();
412 if (empty($user->rights->facture)) {
413 $user->rights->facture =
new stdClass();
414 $user->rights->facture->invoice_advance =
new stdClass();
416 if (empty($user->rights->adherent)) {
417 $user->rights->adherent =
new stdClass();
418 $user->rights->adherent->cotisation =
new stdClass();
420 $user->rights->societe->creer = 1;
421 $user->rights->facture->creer = 1;
422 $user->rights->facture->invoice_advance->validate = 1;
423 $user->rights->adherent->cotisation->creer = 1;
425 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
432 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
433 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
434 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
438 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
439 $result2 = $adht->fetch(
$object->typeid);
441 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
442 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
444 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
446 if ($result1 > 0 && $result2 > 0) {
448 if ($paymentmethod ==
'paybox') {
451 if ($paymentmethod ==
'paypal') {
454 if ($paymentmethod ==
'stripe') {
457 if (empty($paymentTypeId)) {
458 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
460 if (empty($paymentType)) {
465 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
468 if (empty($paymentTypeId) || $paymentTypeId < 0) {
473 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
476 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
478 if (empty($adht->caneditamount)) {
479 if (
$object->status == $object::STATUS_DRAFT) {
484 $amountbytype = $adht->amountByType(1);
485 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
491 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
493 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') differs from value expected for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
494 $postactionmessages[] = $errmsg;
495 $ispostactionok = -1;
496 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
503 if ($FinalPaymentAmt < $conf->global->MEMBER_MIN_AMOUNT) {
505 $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 ?';
506 $postactionmessages[] = $errmsg;
507 $ispostactionok = -1;
508 dol_syslog(
"Failed to validate member (amount lower than minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
513 if ($currencyCodeType && $currencyCodeType != $conf->currency) {
515 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.$conf->currency.
'). May be a hack to try to pay a different amount ?';
516 $postactionmessages[] = $errmsg;
517 $ispostactionok = -1;
518 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
523 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
524 if ($result < 0 || empty(
$object->datevalid)) {
527 $postactionmessages[] = $errmsg;
528 $postactionmessages = array_merge($postactionmessages,
$object->errors);
529 $ispostactionok = -1;
530 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
535 $datesubscription =
$object->datevalid;
549 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
552 while ($datesubend < $now) {
554 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
561 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? $mysoc->default_lang :
$object->thirdparty->default_lang);
563 $amount = $FinalPaymentAmt;
564 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
565 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
569 if ($paymentmethod ==
'paybox') {
572 if ($paymentmethod ==
'paypal') {
575 if ($paymentmethod ==
'stripe') {
581 'paymentmethod' => $paymentmethod,
583 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
585 if (isset($hookmanager->resArray[
'bankaccountid'])) {
586 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
587 $accountid = $hookmanager->resArray[
'bankaccountid'];
590 if ($accountid < 0) {
592 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
593 $postactionmessages[] = $errmsg;
594 $ispostactionok = -1;
595 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
598 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
601 $emetteur_banque =
'';
605 $option =
'bankviainvoice';
607 $option =
'bankdirect';
609 $option =
'invoiceonly';
611 if (empty($option)) {
621 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
623 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
627 $postactionmessages[] = $errmsg;
628 $ispostactionok = -1;
630 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
636 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
638 $autocreatethirdparty = 1;
640 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
645 $postactionmessages[] =
$object->error;
646 $postactionmessages = array_merge($postactionmessages,
$object->errors);
647 $ispostactionok = -1;
649 if ($option ==
'bankviainvoice') {
650 $postactionmessages[] =
'Invoice, payment and bank record created';
651 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
653 if ($option ==
'bankdirect') {
654 $postactionmessages[] =
'Bank record created';
655 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
657 if ($option ==
'invoiceonly') {
658 $postactionmessages[] =
'Invoice recorded';
659 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
668 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
669 $thirdparty_id =
$object->fk_soc;
671 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
673 $service =
'StripeTest';
676 $service =
'StripeLive';
681 $thirdparty =
new Societe($db);
682 $thirdparty->fetch($thirdparty_id);
684 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
685 $stripe =
new Stripe($db);
688 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
690 if (!$customer && $TRANSACTIONID) {
691 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
694 global $stripearrayofkeysbyenv;
695 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
697 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
699 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
702 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
706 $stripecu = $chpi->customer;
708 if (empty($stripecu)) {
710 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
713 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
714 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
717 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
718 $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)";
719 $resql = $db->query(
$sql);
722 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
724 $postactionmessages[] = $errmsg;
725 $ispostactionok = -1;
730 $errmsg =
'Failed to retrieve paymentintent or charge from id';
732 $postactionmessages[] = $errmsg;
733 $ispostactionok = -1;
737 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
739 $postactionmessages[] = $errmsg;
740 $ispostactionok = -1;
754 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
757 if (
$object->email && $sendalsoemail) {
762 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
765 $outputlangs->loadLangs(array(
"main",
"members"));
767 $arraydefaultmessage =
null;
770 if (!empty($labeltouse)) {
771 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
774 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
775 $subject = $arraydefaultmessage->topic;
776 $msg = $arraydefaultmessage->content;
784 $nuser =
new User($db);
787 $result = $nuser->create_from_member($tmpuser,
$object->login);
788 $newpassword = $nuser->setPassword($user,
'');
791 $outputlangs->load(
"errors");
792 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
794 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
795 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
797 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
806 $listofpaths = array();
807 $listofnames = array();
808 $listofmimes = array();
809 if (is_object(
$object->invoice)) {
810 $invoicediroutput = $conf->facture->dir_output;
812 $file = $fileparams[
'fullname'];
814 $listofpaths = array($file);
815 $listofnames = array(basename($file));
819 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
821 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
825 $postactionmessages[] = $errmsg;
826 $ispostactionok = -1;
829 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
831 $postactionmessages[] =
'Email sent to member (without any attached document)';
839 $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.';
840 $ispostactionok = -1;
843 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
844 $ispostactionok = -1;
846 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
848 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
850 $result =
$object->fetch((
int) $tmptag[
'INV']);
852 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
855 if ($paymentmethod ===
'paybox') {
858 if ($paymentmethod ===
'paypal') {
861 if ($paymentmethod ===
'stripe') {
864 if (empty($paymentTypeId)) {
865 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
867 if (empty($paymentType)) {
872 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
875 if (empty($paymentTypeId) || $paymentTypeId < 0) {
880 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
883 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
887 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
889 $paiement->datepaye = $now;
890 if ($currencyCodeType == $conf->currency) {
891 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
893 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
895 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
896 $ispostactionok = -1;
899 $paiement->paiementid = $paymentTypeId;
900 $paiement->num_payment =
'';
901 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
902 $paiement->ext_payment_id = $TRANSACTIONID;
904 $paiement->ext_payment_site = $service;
907 $paiement_id = $paiement->create($user, 1);
908 if ($paiement_id < 0) {
909 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
910 $ispostactionok = -1;
913 $postactionmessages[] =
'Payment created';
920 if ($paymentmethod ==
'paybox') {
922 } elseif ($paymentmethod ==
'paypal') {
924 } elseif ($paymentmethod ==
'stripe') {
930 'paymentmethod' => $paymentmethod,
932 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
934 if (isset($hookmanager->resArray[
'bankaccountid'])) {
935 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
936 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
939 if ($bankaccountid > 0) {
940 $label =
'(CustomerInvoicePayment)';
942 $label =
'(CustomerInvoicePaymentBack)';
944 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
946 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
947 $ispostactionok = -1;
950 $postactionmessages[] =
'Bank transaction of payment created';
954 $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.';
955 $ispostactionok = -1;
966 $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.';
967 $ispostactionok = -1;
970 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
971 $ispostactionok = -1;
973 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
974 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
976 $result =
$object->fetch((
int) $tmptag[
'ORD']);
978 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
981 if ($paymentmethod ==
'paybox') {
984 if ($paymentmethod ==
'paypal') {
987 if ($paymentmethod ==
'stripe') {
990 if (empty($paymentTypeId)) {
991 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
993 if (empty($paymentType)) {
998 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1001 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1008 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1009 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1011 $result = $invoice->createFromOrder(
$object, $user);
1013 $object->classifyBilled($user);
1014 $invoice->validate($user);
1016 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1018 $paiement->datepaye = $now;
1019 if ($currencyCodeType == $conf->currency) {
1020 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1022 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1024 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1025 $ispostactionok = -1;
1028 $paiement->paiementid = $paymentTypeId;
1029 $paiement->num_payment =
'';
1030 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1031 $paiement->ext_payment_id = $TRANSACTIONID;
1032 $paiement->ext_payment_site = $service;
1035 $paiement_id = $paiement->create($user, 1);
1036 if ($paiement_id < 0) {
1037 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1038 $ispostactionok = -1;
1041 $postactionmessages[] =
'Payment created';
1042 $ispostactionok = 1;
1048 if ($paymentmethod ==
'paybox') {
1050 } elseif ($paymentmethod ==
'paypal') {
1052 } elseif ($paymentmethod ==
'stripe') {
1058 'paymentmethod' => $paymentmethod,
1060 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
1061 if ($reshook >= 0) {
1062 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1063 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1064 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1067 if ($bankaccountid > 0) {
1068 $label =
'(CustomerInvoicePayment)';
1070 $label =
'(CustomerInvoicePaymentBack)';
1072 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1074 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1075 $ispostactionok = -1;
1078 $postactionmessages[] =
'Bank transaction of payment created';
1079 $ispostactionok = 1;
1082 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1083 $ispostactionok = -1;
1094 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1095 $ispostactionok = -1;
1098 $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.';
1099 $ispostactionok = -1;
1102 $postactionmessages[] =
'Invoice module is not enable';
1103 $ispostactionok = -1;
1106 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1107 $ispostactionok = -1;
1109 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1110 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1111 $don =
new Don($db);
1112 $result = $don->fetch((
int) $tmptag[
'DON']);
1115 if ($paymentmethod ==
'paybox') {
1118 if ($paymentmethod ==
'paypal') {
1119 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1121 if ($paymentmethod ==
'stripe') {
1124 if (empty($paymentTypeId)) {
1125 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1127 if (empty($paymentType)) {
1128 $paymentType =
'CB';
1132 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1135 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1141 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1145 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1148 $totalpaid = $FinalPaymentAmt;
1150 if ($currencyCodeType == $conf->currency) {
1151 $paiement->amounts = array(
$object->id => $totalpaid);
1154 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1155 $ispostactionok = -1;
1159 $paiement->fk_donation = $don->id;
1160 $paiement->datep = $now;
1161 $paiement->paymenttype = $paymentTypeId;
1162 $paiement->num_payment =
'';
1163 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1164 $paiement->ext_payment_id = $TRANSACTIONID;
1165 $paiement->ext_payment_site = $service;
1168 $paiement_id = $paiement->create($user, 1);
1169 if ($paiement_id < 0) {
1170 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1171 $ispostactionok = -1;
1174 $postactionmessages[] =
'Payment created';
1175 $ispostactionok = 1;
1177 if ($totalpaid >= $don->getRemainToPay()) {
1178 $don->setPaid($don->id);
1185 if ($paymentmethod ==
'paybox') {
1187 } elseif ($paymentmethod ==
'paypal') {
1189 } elseif ($paymentmethod ==
'stripe') {
1195 'paymentmethod' => $paymentmethod,
1197 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
1198 if ($reshook >= 0) {
1199 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1200 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1201 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1204 if ($bankaccountid > 0) {
1205 $label =
'(DonationPayment)';
1206 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1208 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1209 $ispostactionok = -1;
1212 $postactionmessages[] =
'Bank transaction of payment created';
1213 $ispostactionok = 1;
1216 $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.';
1217 $ispostactionok = -1;
1228 $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.';
1229 $ispostactionok = -1;
1232 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1233 $ispostactionok = -1;
1238 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1240 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1241 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1242 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1244 $result =
$object->fetch($ref);
1247 if ($paymentmethod ==
'paybox') {
1250 if ($paymentmethod ==
'paypal') {
1253 if ($paymentmethod ==
'stripe') {
1256 if (empty($paymentTypeId)) {
1257 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1259 if (empty($paymentType)) {
1260 $paymentType =
'CB';
1264 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1267 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1273 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1274 $resultvalidate =
$object->validate($user);
1275 if ($resultvalidate < 0) {
1276 $postactionmessages[] =
'Cannot validate invoice';
1277 $ispostactionok = -1;
1283 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1285 $paiement->datepaye = $now;
1286 if ($currencyCodeType == $conf->currency) {
1287 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1289 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1291 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1292 $ispostactionok = -1;
1295 $paiement->paiementid = $paymentTypeId;
1296 $paiement->num_payment =
'';
1297 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1298 $paiement->ext_payment_id = $TRANSACTIONID;
1299 $paiement->ext_payment_site = $service;
1302 $paiement_id = $paiement->create($user, 1);
1303 if ($paiement_id < 0) {
1304 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1305 $ispostactionok = -1;
1308 $postactionmessages[] =
'Payment created';
1309 $ispostactionok = 1;
1315 if ($paymentmethod ==
'paybox') {
1317 } elseif ($paymentmethod ==
'paypal') {
1319 } elseif ($paymentmethod ==
'stripe') {
1325 'paymentmethod' => $paymentmethod,
1327 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
1328 if ($reshook >= 0) {
1329 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1330 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1331 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1334 if ($bankaccountid > 0) {
1335 $label =
'(CustomerInvoicePayment)';
1337 $label =
'(CustomerInvoicePaymentBack)';
1339 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1341 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1342 $ispostactionok = -1;
1345 $postactionmessages[] =
'Bank transaction of payment created';
1346 $ispostactionok = 1;
1349 $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.';
1350 $ispostactionok = -1;
1359 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1360 if ($resultattendee < 0) {
1364 $attendeetovalidate->validate($user);
1366 $attendeetovalidate->amount = $FinalPaymentAmt;
1367 $attendeetovalidate->date_subscription =
dol_now();
1368 $attendeetovalidate->update($user);
1382 $thirdparty =
new Societe($db);
1383 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1384 if ($resultthirdparty < 0) {
1385 setEventMessages($resultthirdparty->error, $resultthirdparty->errors,
"errors");
1387 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1388 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1391 $outputlangs =
new Translate(
'', $conf);
1392 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1394 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1396 $arraydefaultmessage =
null;
1398 $idoftemplatetouse =
getDolGlobalString(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1400 if (!empty($idoftemplatetouse)) {
1401 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1404 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1405 $subject = $arraydefaultmessage->topic;
1406 $msg = $arraydefaultmessage->content;
1408 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1409 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1418 $sendto = $attendeetovalidate->email;
1420 if ($thirdparty->email) {
1421 $cc = $thirdparty->email;
1423 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1424 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1429 $urlback = $_SERVER[
"REQUEST_URI"];
1435 $listofpaths = array();
1436 $listofnames = array();
1437 $listofmimes = array();
1439 $invoicediroutput = $conf->facture->dir_output;
1441 $file = $fileparams[
'fullname'];
1443 $listofpaths = array($file);
1444 $listofnames = array(basename($file));
1448 $trackid =
'inv'.$object->id;
1450 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1452 $result = $mailfile->sendfile();
1454 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1456 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1462 $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.';
1463 $ispostactionok = -1;
1466 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1467 $ispostactionok = -1;
1469 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1471 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1472 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1473 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1475 $result =
$object->fetch($ref);
1477 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1480 if ($paymentmethod ==
'paybox') {
1483 if ($paymentmethod ==
'paypal') {
1486 if ($paymentmethod ==
'stripe') {
1489 if (empty($paymentTypeId)) {
1490 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1492 if (empty($paymentType)) {
1493 $paymentType =
'CB';
1497 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1500 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1506 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1507 $resultvalidate =
$object->validate($user);
1508 if ($resultvalidate < 0) {
1509 $postactionmessages[] =
'Cannot validate invoice';
1510 $ispostactionok = -1;
1516 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1518 $paiement->datepaye = $now;
1519 if ($currencyCodeType == $conf->currency) {
1520 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1522 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1524 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1525 $ispostactionok = -1;
1528 $paiement->paiementid = $paymentTypeId;
1529 $paiement->num_payment =
'';
1530 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1531 $paiement->ext_payment_id = $TRANSACTIONID;
1532 $paiement->ext_payment_site = $service;
1535 $paiement_id = $paiement->create($user, 1);
1536 if ($paiement_id < 0) {
1537 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1538 $ispostactionok = -1;
1541 $postactionmessages[] =
'Payment created';
1542 $ispostactionok = 1;
1548 if ($paymentmethod ==
'paybox') {
1550 } elseif ($paymentmethod ==
'paypal') {
1552 } elseif ($paymentmethod ==
'stripe') {
1558 'paymentmethod' => $paymentmethod,
1560 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
1561 if ($reshook >= 0) {
1562 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1563 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1564 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1567 if ($bankaccountid > 0) {
1568 $label =
'(CustomerInvoicePayment)';
1570 $label =
'(CustomerInvoicePaymentBack)';
1572 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1574 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1575 $ispostactionok = -1;
1578 $postactionmessages[] =
'Bank transaction of payment created';
1579 $ispostactionok = 1;
1582 $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.';
1583 $ispostactionok = -1;
1590 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1591 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1593 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1594 if ($resultbooth < 0) {
1598 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1599 $resultboothupdate = $booth->update($user);
1600 if ($resultboothupdate<0) {
1603 $resultinvoice = $invoice->fetch($ref);
1604 if ($resultinvoice<0) {
1605 $postactionmessages[] =
'Could not find the associated invoice.';
1606 $ispostactionok = -1;
1609 $thirdparty =
new Societe($db);
1610 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1611 if ($resultthirdparty<0) {
1616 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1617 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1620 $outputlangs =
new Translate(
'', $conf);
1621 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1623 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1625 $arraydefaultmessage =
null;
1627 $idoftemplatetouse =
getDolGlobalString(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1629 if (!empty($idoftemplatetouse)) {
1630 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1633 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1634 $subject = $arraydefaultmessage->topic;
1635 $msg = $arraydefaultmessage->content;
1637 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1638 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1647 $sendto = $thirdparty->email;
1649 $urlback = $_SERVER[
"REQUEST_URI"];
1652 $trackid =
'inv'.$invoice->id;
1654 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1656 $result = $mailfile->sendfile();
1658 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1660 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1675 $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.';
1676 $ispostactionok = -1;
1679 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1680 $ispostactionok = -1;
1682 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1683 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1685 $result =
$object->fetch((
int) $tmptag[
'CON']);
1687 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1690 if ($paymentmethod ==
'paybox') {
1693 if ($paymentmethod ==
'paypal') {
1696 if ($paymentmethod ==
'stripe') {
1699 if (empty($paymentTypeId)) {
1700 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1702 if (empty($paymentType)) {
1703 $paymentType =
'CB';
1707 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1710 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1715 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1716 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] :
null;
1720 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1721 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1723 $result = $invoice->createFromContract(
$object, $user, array((
int) $contract_lines));
1726 $invoice->validate($user);
1728 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1730 $paiement->datepaye = $now;
1731 if ($currencyCodeType == $conf->currency) {
1732 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1734 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1736 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1737 $ispostactionok = -1;
1740 $paiement->paiementid = $paymentTypeId;
1741 $paiement->num_payment =
'';
1742 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1743 $paiement->ext_payment_id = $TRANSACTIONID;
1744 $paiement->ext_payment_site = $service;
1747 $paiement_id = $paiement->create($user, 1);
1748 if ($paiement_id < 0) {
1749 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1750 $ispostactionok = -1;
1753 $postactionmessages[] =
'Payment created';
1754 $ispostactionok = 1;
1760 if ($paymentmethod ==
'paybox') {
1762 } elseif ($paymentmethod ==
'paypal') {
1764 } elseif ($paymentmethod ==
'stripe') {
1770 'paymentmethod' => $paymentmethod,
1772 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters,
$object, $action);
1773 if ($reshook >= 0) {
1774 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1775 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1776 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1779 if ($bankaccountid > 0) {
1780 $label =
'(CustomerInvoicePayment)';
1782 $label =
'(CustomerInvoicePaymentBack)';
1784 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1786 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1787 $ispostactionok = -1;
1790 $postactionmessages[] =
'Bank transaction of payment created';
1791 $ispostactionok = 1;
1794 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1795 $ispostactionok = -1;
1806 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1807 if (!empty($cols)) {
1808 $msg .=
' and col '. $cols .
'.';
1810 $postactionmessages[] = $msg;
1811 $ispostactionok = -1;
1814 $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.';
1815 $ispostactionok = -1;
1818 $postactionmessages[] =
'Invoice module is not enable';
1819 $ispostactionok = -1;
1822 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
1823 if (!empty($cols)) {
1824 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
1826 $postactionmessages[] = $msg;
1827 $ispostactionok = -1;
1836 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1837 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1839 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
1840 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'': $_SESSION[
"FinalPaymentAmt"];
1841 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
1843 if (is_object(
$object) && method_exists(
$object,
'call_trigger')) {
1845 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1850 } elseif (get_class(
$object) ==
'stdClass') {
1852 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1854 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1863 if (empty($doactionsthenredirect)) {
1865 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
1866 if ($TRANSACTIONID) {
1867 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
1871 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
1877 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
1878 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
1879 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
1880 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
1881 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
1883 if ($mysoc->email) {
1884 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
1896 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
1900 $companylangs =
new Translate(
'', $conf);
1901 $companylangs->setDefaultLang($mysoc->default_lang);
1902 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
1904 $sendto = $sendemail;
1907 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1908 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1913 $urlback = $_SERVER[
"REQUEST_URI"];
1914 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
1916 if (array_key_exists(
'MEM', $tmptag)) {
1917 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
1918 $content .=
'<strong>'.$companylangs->trans(
"PaymentSubscription").
"</strong><br><br>\n";
1919 $content .= $companylangs->trans(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
1920 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1921 } elseif (array_key_exists(
'INV', $tmptag)) {
1922 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
1923 $content .=
'<strong>'.$companylangs->trans(
"Payment").
"</strong><br><br>\n";
1924 $content .= $companylangs->trans(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
1926 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1928 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
1930 $content .= $companylangs->transnoentities(
"PostActionAfterPayment").
' : ';
1931 if ($ispostactionok > 0) {
1933 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
1934 } elseif ($ispostactionok == 0) {
1935 $content .= $companylangs->transnoentitiesnoconv(
"None");
1937 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
1938 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
1940 $content .=
'<br>'.
"\n";
1941 foreach ($postactionmessages as $postactionmessage) {
1942 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
1944 if ($ispostactionok < 0) {
1945 $content .= $langs->transnoentities(
"ARollbackWasPerformedOnPostActions");
1947 $content .=
'<br>'.
"\n";
1949 $content .=
"<br>\n";
1950 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
1951 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
1952 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
1953 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
1954 $content .=
"<br>\n";
1955 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
1957 if (!empty($ErrorCode)) {
1958 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
1960 if (!empty($ErrorShortMsg)) {
1961 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
1963 if (!empty($ErrorLongMsg)) {
1964 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
1966 if (!empty($ErrorSeverityCode)) {
1967 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
1974 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1975 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
1977 $result = $mailfile->sendfile();
1979 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1982 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1990 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1991 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1993 $paymentType = $_SESSION[
'PaymentType'];
1994 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1995 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1997 if (is_object(
$object) && method_exists(
$object,
'call_trigger')) {
1999 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2008 $companylangs =
new Translate(
'', $conf);
2009 $companylangs->setDefaultLang($mysoc->default_lang);
2010 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2012 $sendto = $sendemail;
2015 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2016 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2019 $urlback = $_SERVER[
"REQUEST_URI"];
2020 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2022 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2024 $content .=
"<br><br>\n";
2025 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2026 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2027 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2028 $content .=
"<br>\n";
2029 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2035 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2036 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml,
'',
'', $trackid,
'',
'standard');
2038 $result = $mailfile->sendfile();
2040 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2042 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2049 unset($_SESSION[
"FinalPaymentAmt"]);
2050 unset($_SESSION[
"TRANSACTIONID"]);
2054 if (empty($doactionsthenredirect)) {
2057 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag($paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2062 if (empty($doactionsthenredirect)) {
2073 if (!empty($doactionsthenredirect)) {
2077 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2078 print
"<script>window.top.location.href = '".dol_escape_js($ext_urlok) .
"';</script>";
2082 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2083 print
"<script>window.top.location.href = '".dol_escape_js($ext_urlko).
"';</script>";
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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...)
Stripe class @TODO No reason to extends CommonObject.
Class to manage translations.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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)
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.
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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_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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.