33if (!defined(
'NOLOGIN')) {
36if (!defined(
'NOCSRFCHECK')) {
37 define(
"NOCSRFCHECK", 1);
39if (!defined(
'NOIPCHECK')) {
40 define(
'NOIPCHECK',
'1');
42if (!defined(
'NOBROWSERNOTIF')) {
43 define(
'NOBROWSERNOTIF',
'1');
46if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
47 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
53$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
54if (is_numeric($entity)) {
55 define(
"DOLENTITY", $entity);
59require
'../../main.inc.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
63if (isModEnabled(
'paypal')) {
64 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
65 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
81$hookmanager->initHooks(array(
'newpayment'));
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
87$PAYPAL_API_PASSWORD =
"";
88$PAYPAL_API_SIGNATURE =
"";
89$PAYPAL_API_SANDBOX =
"";
92if (isModEnabled(
'paypal')) {
98 $PAYPALTOKEN =
GETPOST(
'TOKEN');
99 if (empty($PAYPALTOKEN)) {
100 $PAYPALTOKEN =
GETPOST(
'token');
102 $PAYPALPAYERID =
GETPOST(
'PAYERID');
103 if (empty($PAYPALPAYERID)) {
104 $PAYPALPAYERID =
GETPOST(
'PayerID');
109if (empty($FULLTAG)) {
115$suffix =
GETPOST(
"suffix",
'aZ09');
122if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
123 $paymentmethod = $reg[1];
125if (empty($paymentmethod)) {
126 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
127 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
131dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
135$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
137 dol_syslog(
"paymentok.php page is invoked from a website with ref ".$ws.
". It performs actions and then redirects back to this website. A page with ref paymentok must be created for this website.", LOG_DEBUG, 0,
'_payment');
140$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
143if (empty($validpaymentmethod)) {
148$creditor = $mysoc->name;
149$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
150$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
160$PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
162$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
170$ws_virtuelhost =
null;
172$doactionsthenredirect = 0;
174 $doactionsthenredirect = 1;
175 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
177 $result = $website->fetch(0, $ws);
179 $ws_virtuelhost = $website->virtualhost;
180 $ws_id = $website->id;
197dol_syslog(
"Callback url when a payment was done. doactionsthenredirect=".$doactionsthenredirect.
" query_string=".(empty($_SERVER[
"QUERY_STRING"]) ?
'' :
dol_escape_htmltag($_SERVER[
"QUERY_STRING"])).
" script_uri=".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SCRIPT_URI"])), LOG_DEBUG, 0,
'_payment');
198dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
199dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
202foreach ($_POST as $k => $v) {
203 if (is_scalar($k) && is_scalar($v)) {
204 $tracepost .=
"$k - $v\n";
207dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
210foreach ($_SESSION as $k => $v) {
211 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
212 $tracesession .=
"$k - $v\n";
215dol_syslog(
"SESSION=".$tracesession, LOG_DEBUG, 0,
'_payment');
217dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
221 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
224$conf->dol_hide_topmenu = 1;
225$conf->dol_hide_leftmenu = 1;
229if (empty($doactionsthenredirect)) {
230 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
231 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
235 print
'<span id="dolpaymentspan"></span>'.
"\n";
236 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
241 $logosmall = $mysoc->logo_small;
242 $logo = $mysoc->logo;
243 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
253 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
254 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
255 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
256 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
257 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
258 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
263 print
'<div class="backgreypublicpayment">';
264 print
'<div class="logopublicpayment">';
265 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
269 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
272 } elseif ($creditor) {
273 print
'<div class="backgreypublicpayment">';
274 print
'<div class="logopublicpayment">';
280 print
'<div class="backimagepublicpayment">';
281 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
286 print
'<br><br><br>';
294if (isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
295 if (!empty($PAYPALTOKEN)) {
297 $onlinetoken = $PAYPALTOKEN;
299 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
301 $ipaddress = $_SESSION[
'ipaddress'];
302 $currencyCodeType = $_SESSION[
'currencyCodeType'];
303 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
304 $paymentType = $_SESSION[
'PaymentType'];
306 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
309 if (!empty($paymentType)) {
310 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
314 $ack = strtoupper($resArray[
"ACK"]);
315 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
317 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
319 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, 0,
'_payment');
322 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
323 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
326 $ack = strtoupper($resArray2[
"ACK"]);
327 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
328 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
334 $object->resArray = $resArray2;
338 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
339 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
340 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
341 $NOTE = urldecode($resArray2[
"NOTE"]);
345 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
348 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
349 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
350 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
351 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
354 $ErrorCode =
"SESSIONEXPIRED";
355 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
356 $ErrorShortMsg =
"Session expired";
358 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
362 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
363 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
364 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
366 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
372if (isModEnabled(
'paybox')) {
373 if ($paymentmethod ===
'paybox') {
380if (isModEnabled(
'stripe')) {
381 if ($paymentmethod ===
'stripe') {
383 if (
GETPOST(
'paymentoksessionkey') == $_SESSION[
'paymentoksessionkey']) {
387 $ispaymentok =
false;
393if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
397 'paymentmethod' => $paymentmethod,
399 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
401 if (isset($hookmanager->resArray[
'ispaymentok'])) {
402 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
403 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
409if (empty($ipaddress)) {
410 $ipaddress = $_SESSION[
'ipaddress'];
412if (empty($FinalPaymentAmt)) {
413 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
415if (empty($currencyCodeType)) {
416 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
418if (empty($paymentType)) {
419 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
422if (empty($TRANSACTIONID)) {
423 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
424 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
426 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
434dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
438$appli = $mysoc->name;
443$postactionmessages = array();
446 if (empty($user->rights->societe)) {
447 $user->rights->societe =
new stdClass();
449 if (empty($user->rights->facture)) {
450 $user->rights->facture =
new stdClass();
451 $user->rights->facture->invoice_advance =
new stdClass();
453 if (empty($user->rights->adherent)) {
454 $user->rights->adherent =
new stdClass();
455 $user->rights->adherent->cotisation =
new stdClass();
457 $user->rights->societe->creer = 1;
458 $user->rights->facture->creer = 1;
459 $user->rights->facture->invoice_advance->validate = 1;
460 $user->rights->adherent->cotisation->creer = 1;
462 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
469 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
470 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
471 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
475 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
476 $result2 = $adht->fetch(
$object->typeid);
478 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
479 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
481 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
483 if ($result1 > 0 && $result2 > 0) {
485 if ($paymentmethod ==
'paybox') {
488 if ($paymentmethod ==
'paypal') {
491 if ($paymentmethod ==
'stripe') {
494 if (empty($paymentTypeId)) {
495 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
497 if (empty($paymentType)) {
502 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
505 if (empty($paymentTypeId) || $paymentTypeId < 0) {
510 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
513 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
515 if (empty($adht->caneditamount)) {
516 if (
$object->status == $object::STATUS_DRAFT) {
518 $amountbytype = $adht->amountByType(1);
522 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
532 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
534 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
536 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') propagated by payment page differs from the expected value for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
537 $postactionmessages[] = $errmsg;
538 $ispostactionok = -1;
539 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
548 $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 ?';
549 $postactionmessages[] = $errmsg;
550 $ispostactionok = -1;
551 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
556 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
558 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
559 $postactionmessages[] = $errmsg;
560 $ispostactionok = -1;
561 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
566 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
567 if ($result < 0 || empty(
$object->datevalid)) {
570 $postactionmessages[] = $errmsg;
571 $postactionmessages = array_merge($postactionmessages,
$object->errors);
572 $ispostactionok = -1;
573 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
578 $datesubscription =
$object->datevalid;
595 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
598 while ($datesubend < $now) {
600 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
607 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? $mysoc->default_lang :
$object->thirdparty->default_lang);
609 $amount = $FinalPaymentAmt;
610 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
611 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
615 if ($paymentmethod ==
'paybox') {
618 if ($paymentmethod ==
'paypal') {
621 if ($paymentmethod ==
'stripe') {
627 'paymentmethod' => $paymentmethod,
629 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
631 if (isset($hookmanager->resArray[
'bankaccountid'])) {
632 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
633 $accountid = $hookmanager->resArray[
'bankaccountid'];
636 if ($accountid < 0) {
638 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
639 $postactionmessages[] = $errmsg;
640 $ispostactionok = -1;
641 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
644 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
647 $emetteur_banque =
'';
650 if (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankviainvoice' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
651 $option =
'bankviainvoice';
652 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankdirect' && isModEnabled(
"bank")) {
653 $option =
'bankdirect';
654 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'invoiceonly' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
655 $option =
'invoiceonly';
657 if (empty($option)) {
667 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
669 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
673 $postactionmessages[] = $errmsg;
674 $ispostactionok = -1;
676 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
682 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
684 $autocreatethirdparty = 1;
686 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
691 $postactionmessages[] =
$object->error;
692 $postactionmessages = array_merge($postactionmessages,
$object->errors);
693 $ispostactionok = -1;
695 if ($option ==
'bankviainvoice') {
696 $postactionmessages[] =
'Invoice, payment and bank record created';
697 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
699 if ($option ==
'bankdirect') {
700 $postactionmessages[] =
'Bank record created';
701 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
703 if ($option ==
'invoiceonly') {
704 $postactionmessages[] =
'Invoice recorded';
705 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
715 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
718 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
720 $service =
'StripeTest';
723 $service =
'StripeLive';
728 $thirdparty =
new Societe($db);
729 $thirdparty->fetch($thirdparty_id);
731 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
732 $stripe =
new Stripe($db);
735 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
737 if (!$customer && $TRANSACTIONID) {
738 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
741 global $stripearrayofkeysbyenv;
742 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
744 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
746 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
749 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
753 $stripecu = $chpi->customer;
755 if (empty($stripecu)) {
757 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
760 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
761 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
764 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
765 $sql .=
" VALUES (".((int) $thirdparty_id).
", '', '".$db->escape($stripecu).
"', 'stripe', '".$db->escape($stripearrayofkeysbyenv[$servicestatus][
'publishable_key']).
"', ".((int) $servicestatus).
", ".((int)
$conf->entity).
", '".$db->idate(
dol_now()).
"', 0)";
766 $resql = $db->query($sql);
769 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
771 $postactionmessages[] = $errmsg;
772 $ispostactionok = -1;
777 $errmsg =
'Failed to retrieve paymentintent or charge from id';
779 $postactionmessages[] = $errmsg;
780 $ispostactionok = -1;
784 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
786 $postactionmessages[] = $errmsg;
787 $ispostactionok = -1;
804 $nuser =
new User($db);
809 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
810 $resqlcount = $db->query($sql);
812 $objcount = $db->fetch_object($resqlcount);
814 $found = $objcount->nb;
819 $result = $nuser->create_from_member($tmpuser,
$object->login);
820 $newpassword = $nuser->setPassword($user,
'');
823 $outputlangs->load(
"errors");
824 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
826 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
827 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
830 $outputlangs->load(
"errors");
831 $postactionmessages[] =
'No user created because a user linked to member already exists';
837 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
840 if (
$object->email && $sendalsoemail) {
845 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
848 $outputlangs->loadLangs(array(
"main",
"members"));
850 $arraydefaultmessage =
null;
853 if (!empty($labeltouse)) {
854 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
857 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
858 $subject = $arraydefaultmessage->topic;
859 $msg = $arraydefaultmessage->content;
864 if ($infouserlogin) {
865 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
874 $listofpaths = array();
875 $listofnames = array();
876 $listofmimes = array();
877 if (is_object(
$object->invoice)) {
878 $invoicediroutput =
$conf->facture->dir_output;
880 $file = $fileparams[
'fullname'];
882 $listofpaths = array($file);
883 $listofnames = array(basename($file));
887 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
889 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
893 $postactionmessages[] = $errmsg;
894 $ispostactionok = -1;
897 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
899 $postactionmessages[] =
'Email sent to member (without any attached document)';
907 $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.';
908 $ispostactionok = -1;
911 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
912 $ispostactionok = -1;
914 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
916 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
918 $result =
$object->fetch((
int) $tmptag[
'INV']);
920 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
923 if ($paymentmethod ===
'paybox') {
926 if ($paymentmethod ===
'paypal') {
929 if ($paymentmethod ===
'stripe') {
932 if (empty($paymentTypeId)) {
933 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
935 if (empty($paymentType)) {
940 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
943 if (empty($paymentTypeId) || $paymentTypeId < 0) {
948 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
951 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
955 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
957 $paiement->datepaye = $now;
958 if ($currencyCodeType ==
$conf->currency) {
959 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
961 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
963 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
964 $ispostactionok = -1;
967 $paiement->paiementid = $paymentTypeId;
968 $paiement->num_payment =
'';
969 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
970 $paiement->ext_payment_id = $TRANSACTIONID;
972 $paiement->ext_payment_site = $service;
975 $paiement_id = $paiement->create($user, 1);
976 if ($paiement_id < 0) {
977 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
978 $ispostactionok = -1;
981 $postactionmessages[] =
'Payment created';
986 if (!$error && isModEnabled(
"bank")) {
988 if ($paymentmethod ==
'paybox') {
990 } elseif ($paymentmethod ==
'paypal') {
992 } elseif ($paymentmethod ==
'stripe') {
998 'paymentmethod' => $paymentmethod,
1000 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1001 if ($reshook >= 0) {
1002 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1003 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1004 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1007 if ($bankaccountid > 0) {
1008 $label =
'(CustomerInvoicePayment)';
1010 $label =
'(CustomerInvoicePaymentBack)';
1012 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1014 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1015 $ispostactionok = -1;
1018 $postactionmessages[] =
'Bank transaction of payment created';
1019 $ispostactionok = 1;
1022 $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.';
1023 $ispostactionok = -1;
1034 $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.';
1035 $ispostactionok = -1;
1038 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1039 $ispostactionok = -1;
1041 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1042 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1044 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1046 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1048 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1051 if ($paymentmethod ==
'paybox') {
1054 if ($paymentmethod ==
'paypal') {
1057 if ($paymentmethod ==
'stripe') {
1060 if (empty($paymentTypeId)) {
1061 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1063 if (empty($paymentType)) {
1064 $paymentType =
'CB';
1068 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1071 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1076 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1079 if (isModEnabled(
'invoice')) {
1080 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1083 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1085 $result = $invoice->createFromOrder($object, $user);
1087 if ($FinalPaymentAmt !=
$object->total_ttc) {
1095 $object->classifyBilled($user);
1097 $invoice->validate($user);
1100 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1102 $paiement->datepaye = $now;
1103 if ($currencyCodeType ==
$conf->currency) {
1104 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1106 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1108 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1109 $ispostactionok = -1;
1112 $paiement->paiementid = $paymentTypeId;
1113 $paiement->num_payment =
'';
1114 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1115 $paiement->ext_payment_id = $TRANSACTIONID;
1116 $paiement->ext_payment_site = $service;
1119 $paiement_id = $paiement->create($user, 1);
1120 if ($paiement_id < 0) {
1121 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1122 $ispostactionok = -1;
1125 $postactionmessages[] =
'Payment created';
1126 $ispostactionok = 1;
1130 if (!$error && isModEnabled(
"bank")) {
1132 if ($paymentmethod ==
'paybox') {
1134 } elseif ($paymentmethod ==
'paypal') {
1136 } elseif ($paymentmethod ==
'stripe') {
1142 'paymentmethod' => $paymentmethod,
1144 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1145 if ($reshook >= 0) {
1146 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1147 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1148 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1151 if ($bankaccountid > 0) {
1152 $label =
'(CustomerInvoicePayment)';
1154 $label =
'(CustomerInvoicePaymentBack)';
1156 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1158 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1159 $ispostactionok = -1;
1162 $postactionmessages[] =
'Bank transaction of payment created';
1163 $ispostactionok = 1;
1166 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1167 $ispostactionok = -1;
1172 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1173 $ispostactionok = -1;
1183 $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.';
1184 $ispostactionok = -1;
1187 $postactionmessages[] =
'Invoice module is not enable';
1188 $ispostactionok = -1;
1191 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1192 $ispostactionok = -1;
1194 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1195 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1196 $don =
new Don($db);
1197 $result = $don->fetch((
int) $tmptag[
'DON']);
1200 if ($paymentmethod ==
'paybox') {
1203 if ($paymentmethod ==
'paypal') {
1204 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1206 if ($paymentmethod ==
'stripe') {
1209 if (empty($paymentTypeId)) {
1210 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1212 if (empty($paymentType)) {
1213 $paymentType =
'CB';
1217 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1220 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1226 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1230 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1233 $totalpaid = $FinalPaymentAmt;
1235 if ($currencyCodeType ==
$conf->currency) {
1236 $paiement->amounts = array(
$object->id => $totalpaid);
1239 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1240 $ispostactionok = -1;
1244 $paiement->fk_donation = $don->id;
1245 $paiement->datep = $now;
1246 $paiement->paymenttype = $paymentTypeId;
1247 $paiement->num_payment =
'';
1248 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1249 $paiement->ext_payment_id = $TRANSACTIONID;
1250 $paiement->ext_payment_site = $service;
1253 $paiement_id = $paiement->create($user, 1);
1254 if ($paiement_id < 0) {
1255 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1256 $ispostactionok = -1;
1259 $postactionmessages[] =
'Payment created';
1260 $ispostactionok = 1;
1262 if ($totalpaid >= $don->getRemainToPay()) {
1263 $don->setPaid($don->id);
1268 if (!$error && isModEnabled(
"bank")) {
1270 if ($paymentmethod ==
'paybox') {
1272 } elseif ($paymentmethod ==
'paypal') {
1274 } elseif ($paymentmethod ==
'stripe') {
1280 'paymentmethod' => $paymentmethod,
1282 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1283 if ($reshook >= 0) {
1284 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1285 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1286 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1289 if ($bankaccountid > 0) {
1290 $label =
'(DonationPayment)';
1291 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1293 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1294 $ispostactionok = -1;
1297 $postactionmessages[] =
'Bank transaction of payment created';
1298 $ispostactionok = 1;
1301 $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.';
1302 $ispostactionok = -1;
1313 $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.';
1314 $ispostactionok = -1;
1317 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1318 $ispostactionok = -1;
1323 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1325 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1326 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1327 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1329 $result =
$object->fetch($ref);
1332 if ($paymentmethod ==
'paybox') {
1335 if ($paymentmethod ==
'paypal') {
1338 if ($paymentmethod ==
'stripe') {
1341 if (empty($paymentTypeId)) {
1342 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1344 if (empty($paymentType)) {
1345 $paymentType =
'CB';
1349 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1352 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1358 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1359 $resultvalidate =
$object->validate($user);
1360 if ($resultvalidate < 0) {
1361 $postactionmessages[] =
'Cannot validate invoice';
1362 $ispostactionok = -1;
1368 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1370 $paiement->datepaye = $now;
1371 if ($currencyCodeType ==
$conf->currency) {
1372 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1374 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1376 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1377 $ispostactionok = -1;
1380 $paiement->paiementid = $paymentTypeId;
1381 $paiement->num_payment =
'';
1382 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1383 $paiement->ext_payment_id = $TRANSACTIONID;
1384 $paiement->ext_payment_site = $service;
1387 $paiement_id = $paiement->create($user, 1);
1388 if ($paiement_id < 0) {
1389 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1390 $ispostactionok = -1;
1393 $postactionmessages[] =
'Payment created';
1394 $ispostactionok = 1;
1398 if (!$error && isModEnabled(
"bank")) {
1400 if ($paymentmethod ==
'paybox') {
1402 } elseif ($paymentmethod ==
'paypal') {
1404 } elseif ($paymentmethod ==
'stripe') {
1410 'paymentmethod' => $paymentmethod,
1412 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1413 if ($reshook >= 0) {
1414 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1415 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1416 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1419 if ($bankaccountid > 0) {
1420 $label =
'(CustomerInvoicePayment)';
1422 $label =
'(CustomerInvoicePaymentBack)';
1424 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1426 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1427 $ispostactionok = -1;
1430 $postactionmessages[] =
'Bank transaction of payment created';
1431 $ispostactionok = 1;
1434 $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.';
1435 $ispostactionok = -1;
1444 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1445 if ($resultattendee < 0) {
1449 $attendeetovalidate->validate($user);
1451 $attendeetovalidate->amount = $FinalPaymentAmt;
1452 $attendeetovalidate->date_subscription =
dol_now();
1453 $attendeetovalidate->update($user);
1467 $thirdparty =
new Societe($db);
1468 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1469 if ($resultthirdparty < 0) {
1470 setEventMessages($resultthirdparty->error, $resultthirdparty->errors,
"errors");
1472 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1473 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1477 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1479 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1481 $arraydefaultmessage =
null;
1483 $idoftemplatetouse =
getDolGlobalString(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1485 if (!empty($idoftemplatetouse)) {
1486 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1489 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1490 $subject = $arraydefaultmessage->topic;
1491 $msg = $arraydefaultmessage->content;
1493 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1494 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1503 $sendto = $attendeetovalidate->email;
1505 if ($thirdparty->email) {
1506 $cc = $thirdparty->email;
1508 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1509 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1514 $urlback = $_SERVER[
"REQUEST_URI"];
1520 $listofpaths = array();
1521 $listofnames = array();
1522 $listofmimes = array();
1523 if (is_object($object)) {
1524 $invoicediroutput =
$conf->facture->dir_output;
1526 $file = $fileparams[
'fullname'];
1528 $listofpaths = array($file);
1529 $listofnames = array(basename($file));
1533 $trackid =
'inv'.$object->id;
1535 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1537 $result = $mailfile->sendfile();
1539 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1541 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1547 $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.';
1548 $ispostactionok = -1;
1551 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1552 $ispostactionok = -1;
1554 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1556 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1557 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1558 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1560 $result =
$object->fetch($ref);
1562 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1565 if ($paymentmethod ==
'paybox') {
1568 if ($paymentmethod ==
'paypal') {
1571 if ($paymentmethod ==
'stripe') {
1574 if (empty($paymentTypeId)) {
1575 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1577 if (empty($paymentType)) {
1578 $paymentType =
'CB';
1582 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1585 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1591 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1592 $resultvalidate =
$object->validate($user);
1593 if ($resultvalidate < 0) {
1594 $postactionmessages[] =
'Cannot validate invoice';
1595 $ispostactionok = -1;
1601 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1603 $paiement->datepaye = $now;
1604 if ($currencyCodeType ==
$conf->currency) {
1605 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1607 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1609 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1610 $ispostactionok = -1;
1613 $paiement->paiementid = $paymentTypeId;
1614 $paiement->num_payment =
'';
1615 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1616 $paiement->ext_payment_id = $TRANSACTIONID;
1617 $paiement->ext_payment_site = $service;
1620 $paiement_id = $paiement->create($user, 1);
1621 if ($paiement_id < 0) {
1622 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1623 $ispostactionok = -1;
1626 $postactionmessages[] =
'Payment created';
1627 $ispostactionok = 1;
1631 if (!$error && isModEnabled(
"bank")) {
1633 if ($paymentmethod ==
'paybox') {
1635 } elseif ($paymentmethod ==
'paypal') {
1637 } elseif ($paymentmethod ==
'stripe') {
1643 'paymentmethod' => $paymentmethod,
1645 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1646 if ($reshook >= 0) {
1647 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1648 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1649 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1652 if ($bankaccountid > 0) {
1653 $label =
'(CustomerInvoicePayment)';
1655 $label =
'(CustomerInvoicePaymentBack)';
1657 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1659 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1660 $ispostactionok = -1;
1663 $postactionmessages[] =
'Bank transaction of payment created';
1664 $ispostactionok = 1;
1667 $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.';
1668 $ispostactionok = -1;
1675 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1676 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1678 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1679 if ($resultbooth < 0) {
1683 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1684 $resultboothupdate = $booth->update($user);
1685 if ($resultboothupdate<0) {
1688 $resultinvoice = $invoice->fetch($ref);
1689 if ($resultinvoice<0) {
1690 $postactionmessages[] =
'Could not find the associated invoice.';
1691 $ispostactionok = -1;
1694 $thirdparty =
new Societe($db);
1695 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1696 if ($resultthirdparty<0) {
1703 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1704 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1708 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1710 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1712 $arraydefaultmessage =
null;
1714 $idoftemplatetouse =
getDolGlobalString(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1716 if (!empty($idoftemplatetouse)) {
1717 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1720 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1721 $subject = $arraydefaultmessage->topic;
1722 $msg = $arraydefaultmessage->content;
1724 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1725 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1734 $sendto = $thirdparty->email;
1736 $urlback = $_SERVER[
"REQUEST_URI"];
1739 $trackid =
'inv'.$invoice->id;
1741 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1743 $result = $mailfile->sendfile();
1745 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1747 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1762 $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.';
1763 $ispostactionok = -1;
1766 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1767 $ispostactionok = -1;
1769 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1770 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1772 $result =
$object->fetch((
int) $tmptag[
'CON']);
1774 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1777 if ($paymentmethod ==
'paybox') {
1780 if ($paymentmethod ==
'paypal') {
1783 if ($paymentmethod ==
'stripe') {
1786 if (empty($paymentTypeId)) {
1787 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1789 if (empty($paymentType)) {
1790 $paymentType =
'CB';
1794 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1797 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1802 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1803 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1806 if (isModEnabled(
'invoice')) {
1807 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1810 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1812 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1815 $invoice->validate($user);
1817 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1819 $paiement->datepaye = $now;
1820 if ($currencyCodeType ==
$conf->currency) {
1821 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1823 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1825 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1826 $ispostactionok = -1;
1829 $paiement->paiementid = $paymentTypeId;
1830 $paiement->num_payment =
'';
1831 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1832 $paiement->ext_payment_id = $TRANSACTIONID;
1833 $paiement->ext_payment_site = $service;
1836 $paiement_id = $paiement->create($user, 1);
1837 if ($paiement_id < 0) {
1838 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1839 $ispostactionok = -1;
1842 $postactionmessages[] =
'Payment created';
1843 $ispostactionok = 1;
1847 if (!$error && isModEnabled(
"bank")) {
1849 if ($paymentmethod ==
'paybox') {
1851 } elseif ($paymentmethod ==
'paypal') {
1853 } elseif ($paymentmethod ==
'stripe') {
1859 'paymentmethod' => $paymentmethod,
1861 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1862 if ($reshook >= 0) {
1863 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1864 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1865 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1868 if ($bankaccountid > 0) {
1869 $label =
'(CustomerInvoicePayment)';
1871 $label =
'(CustomerInvoicePaymentBack)';
1873 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1875 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1876 $ispostactionok = -1;
1879 $postactionmessages[] =
'Bank transaction of payment created';
1880 $ispostactionok = 1;
1883 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1884 $ispostactionok = -1;
1889 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1890 if (!empty($tmptag[
'COL'])) {
1891 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
1893 $postactionmessages[] = $msg;
1894 $ispostactionok = -1;
1904 $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.';
1905 $ispostactionok = -1;
1908 $postactionmessages[] =
'Invoice module is not enable';
1909 $ispostactionok = -1;
1912 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
1913 if (!empty($tmptag[
'COL'])) {
1914 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
1916 $postactionmessages[] = $msg;
1917 $ispostactionok = -1;
1924dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
1928 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1929 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1931 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
1932 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'': $_SESSION[
"FinalPaymentAmt"];
1933 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
1935 if (is_object($object) && method_exists($object,
'call_trigger')) {
1937 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1942 } elseif (get_class($object) ==
'stdClass') {
1944 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1946 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1955if (empty($doactionsthenredirect)) {
1957 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
1958 if ($TRANSACTIONID) {
1959 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
1963 print
img_picto(
'',
'tick',
'class="green fa-2x"');
1967 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
1973 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
1974 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
1975 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
1976 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
1977 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
1979 if ($mysoc->email) {
1980 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
1992 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
1997 $myCompanyDefaultLang = $mysoc->default_lang;
1998 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2005 $companylangs->setDefaultLang($myCompanyDefaultLang);
2006 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2008 $sendto = $sendemail;
2011 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2012 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2017 $urlback = $_SERVER[
"REQUEST_URI"];
2018 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2020 if (array_key_exists(
'MEM', $tmptag)) {
2021 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2022 $content .=
'<strong>'.$companylangs->trans(
"PaymentSubscription").
"</strong><br><br>\n";
2023 $content .= $companylangs->trans(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2024 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2025 } elseif (array_key_exists(
'INV', $tmptag)) {
2026 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2027 $content .=
'<strong>'.$companylangs->trans(
"Payment").
"</strong><br><br>\n";
2028 $content .= $companylangs->trans(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2030 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2032 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2034 $content .= $companylangs->transnoentities(
"PostActionAfterPayment").
' : ';
2035 if ($ispostactionok > 0) {
2037 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2038 } elseif ($ispostactionok == 0) {
2039 $content .= $companylangs->transnoentitiesnoconv(
"None");
2041 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2042 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2044 $content .=
'<br>'.
"\n";
2045 foreach ($postactionmessages as $postactionmessage) {
2046 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2048 if ($ispostactionok < 0) {
2049 $content .= $langs->transnoentities(
"ARollbackWasPerformedOnPostActions");
2051 $content .=
'<br>'.
"\n";
2053 $content .=
"<br>\n";
2054 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2055 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2056 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2057 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2058 $content .=
"<br>\n";
2059 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2061 if (!empty($ErrorCode)) {
2062 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2064 if (!empty($ErrorShortMsg)) {
2065 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2067 if (!empty($ErrorLongMsg)) {
2068 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2070 if (!empty($ErrorSeverityCode)) {
2071 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2074 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2079 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2080 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2082 $result = $mailfile->sendfile();
2084 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2087 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2095 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2096 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2098 $paymentType = $_SESSION[
'PaymentType'];
2099 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2100 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2102 if (is_object($object) && method_exists($object,
'call_trigger')) {
2104 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2114 $companylangs->setDefaultLang($mysoc->default_lang);
2115 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2117 $sendto = $sendemail;
2120 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2121 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2124 $urlback = $_SERVER[
"REQUEST_URI"];
2125 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2127 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2129 $content .=
"<br><br>\n";
2130 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2131 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2132 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2133 $content .=
"<br>\n";
2134 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2140 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2141 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2143 $result = $mailfile->sendfile();
2145 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2147 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2154unset($_SESSION[
"FinalPaymentAmt"]);
2155unset($_SESSION[
"TRANSACTIONID"]);
2159if (empty($doactionsthenredirect)) {
2162 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag($paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2167if (empty($doactionsthenredirect)) {
2178if (!empty($doactionsthenredirect)) {
2182 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2185 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2186 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2188 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2191 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2192 header(
"Location: ".$ext_urlok);
2197 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2200 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2201 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2203 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2206 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2207 header(
"Location: ".$ext_urlko);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage donations.
Class to manage invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to 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 public pages.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.