32if (!defined(
'NOLOGIN')) {
35if (!defined(
'NOCSRFCHECK')) {
36 define(
"NOCSRFCHECK", 1);
38if (!defined(
'NOIPCHECK')) {
39 define(
'NOIPCHECK',
'1');
41if (!defined(
'NOBROWSERNOTIF')) {
42 define(
'NOBROWSERNOTIF',
'1');
48$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
49if (is_numeric($entity)) {
50 define(
"DOLENTITY", $entity);
54require
'../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
57if (isModEnabled(
'paypal')) {
58 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
59 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
65$hookmanager->initHooks(array(
'newpayment'));
67$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal"));
70if (isModEnabled(
'paypal')) {
71 $PAYPAL_API_USER =
"";
72 if (!empty($conf->global->PAYPAL_API_USER)) {
73 $PAYPAL_API_USER = $conf->global->PAYPAL_API_USER;
75 $PAYPAL_API_PASSWORD =
"";
76 if (!empty($conf->global->PAYPAL_API_PASSWORD)) {
77 $PAYPAL_API_PASSWORD = $conf->global->PAYPAL_API_PASSWORD;
79 $PAYPAL_API_SIGNATURE =
"";
80 if (!empty($conf->global->PAYPAL_API_SIGNATURE)) {
81 $PAYPAL_API_SIGNATURE = $conf->global->PAYPAL_API_SIGNATURE;
83 $PAYPAL_API_SANDBOX =
"";
84 if (!empty($conf->global->PAYPAL_API_SANDBOX)) {
85 $PAYPAL_API_SANDBOX = $conf->global->PAYPAL_API_SANDBOX;
89 $PAYPAL_API_OK = $urlok;
93 $PAYPAL_API_KO = $urlko;
96 $PAYPALTOKEN =
GETPOST(
'TOKEN');
97 if (empty($PAYPALTOKEN)) {
98 $PAYPALTOKEN =
GETPOST(
'token');
100 $PAYPALPAYERID =
GETPOST(
'PAYERID');
101 if (empty($PAYPALPAYERID)) {
102 $PAYPALPAYERID =
GETPOST(
'PayerID');
107if (empty($FULLTAG)) {
113$suffix =
GETPOST(
"suffix",
'aZ09');
114$membertypeid =
GETPOST(
"membertypeid",
'int');
120if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
121 $paymentmethod = $reg[1];
123if (empty($paymentmethod)) {
124 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
125 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
129dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
132$validpaymentmethod = array();
133if (isModEnabled(
'paypal')) {
134 $validpaymentmethod[
'paypal'] =
'paypal';
136if (isModEnabled(
'paybox')) {
137 $validpaymentmethod[
'paybox'] =
'paybox';
139if (isModEnabled(
'stripe')) {
140 $validpaymentmethod[
'stripe'] =
'stripe';
144if (empty($validpaymentmethod)) {
151$PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
153$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
156$object =
new stdClass();
173dol_syslog(
"Callback url when a payment was done. query_string=".(empty($_SERVER[
"QUERY_STRING"]) ?
'' :
dol_escape_htmltag($_SERVER[
"QUERY_STRING"])).
" script_uri=".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SCRIPT_URI"])), LOG_DEBUG, 0,
'_payment');
174dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
175dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
178foreach ($_POST as $k => $v) {
179 if (is_scalar($k) && is_scalar($v)) {
180 $tracepost .=
"$k - $v\n";
183dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
185foreach ($_SESSION as $k => $v) {
186 if (is_scalar($k) && is_scalar($v)) {
187 $tracesession .=
"$k - $v\n";
190dol_syslog(
"SESSION=".$tracesession, LOG_DEBUG, 0,
'_payment');
193if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
194 $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'?lang='.$langs->defaultlang.
'">'.
"\n";
197$conf->dol_hide_topmenu = 1;
198$conf->dol_hide_leftmenu = 1;
200$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
201llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
205print
'<span id="dolpaymentspan"></span>'.
"\n";
206print
'<div id="dolpaymentdiv" class="center">'.
"\n";
211$logosmall = $mysoc->logo_small;
213$paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
214if (!empty($conf->global->$paramlogo)) {
215 $logosmall = $conf->global->$paramlogo;
216} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
217 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
223if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
224 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
225 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
226} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
227 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
228 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
233 print
'<div class="backgreypublicpayment">';
234 print
'<div class="logopublicpayment">';
235 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
238 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
239 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
243if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
244 print
'<div class="backimagepublicpayment">';
245 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.$conf->global->MAIN_IMAGE_PUBLIC_PAYMENT.
'">';
253if (isModEnabled(
'paypal')) {
254 if ($paymentmethod ===
'paypal') {
257 $onlinetoken = $PAYPALTOKEN;
259 $payerID = $PAYPALPAYERID;
261 $currencyCodeType = $_SESSION[
'currencyCodeType'];
262 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
263 $paymentType = $_SESSION[
'PaymentType'];
265 $ipaddress = $_SESSION[
'ipaddress'];
267 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
270 if (!empty($paymentType)) {
271 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
275 $ack = strtoupper($resArray[
"ACK"]);
276 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
278 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
280 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING,
'_payment');
283 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
284 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
287 $ack = strtoupper($resArray2[
"ACK"]);
288 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
289 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
291 $object->source = $source;
293 $object->payerID = $payerID;
294 $object->fulltag = $fulltag;
295 $object->resArray = $resArray2;
299 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
300 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
301 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
302 $NOTE = urldecode($resArray2[
"NOTE"]);
306 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
309 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
310 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
311 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
312 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
315 $ErrorCode =
"SESSIONEXPIRED";
316 $ErrorLongMsg =
"Session expired. Can't retreive PaymentType. Payment has not been validated.";
317 $ErrorShortMsg =
"Session expired";
319 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
323 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
324 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
325 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
327 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
333if (isModEnabled(
'paybox')) {
334 if ($paymentmethod ===
'paybox') {
340if (isModEnabled(
'stripe')) {
341 if ($paymentmethod ===
'stripe') {
350 'paymentmethod' => $paymentmethod,
352$reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
354 if (isset($hookmanager->resArray[
'ispaymentok'])) {
355 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
356 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
362if (empty($ipaddress)) {
363 $ipaddress = $_SESSION[
'ipaddress'];
365if (empty($TRANSACTIONID)) {
366 $TRANSACTIONID = $_SESSION[
'TRANSACTIONID'];
367 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
369 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
372if (empty($FinalPaymentAmt)) {
373 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
375if (empty($currencyCodeType)) {
376 $currencyCodeType = $_SESSION[
'currencyCodeType'];
379if (empty($paymentType)) {
380 $paymentType = $_SESSION[
"paymentType"];
387dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
392$postactionmessages = array();
395 if (empty($user->rights->societe)) {
396 $user->rights->societe =
new stdClass();
398 if (empty($user->rights->facture)) {
399 $user->rights->facture =
new stdClass();
400 $user->rights->facture->invoice_advance =
new stdClass();
402 if (empty($user->rights->adherent)) {
403 $user->rights->adherent =
new stdClass();
404 $user->rights->adherent->cotisation =
new stdClass();
406 $user->rights->societe->creer = 1;
407 $user->rights->facture->creer = 1;
408 $user->rights->facture->invoice_advance->validate = 1;
409 $user->rights->adherent->cotisation->creer = 1;
411 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
418 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
419 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
420 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
424 $result1 = $object->fetch((
int) $tmptag[
'MEM']);
425 $result2 = $adht->fetch($object->typeid);
427 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
428 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
430 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
432 if ($result1 > 0 && $result2 > 0) {
434 if ($paymentmethod ==
'paybox') {
435 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
437 if ($paymentmethod ==
'paypal') {
438 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
440 if ($paymentmethod ==
'stripe') {
441 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
443 if (empty($paymentTypeId)) {
444 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
446 if (empty($paymentType)) {
451 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
454 if (empty($paymentTypeId) || $paymentTypeId < 0) {
459 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
462 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
464 if (empty($adht->caneditamount)) {
465 if ($object->status == $object::STATUS_DRAFT) {
466 $typeid = $object->typeid;
470 $amountbytype = $adht->amountByType(1);
471 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
473 if (empty($amountexpected) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) {
474 $amountexpected = $conf->global->MEMBER_NEWFORM_AMOUNT;
477 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
479 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') differs from value expected for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
480 $postactionmessages[] = $errmsg;
481 $ispostactionok = -1;
482 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
488 if (!empty($conf->global->MEMBER_MIN_AMOUNT)) {
489 if ($FinalPaymentAmt < $conf->global->MEMBER_MIN_AMOUNT) {
491 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed ('.$conf->global->MEMBER_MIN_AMOUNT.
'). May be a hack to try to pay a different amount ?';
492 $postactionmessages[] = $errmsg;
493 $ispostactionok = -1;
494 dol_syslog(
"Failed to validate member (amount lower than minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
499 if ($currencyCodeType && $currencyCodeType != $conf->currency) {
501 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.$conf->currency.
'). May be a hack to try to pay a different amount ?';
502 $postactionmessages[] = $errmsg;
503 $ispostactionok = -1;
504 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
509 $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user);
510 if ($result < 0 || empty($object->datevalid)) {
512 $errmsg = $object->error;
513 $postactionmessages[] = $errmsg;
514 $postactionmessages = array_merge($postactionmessages, $object->errors);
515 $ispostactionok = -1;
516 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
521 $datesubscription = $object->datevalid;
522 if ($object->datefin > 0) {
527 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
530 while ($datesubend < $now) {
532 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
539 $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
541 $amount = $FinalPaymentAmt;
542 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
543 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
547 if ($paymentmethod ==
'paybox') {
548 $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
550 if ($paymentmethod ==
'paypal') {
551 $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
553 if ($paymentmethod ==
'stripe') {
554 $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
556 if ($accountid < 0) {
558 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
559 $postactionmessages[] = $errmsg;
560 $ispostactionok = -1;
561 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
564 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
567 $emetteur_banque =
'';
570 if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankviainvoice' && isModEnabled(
"banque") && isModEnabled(
"societe") && isModEnabled(
'facture')) {
571 $option =
'bankviainvoice';
572 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'bankdirect' && isModEnabled(
"banque")) {
573 $option =
'bankdirect';
574 } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE ==
'invoiceonly' && isModEnabled(
"banque") && isModEnabled(
"societe") && isModEnabled(
'facture')) {
575 $option =
'invoiceonly';
577 if (empty($option)) {
587 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
589 $crowid = $object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
592 $errmsg = $object->error;
593 $postactionmessages[] = $errmsg;
594 $ispostactionok = -1;
596 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
602 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
604 $autocreatethirdparty = 1;
606 $result = $object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
608 dol_syslog(
"Error ".$object->error.
" ".join(
',', $object->errors), LOG_DEBUG, 0,
'_payment');
611 $postactionmessages[] = $object->error;
612 $postactionmessages = array_merge($postactionmessages, $object->errors);
613 $ispostactionok = -1;
615 if ($option ==
'bankviainvoice') {
616 $postactionmessages[] =
'Invoice, payment and bank record created';
617 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
619 if ($option ==
'bankdirect') {
620 $postactionmessages[] =
'Bank record created';
621 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
623 if ($option ==
'invoiceonly') {
624 $postactionmessages[] =
'Invoice recorded';
625 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
634 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
635 $thirdparty_id = $object->fk_soc;
637 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
639 $service =
'StripeTest';
641 if (!empty($conf->global->STRIPE_LIVE) && !
GETPOST(
'forcesandbox',
'alpha')) {
642 $service =
'StripeLive';
647 $thirdparty =
new Societe($db);
648 $thirdparty->fetch($thirdparty_id);
650 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
651 $stripe =
new Stripe($db);
654 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
656 if (!$customer && $TRANSACTIONID) {
657 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
660 global $stripearrayofkeysbyenv;
661 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
663 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
665 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
668 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
672 $stripecu = $chpi->customer;
674 if (empty($stripecu)) {
676 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
679 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
680 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
683 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
684 $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)";
685 $resql = $db->query($sql);
688 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
690 $postactionmessages[] = $errmsg;
691 $ispostactionok = -1;
696 $errmsg =
'Failed to retreive paymentintent or charge from id';
698 $postactionmessages[] = $errmsg;
699 $ispostactionok = -1;
703 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
705 $postactionmessages[] = $errmsg;
706 $ispostactionok = -1;
720 dol_syslog(
"Send email to customer to ".$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
723 if ($object->email && $sendalsoemail) {
728 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
731 $outputlangs->loadLangs(array(
"main",
"members"));
733 $arraydefaultmessage =
null;
734 $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
736 if (!empty($labeltouse)) {
737 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
740 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
741 $subject = $arraydefaultmessage->topic;
742 $msg = $arraydefaultmessage->content;
748 if (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)) {
750 $nuser =
new User($db);
753 $result = $nuser->create_from_member($tmpuser, $object->login);
754 $newpassword = $nuser->setPassword($user,
'');
757 $outputlangs->load(
"errors");
758 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
760 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
761 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
763 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
772 $listofpaths = array();
773 $listofnames = array();
774 $listofmimes = array();
775 if (is_object($object->invoice)) {
776 $invoicediroutput = $conf->facture->dir_output;
777 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->invoice->ref, preg_quote($object->invoice->ref,
'/').
'[^\-]+');
778 $file = $fileparams[
'fullname'];
780 $listofpaths = array($file);
781 $listofnames = array(basename($file));
785 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
787 $result = $object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
790 $errmsg = $object->error;
791 $postactionmessages[] = $errmsg;
792 $ispostactionok = -1;
795 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
797 $postactionmessages[] =
'Email sent to member (without any attached document)';
805 $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.';
806 $ispostactionok = -1;
809 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
810 $ispostactionok = -1;
812 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
814 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
816 $result = $object->fetch((
int) $tmptag[
'INV']);
818 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
821 if ($paymentmethod ===
'paybox') {
822 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
824 if ($paymentmethod ===
'paypal') {
825 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
827 if ($paymentmethod ===
'stripe') {
828 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
830 if (empty($paymentTypeId)) {
831 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
833 if (empty($paymentType)) {
838 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
841 if (empty($paymentTypeId) || $paymentTypeId < 0) {
846 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
849 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
853 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
855 $paiement->datepaye = $now;
856 if ($currencyCodeType == $conf->currency) {
857 $paiement->amounts = array($object->id => $FinalPaymentAmt);
859 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
861 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
862 $ispostactionok = -1;
865 $paiement->paiementid = $paymentTypeId;
866 $paiement->num_payment =
'';
867 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
868 $paiement->ext_payment_id = $TRANSACTIONID;
870 $paiement->ext_payment_site = $service;
873 $paiement_id = $paiement->create($user, 1);
874 if ($paiement_id < 0) {
875 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
876 $ispostactionok = -1;
879 $postactionmessages[] =
'Payment created';
884 if (!$error && isModEnabled(
"banque")) {
886 if ($paymentmethod ==
'paybox') {
887 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
888 } elseif ($paymentmethod ==
'paypal') {
889 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
890 } elseif ($paymentmethod ==
'stripe') {
891 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
894 if ($bankaccountid > 0) {
895 $label =
'(CustomerInvoicePayment)';
897 $label =
'(CustomerInvoicePaymentBack)';
899 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
901 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
902 $ispostactionok = -1;
905 $postactionmessages[] =
'Bank transaction of payment created';
909 $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.';
910 $ispostactionok = -1;
921 $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.';
922 $ispostactionok = -1;
925 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
926 $ispostactionok = -1;
928 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
929 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
931 $result = $object->fetch((
int) $tmptag[
'ORD']);
933 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
936 if ($paymentmethod ==
'paybox') {
937 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
939 if ($paymentmethod ==
'paypal') {
940 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
942 if ($paymentmethod ==
'stripe') {
943 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
945 if (empty($paymentTypeId)) {
946 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
948 if (empty($paymentType)) {
953 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
956 if (empty($paymentTypeId) || $paymentTypeId < 0) {
962 if (isModEnabled(
'facture')) {
963 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0 ) {
964 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
966 $result = $invoice->createFromOrder($object, $user);
968 $object->classifyBilled($user);
969 $invoice->validate($user);
971 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
973 $paiement->datepaye = $now;
974 if ($currencyCodeType == $conf->currency) {
975 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
977 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
979 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
980 $ispostactionok = -1;
983 $paiement->paiementid = $paymentTypeId;
984 $paiement->num_payment =
'';
985 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
986 $paiement->ext_payment_id = $TRANSACTIONID;
987 $paiement->ext_payment_site = $service;
990 $paiement_id = $paiement->create($user, 1);
991 if ($paiement_id < 0) {
992 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
993 $ispostactionok = -1;
996 $postactionmessages[] =
'Payment created';
1001 if (!$error && isModEnabled(
"banque")) {
1003 if ($paymentmethod ==
'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1004 elseif ($paymentmethod ==
'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1005 elseif ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1007 if ($bankaccountid > 0) {
1008 $label =
'(CustomerInvoicePayment)';
1010 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1012 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1013 $ispostactionok = -1;
1016 $postactionmessages[] =
'Bank transaction of payment created';
1017 $ispostactionok = 1;
1020 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1021 $ispostactionok = -1;
1032 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1033 $ispostactionok = -1;
1036 $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.';
1037 $ispostactionok = -1;
1040 $postactionmessages[] =
'Invoice module is not enable';
1041 $ispostactionok = -1;
1044 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1045 $ispostactionok = -1;
1047 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1048 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1049 $don =
new Don($db);
1050 $result = $don->fetch((
int) $tmptag[
'DON']);
1053 if ($paymentmethod ==
'paybox') {
1054 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
1056 if ($paymentmethod ==
'paypal') {
1057 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
1059 if ($paymentmethod ==
'stripe') {
1060 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
1062 if (empty($paymentTypeId)) {
1063 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1065 if (empty($paymentType)) {
1066 $paymentType =
'CB';
1070 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1073 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1079 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1083 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1086 $totalpaid = $FinalPaymentAmt;
1088 if ($currencyCodeType == $conf->currency) {
1089 $paiement->amounts = array($object->id => $totalpaid);
1092 $postactionmessages[] =
'Payment donation can\'t be payed with diffent currency than '.$conf->currency;
1093 $ispostactionok = -1;
1097 $paiement->fk_donation = $don->id;
1098 $paiement->datep = $now;
1099 $paiement->paymenttype = $paymentTypeId;
1100 $paiement->num_payment =
'';
1101 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1102 $paiement->ext_payment_id = $TRANSACTIONID;
1103 $paiement->ext_payment_site = $service;
1106 $paiement_id = $paiement->create($user, 1);
1107 if ($paiement_id < 0) {
1108 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1109 $ispostactionok = -1;
1112 $postactionmessages[] =
'Payment created';
1113 $ispostactionok = 1;
1115 if ($totalpaid >= $don->getRemainToPay()) {
1116 $don->setPaid($don->id);
1121 if (!$error && isModEnabled(
"banque")) {
1123 if ($paymentmethod ==
'paybox') {
1124 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1125 } elseif ($paymentmethod ==
'paypal') {
1126 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1127 } elseif ($paymentmethod ==
'stripe') {
1128 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1131 if ($bankaccountid > 0) {
1132 $result = $paiement->addPaymentToBank($user,
'payment_donation',
'(DonationPayment)', $bankaccountid,
'',
'');
1134 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1135 $ispostactionok = -1;
1138 $postactionmessages[] =
'Bank transaction of payment created';
1139 $ispostactionok = 1;
1142 $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.';
1143 $ispostactionok = -1;
1154 $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.';
1155 $ispostactionok = -1;
1158 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1159 $ispostactionok = -1;
1164 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1166 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1167 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1168 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1170 $result = $object->fetch($ref);
1173 if ($paymentmethod ==
'paybox') {
1174 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
1176 if ($paymentmethod ==
'paypal') {
1177 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
1179 if ($paymentmethod ==
'stripe') {
1180 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
1182 if (empty($paymentTypeId)) {
1183 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1185 if (empty($paymentType)) {
1186 $paymentType =
'CB';
1190 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1193 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1199 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1200 $resultvalidate = $object->validate($user);
1201 if ($resultvalidate < 0) {
1202 $postactionmessages[] =
'Cannot validate invoice';
1203 $ispostactionok = -1;
1209 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1211 $paiement->datepaye = $now;
1212 if ($currencyCodeType == $conf->currency) {
1213 $paiement->amounts = array($object->id => $FinalPaymentAmt);
1215 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
1217 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1218 $ispostactionok = -1;
1221 $paiement->paiementid = $paymentTypeId;
1222 $paiement->num_payment =
'';
1223 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1224 $paiement->ext_payment_id = $TRANSACTIONID;
1225 $paiement->ext_payment_site = $service;
1228 $paiement_id = $paiement->create($user, 1);
1229 if ($paiement_id < 0) {
1230 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1231 $ispostactionok = -1;
1234 $postactionmessages[] =
'Payment created';
1235 $ispostactionok = 1;
1239 if (!$error && isModEnabled(
"banque")) {
1241 if ($paymentmethod ==
'paybox') {
1242 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1243 } elseif ($paymentmethod ==
'paypal') {
1244 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1245 } elseif ($paymentmethod ==
'stripe') {
1246 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1249 if ($bankaccountid > 0) {
1250 $label =
'(CustomerInvoicePayment)';
1252 $label =
'(CustomerInvoicePaymentBack)';
1254 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1256 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1257 $ispostactionok = -1;
1260 $postactionmessages[] =
'Bank transaction of payment created';
1261 $ispostactionok = 1;
1264 $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.';
1265 $ispostactionok = -1;
1273 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1274 if ($resultattendee < 0) {
1278 $attendeetovalidate->validate($user);
1280 $attendeetovalidate->amount = $FinalPaymentAmt;
1281 $attendeetovalidate->date_subscription =
dol_now();
1282 $attendeetovalidate->update($user);
1296 $thirdparty =
new Societe($db);
1297 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1298 if ($resultthirdparty < 0) {
1299 setEventMessages($resultthirdparty->error, $resultthirdparty->errors,
"errors");
1301 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1302 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1305 $outputlangs =
new Translate(
'', $conf);
1306 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1308 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1310 $arraydefaultmessage =
null;
1312 $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT;
1314 if (!empty($idoftemplatetouse)) {
1315 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1318 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1319 $subject = $arraydefaultmessage->topic;
1320 $msg = $arraydefaultmessage->content;
1322 $subject =
'['.$appli.
'] '.$object->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1323 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1332 $sendto = $attendeetovalidate->email;
1334 if ($thirdparty->email) {
1335 $cc = $thirdparty->email;
1337 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1338 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1341 $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM :
getDolGlobalString(
"MAIN_MAIL_EMAIL_FROM");
1343 $urlback = $_SERVER[
"REQUEST_URI"];
1349 $listofpaths = array();
1350 $listofnames = array();
1351 $listofmimes = array();
1352 if (is_object($object)) {
1353 $invoicediroutput = $conf->facture->dir_output;
1354 $fileparams =
dol_most_recent_file($invoicediroutput.
'/'.$object->ref, preg_quote($object->ref,
'/').
'[^\-]+');
1355 $file = $fileparams[
'fullname'];
1357 $listofpaths = array($file);
1358 $listofnames = array(basename($file));
1362 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, $ishtml);
1364 $result = $mailfile->sendfile();
1366 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1368 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1374 $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.';
1375 $ispostactionok = -1;
1378 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1379 $ispostactionok = -1;
1381 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1383 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1384 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1385 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1387 $result = $object->fetch($ref);
1389 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1392 if ($paymentmethod ==
'paybox') {
1393 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
1395 if ($paymentmethod ==
'paypal') {
1396 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
1398 if ($paymentmethod ==
'stripe') {
1399 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
1401 if (empty($paymentTypeId)) {
1402 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1404 if (empty($paymentType)) {
1405 $paymentType =
'CB';
1409 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1412 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1418 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1419 $resultvalidate = $object->validate($user);
1420 if ($resultvalidate < 0) {
1421 $postactionmessages[] =
'Cannot validate invoice';
1422 $ispostactionok = -1;
1428 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1430 $paiement->datepaye = $now;
1431 if ($currencyCodeType == $conf->currency) {
1432 $paiement->amounts = array($object->id => $FinalPaymentAmt);
1434 $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt);
1436 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1437 $ispostactionok = -1;
1440 $paiement->paiementid = $paymentTypeId;
1441 $paiement->num_payment =
'';
1442 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1443 $paiement->ext_payment_id = $TRANSACTIONID;
1444 $paiement->ext_payment_site = $service;
1447 $paiement_id = $paiement->create($user, 1);
1448 if ($paiement_id < 0) {
1449 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1450 $ispostactionok = -1;
1453 $postactionmessages[] =
'Payment created';
1454 $ispostactionok = 1;
1458 if (!$error && isModEnabled(
"banque")) {
1460 if ($paymentmethod ==
'paybox') {
1461 $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1462 } elseif ($paymentmethod ==
'paypal') {
1463 $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1464 } elseif ($paymentmethod ==
'stripe') {
1465 $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1468 if ($bankaccountid > 0) {
1469 $label =
'(CustomerInvoicePayment)';
1471 $label =
'(CustomerInvoicePaymentBack)';
1473 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1475 $postactionmessages[] = $paiement->error.
' '.join(
"<br>\n", $paiement->errors);
1476 $ispostactionok = -1;
1479 $postactionmessages[] =
'Bank transaction of payment created';
1480 $ispostactionok = 1;
1483 $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.';
1484 $ispostactionok = -1;
1491 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1492 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1494 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1495 if ($resultbooth < 0) {
1499 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1500 $resultboothupdate = $booth->update($user);
1501 if ($resultboothupdate<0) {
1504 $resultinvoice = $invoice->fetch($ref);
1505 if ($resultinvoice<0) {
1506 $postactionmessages[] =
'Could not find the associated invoice.';
1507 $ispostactionok = -1;
1510 $thirdparty =
new Societe($db);
1511 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1512 if ($resultthirdparty<0) {
1517 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1518 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1521 $outputlangs =
new Translate(
'', $conf);
1522 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1524 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1526 $arraydefaultmessage =
null;
1528 $idoftemplatetouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH;
1530 if (!empty($idoftemplatetouse)) {
1531 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1534 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1535 $subject = $arraydefaultmessage->topic;
1536 $msg = $arraydefaultmessage->content;
1538 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1539 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1548 $sendto = $thirdparty->email;
1549 $from = $conf->global->MAILING_EMAIL_FROM;
1550 $urlback = $_SERVER[
"REQUEST_URI"];
1554 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml);
1556 $result = $mailfile->sendfile();
1558 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1560 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1575 $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.';
1576 $ispostactionok = -1;
1579 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1580 $ispostactionok = -1;
1582 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1583 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1585 $result = $object->fetch((
int) $tmptag[
'CON']);
1587 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1590 if ($paymentmethod ==
'paybox') {
1591 $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
1593 if ($paymentmethod ==
'paypal') {
1594 $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
1596 if ($paymentmethod ==
'stripe') {
1597 $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
1599 if (empty($paymentTypeId)) {
1600 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1602 if (empty($paymentType)) {
1603 $paymentType =
'CB';
1607 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1610 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1615 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1616 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1619 if (isModEnabled(
'facture')) {
1620 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0 ) {
1621 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1623 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1626 $invoice->validate($user);
1628 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1630 $paiement->datepaye = $now;
1631 if ($currencyCodeType == $conf->currency) {
1632 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1634 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1636 $postactionmessages[] =
'Payment was done in a different currency that currency expected of company';
1637 $ispostactionok = -1;
1640 $paiement->paiementid = $paymentTypeId;
1641 $paiement->num_payment =
'';
1642 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1643 $paiement->ext_payment_id = $TRANSACTIONID;
1644 $paiement->ext_payment_site = $service;
1647 $paiement_id = $paiement->create($user, 1);
1648 if ($paiement_id < 0) {
1649 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1650 $ispostactionok = -1;
1653 $postactionmessages[] =
'Payment created';
1654 $ispostactionok = 1;
1658 if (!$error && isModEnabled(
"banque")) {
1660 if ($paymentmethod ==
'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
1661 elseif ($paymentmethod ==
'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
1662 elseif ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
1664 if ($bankaccountid > 0) {
1665 $label =
'(CustomerInvoicePayment)';
1667 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1669 $postactionmessages[] = $paiement->error .
' ' . join(
"<br>\n", $paiement->errors);
1670 $ispostactionok = -1;
1673 $postactionmessages[] =
'Bank transaction of payment created';
1674 $ispostactionok = 1;
1677 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1678 $ispostactionok = -1;
1689 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1690 if (!empty($cols)) $msg .=
' and col '. $cols .
'.';
1691 $postactionmessages[] = $msg;
1692 $ispostactionok = -1;
1695 $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.';
1696 $ispostactionok = -1;
1699 $postactionmessages[] =
'Invoice module is not enable';
1700 $ispostactionok = -1;
1703 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
1704 if (!empty($cols)) $msg .=
' for col '.$tmptag[
'COL'] .
'.';
1705 $postactionmessages[] = $msg;
1706 $ispostactionok = -1;
1715$appli = $mysoc->name;
1720 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1721 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1723 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1724 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1725 $paymentType = $_SESSION[
'PaymentType'];
1727 if (is_object($object) && method_exists($object,
'call_trigger')) {
1729 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1734 } elseif (get_class($object) ==
'stdClass') {
1736 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1738 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
1739 if ($result < 0) $error++;
1742 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
1743 if ($TRANSACTIONID) {
1744 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
1747 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
1748 if (!empty($conf->global->$key)) {
1750 print $conf->global->$key;
1754 if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) {
1755 $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
1760 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
1764 $companylangs =
new Translate(
'', $conf);
1765 $companylangs->setDefaultLang($mysoc->default_lang);
1766 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
1768 $sendto = $sendemail;
1769 $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM :
getDolGlobalString(
"MAIN_MAIL_EMAIL_FROM");
1771 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1772 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1777 $urlback = $_SERVER[
"REQUEST_URI"];
1778 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
1780 if (array_key_exists(
'MEM', $tmptag)) {
1781 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
1782 $content .=
'<strong>'.$companylangs->trans(
"PaymentSubscription").
"</strong><br><br>\n";
1783 $content .= $companylangs->trans(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
1784 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1785 } elseif (array_key_exists(
'INV', $tmptag)) {
1786 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
1787 $content .=
'<strong>'.$companylangs->trans(
"Payment").
"</strong><br><br>\n";
1788 $content .= $companylangs->trans(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
1790 $content .= $companylangs->trans(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
1792 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
1794 $content .= $companylangs->transnoentities(
"PostActionAfterPayment").
' : ';
1795 if ($ispostactionok > 0) {
1797 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
1798 } elseif ($ispostactionok == 0) {
1799 $content .= $companylangs->transnoentitiesnoconv(
"None");
1801 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
1802 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
1804 $content .=
'<br>'.
"\n";
1805 foreach ($postactionmessages as $postactionmessage) {
1806 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
1808 if ($ispostactionok < 0) {
1809 $content .= $langs->transnoentities(
"ARollbackWasPerformedOnPostActions");
1811 $content .=
'<br>'.
"\n";
1813 $content .=
"<br>\n";
1814 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
1815 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
1816 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
1817 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
1818 $content .=
"<br>\n";
1819 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
1821 if (!empty($ErrorCode)) {
1822 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
1824 if (!empty($ErrorShortMsg)) {
1825 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
1827 if (!empty($ErrorLongMsg)) {
1828 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
1830 if (!empty($ErrorSeverityCode)) {
1831 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
1837 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1838 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
1840 $result = $mailfile->sendfile();
1842 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1845 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1851 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
1852 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
1854 $paymentType = $_SESSION[
'PaymentType'];
1855 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1856 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1858 if (is_object($object) && method_exists($object,
'call_trigger')) {
1860 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
1867 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
1868 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
1869 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
1870 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
1871 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
1873 if ($mysoc->email) {
1874 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
1878 if (!empty($conf->global->PAYMENTONLINE_SENDEMAIL)) {
1879 $sendemail = $conf->global->PAYMENTONLINE_SENDEMAIL;
1882 if ($paymentmethod ==
'paypal' && !empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) {
1883 $sendemail = $conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
1884 } elseif ($paymentmethod ==
'paybox' && !empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) {
1885 $sendemail = $conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
1886 } elseif ($paymentmethod ==
'stripe' && !empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) {
1887 $sendemail = $conf->global->STRIPE_PAYONLINE_SENDEMAIL;
1892 $companylangs =
new Translate(
'', $conf);
1893 $companylangs->setDefaultLang($mysoc->default_lang);
1894 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
1896 $sendto = $sendemail;
1897 $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM :
getDolGlobalString(
"MAIN_MAIL_EMAIL_FROM");
1899 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1900 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1903 $urlback = $_SERVER[
"REQUEST_URI"];
1904 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
1906 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
1908 $content .=
"<br><br>\n";
1909 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
1910 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
1911 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
1912 $content .=
"<br>\n";
1913 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
1918 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1919 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
1921 $result = $mailfile->sendfile();
1923 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1925 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1933print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag($paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
1940unset($_SESSION[
"FinalPaymentAmt"]);
1941unset($_SESSION[
"TRANSACTIONID"]);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage contracts.
Class to manage donations.
Class to manage invoices.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=false, $mode='')
Return file(s) into a directory (by default most recent)
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.