34if (!defined(
'NOLOGIN')) {
37if (!defined(
'NOCSRFCHECK')) {
38 define(
"NOCSRFCHECK", 1);
40if (!defined(
'NOIPCHECK')) {
41 define(
'NOIPCHECK',
'1');
43if (!defined(
'NOBROWSERNOTIF')) {
44 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';
70require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
71require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
72require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
74 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
75 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
81$hookmanager->initHooks(array(
'newpayment'));
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paypal",
"stripe"));
87$PAYPAL_API_PASSWORD =
"";
88$PAYPAL_API_SIGNATURE =
"";
89$PAYPAL_API_SANDBOX =
"";
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)) {
129 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_WARNING, 0,
'_payment');
130 http_response_code(400);
131 print
'Bad request: the callback url does not contain a valid fulltag parameter, required to find the payment method used.';
135dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
139$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
141 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');
144$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
147if (empty($validpaymentmethod)) {
153$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
154$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
164$PAYMENTSTATUS = $TRANSACTIONID = $LONGTRANSACTIONID = $TAXAMT = $NOTE =
'';
166$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
174$ws_virtuelhost =
null;
176$doactionsthenredirect = 0;
178 $doactionsthenredirect = 1;
179 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
181 $result = $website->fetch(0, $ws);
183 $ws_virtuelhost = $website->virtualhost;
184 $ws_id = $website->id;
201dol_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');
202dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
203dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
206foreach ($_POST as $k => $v) {
207 if (is_scalar($k) && is_scalar($v)) {
208 $tracepost .=
"$k=$v\n";
211dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
214foreach ($_SESSION as $k => $v) {
215 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
216 $tracesession .=
"$k=$v\n";
219dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
221dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
225 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
228$conf->dol_hide_topmenu = 1;
229$conf->dol_hide_leftmenu = 1;
233if (empty($doactionsthenredirect)) {
234 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
235 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
239 print
'<span id="dolpaymentspan"></span>'.
"\n";
240 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
245 $logosmall =
$mysoc->logo_small;
247 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
257 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
258 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
259 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
260 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
261 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
267 print
'<div class="backgreypublicpayment">';
268 print
'<div class="logopublicpayment">';
269 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
273 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>';
276 } elseif ($creditor) {
277 print
'<div class="backgreypublicpayment">';
278 print
'<div class="logopublicpayment">';
284 print
'<div class="backimagepublicpayment">';
285 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
290 print
'<br><br><br>';
295$service = $paymentmethod;
298if (
isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
299 if (!empty($PAYPALTOKEN)) {
302 $onlinetoken = $PAYPALTOKEN;
304 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
306 $ipaddress = $_SESSION[
'ipaddress'];
307 $currencyCodeType = $_SESSION[
'currencyCodeType'];
308 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
309 $paymentType = $_SESSION[
'PaymentType'];
311 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
314 if (!empty($paymentType)) {
315 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
319 $ack = strtoupper($resArray[
"ACK"]);
320 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
322 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
327 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
328 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
331 $ack = strtoupper($resArray2[
"ACK"]);
332 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
333 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
339 $object->resArray = $resArray2;
343 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
344 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
345 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
346 $NOTE = urldecode($resArray2[
"NOTE"]);
353 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
354 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
355 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
356 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
359 $ErrorCode =
"SESSIONEXPIRED";
360 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
361 $ErrorShortMsg =
"Session expired";
363 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
367 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
368 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
369 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
371 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
377if (
isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
379 if (empty($TRANSACTIONID)) {
380 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
381 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
383 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
386 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
387 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
389 $service =
'StripeTest';
392 $service =
'StripeLive';
399 if (!
GETPOST(
'payment_intent',
'alphanohtml') &&
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
401 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
406 if (!$error && $TRANSACTIONID) {
409 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
411 $stripeacc = $stripe->getStripeAccount($service);
414 global $stripearrayofkeysbyenv;
415 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
418 if (empty($stripeacc)) {
419 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
421 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
426 $zeroDecimalCurrencies = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
427 if (in_array(strtoupper($currencyCodeType), $zeroDecimalCurrencies)) {
428 $expectedAmount = (int) round($FinalPaymentAmt);
430 $expectedAmount = (int) round($FinalPaymentAmt * 100);
432 $expectedCurrency = strtolower($currencyCodeType);
434 if ((
int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
436 $errmsg =
'Stripe payment information mismatch: expected amount ' . $expectedAmount .
' and currency ' . $expectedCurrency .
', got amount ' . $paymentIntent->amount .
' and currency ' . $paymentIntent->currency;
439 if ($paymentIntent->status !==
'succeeded') {
441 $errmsg =
'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
448 if ($paymentIntent instanceof \
Stripe\PaymentIntent) {
449 $customerid = $paymentIntent->customer;
451 if (isset($stripearrayofkeysbyenv[$servicestatus][
'publishable_key'])) {
452 $pkey = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
455 if ($customerid && $pkey) {
456 $LONGTRANSACTIONID = $TRANSACTIONID.
':'.$customerid.
'@'.$pkey;
460 $errormessage =
"Stripe API error: ".$e->getMessage();
461 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
465 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
466 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
471 $errmsg =
'Stripe API error: ' . $e->getMessage();
476 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
484 $ispaymentok =
false;
489if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
493 'paymentmethod' => $paymentmethod,
495 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
497 if (isset($hookmanager->resArray[
'ispaymentok'])) {
498 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
499 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
508if (empty($ipaddress)) {
509 $ipaddress = $_SESSION[
'ipaddress'];
511if (empty($FinalPaymentAmt)) {
512 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
514if (empty($currencyCodeType)) {
515 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
517if (empty($paymentType)) {
518 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
521if (empty($TRANSACTIONID)) {
522 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
523 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
525 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
540if ($ispaymentok && !empty($TRANSACTIONID)) {
541 $sqltransaction =
"SELECT p.rowid FROM ".MAIN_DB_PREFIX.
"paiement as p";
542 $sqltransaction .=
" WHERE p.ext_payment_id = '".$db->escape($TRANSACTIONID).
"' OR p.ext_payment_id LIKE '".
$db->escape(
$db->escapeforlike($TRANSACTIONID)).
":%'";
543 $sqltransaction .=
" UNION";
544 $sqltransaction .=
" SELECT pd.rowid FROM ".MAIN_DB_PREFIX.
"payment_donation as pd";
545 $sqltransaction .=
" WHERE pd.ext_payment_id = '".$db->escape($TRANSACTIONID).
"' OR pd.ext_payment_id LIKE '".
$db->escape(
$db->escapeforlike($TRANSACTIONID)).
":%'";
546 $resqltransaction =
$db->query($sqltransaction);
547 if (!$resqltransaction ||
$db->num_rows($resqltransaction) > 0) {
548 dol_syslog(
"The transaction ".$TRANSACTIONID.
" is already used by a recorded payment (or the check failed), so it is not recorded again", LOG_WARNING, 0,
'_payment');
549 $ispaymentok =
false;
550 $ErrorCode =
"ALREADYRECORDED";
551 $ErrorShortMsg =
"Payment already recorded";
552 $ErrorLongMsg =
"The transaction ".$TRANSACTIONID.
" of the payment service was already recorded for a payment. It is not recorded again.";
560$postactionmessages = array();
563 if (empty($user->rights->societe)) {
564 $user->rights->societe =
new stdClass();
566 if (empty($user->rights->facture)) {
567 $user->rights->facture =
new stdClass();
568 $user->rights->facture->invoice_advance =
new stdClass();
570 if (empty($user->rights->adherent)) {
571 $user->rights->adherent =
new stdClass();
572 $user->rights->adherent->cotisation =
new stdClass();
574 $user->rights->societe->creer = 1;
575 $user->rights->facture->creer = 1;
576 $user->rights->facture->invoice_advance->validate = 1;
577 $user->rights->adherent->cotisation->creer = 1;
579 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
586 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
587 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
588 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
592 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
593 $result2 = $adht->fetch(
$object->typeid);
595 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
596 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
598 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
600 if ($result1 > 0 && $result2 > 0) {
601 if ($paymentmethod ==
'paybox') {
604 if ($paymentmethod ==
'paypal') {
607 if ($paymentmethod ==
'stripe') {
610 if (empty($paymentTypeId)) {
611 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
613 if (empty($paymentType)) {
621 if (empty($paymentTypeId) || $paymentTypeId < 0) {
626 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
629 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
631 $amountbytype = $adht->amountByType(1);
632 $minimumamountbytype = $adht->minimumamountbytype(1);
633 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
635 if (empty($adht->caneditamount)) {
636 if (
$object->status == $object::STATUS_DRAFT) {
639 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
645 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
646 if (!empty($adht->caneditamountamount)) {
647 $amountexpected = max($amountexpected, $adht->minimumamount);
649 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
651 $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 ?';
652 $postactionmessages[] = $errmsg;
653 $ispostactionok = -1;
654 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
661 if ($FinalPaymentAmt <
getDolGlobalInt(
'MEMBER_MIN_AMOUNT') || $FinalPaymentAmt < $minimumamount) {
663 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' . max(
getDolGlobalString(
'MEMBER_MIN_AMOUNT'), $minimumamount).
'). May be a hack to try to pay a different amount ?';
664 $postactionmessages[] = $errmsg;
665 $ispostactionok = -1;
666 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
671 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
673 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
674 $postactionmessages[] = $errmsg;
675 $ispostactionok = -1;
676 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
681 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
685 $postactionmessages[] = $errmsg;
686 $postactionmessages = array_merge($postactionmessages,
$object->errors);
687 $ispostactionok = -1;
688 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
691 if (empty(
$object->datevalid)) {
692 dol_syslog(
"Member date of validation is empty. We define it", LOG_WARNING, 0,
'_payment');
694 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
695 $sql .=
" datevalid = '".$db->idate($now).
"'";
696 $sql .=
" WHERE rowid = ".((int)
$object->id);
697 $result =
$db->query($sql);
701 $errmsg =
$db->error();
702 $postactionmessages[] = $errmsg;
704 $ispostactionok = -1;
705 dol_syslog(
"Failed to set date of validation: ".$errmsg, LOG_ERR, 0,
'_payment');
711 $datesubscription =
$object->datevalid;
728 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
731 while ($datesubend < $now) {
733 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
742 $amount = $FinalPaymentAmt;
743 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
744 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
748 if ($paymentmethod ==
'paybox') {
751 if ($paymentmethod ==
'paypal') {
754 if ($paymentmethod ==
'stripe') {
759 'paymentmethod' => $paymentmethod,
761 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
763 if (isset($hookmanager->resArray[
'bankaccountid'])) {
764 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
765 $accountid = $hookmanager->resArray[
'bankaccountid'];
770 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
771 $postactionmessages[] = $errmsg;
772 $ispostactionok = -1;
773 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
779 $emetteur_banque =
'';
783 $option =
'bankviainvoice';
785 $option =
'bankdirect';
787 $option =
'invoiceonly';
789 if (empty($option)) {
800 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
802 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
806 $postactionmessages[] = $errmsg;
807 $ispostactionok = -1;
809 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
814 $autocreatethirdparty = 0;
817 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
819 $autocreatethirdparty = 1;
821 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
826 $postactionmessages[] =
$object->error;
827 $postactionmessages = array_merge($postactionmessages,
$object->errors);
828 $ispostactionok = -1;
830 if ($option ==
'bankviainvoice') {
831 $postactionmessages[] =
'Invoice, payment and bank record created';
832 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
834 if ($option ==
'bankdirect') {
835 $postactionmessages[] =
'Bank record created';
836 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
838 if ($option ==
'invoiceonly') {
839 $postactionmessages[] =
'Invoice recorded';
840 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
850 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
853 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
855 $service =
'StripeTest';
858 $service =
'StripeLive';
864 $thirdparty->fetch($thirdparty_id);
866 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
870 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
872 if (!$customer && $TRANSACTIONID) {
873 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
876 global $stripearrayofkeysbyenv;
877 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
879 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
881 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
884 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
888 $stripecu = $chpi->customer;
890 if (empty($stripecu)) {
892 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
895 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
896 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
899 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
900 $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)";
901 $resql =
$db->query($sql);
904 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
906 $postactionmessages[] = $errmsg;
907 $ispostactionok = -1;
912 $errmsg =
'Failed to retrieve paymentintent or charge from id';
914 $postactionmessages[] = $errmsg;
915 $ispostactionok = -1;
919 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
921 $postactionmessages[] = $errmsg;
922 $ispostactionok = -1;
944 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
945 $resqlcount =
$db->query($sql);
947 $objcount =
$db->fetch_object($resqlcount);
949 $found = $objcount->nb;
954 $result = $nuser->create_from_member($tmpuser,
$object->login);
955 $newpassword = $nuser->setPassword($user,
'');
958 $outputlangs->load(
"errors");
959 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
961 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
962 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
965 $outputlangs->load(
"errors");
966 $postactionmessages[] =
'No user created because a user linked to member already exists';
972 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
975 if (
$object->email && $sendalsoemail) {
980 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
983 $outputlangs->loadLangs(array(
"main",
"members"));
985 $arraydefaultmessage =
null;
988 if (!empty($labeltouse)) {
989 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
992 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
993 $subject = $arraydefaultmessage->topic;
994 $msg = $arraydefaultmessage->content;
997 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
999 if ($infouserlogin) {
1000 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
1009 $listofpaths = array();
1010 $listofnames = array();
1011 $listofmimes = array();
1012 if (is_object(
$object->invoice)) {
1013 $invoicediroutput =
$conf->facture->dir_output;
1015 $file = $fileparams[
'fullname'];
1017 $listofpaths = array($file);
1018 $listofnames = array(basename($file));
1022 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
1024 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
1028 $postactionmessages[] = $errmsg;
1029 $ispostactionok = -1;
1032 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
1034 $postactionmessages[] =
'Email sent to member (without any attached document)';
1042 $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.';
1043 $ispostactionok = -1;
1046 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1047 $ispostactionok = -1;
1049 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1051 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1054 $result =
$object->fetch((
int) $tmptag[
'INV']);
1056 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1059 if ($paymentmethod ===
'paybox') {
1062 if ($paymentmethod ===
'paypal') {
1065 if ($paymentmethod ===
'stripe') {
1068 if (empty($paymentTypeId)) {
1069 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1071 if (empty($paymentType)) {
1072 $paymentType =
'CB';
1079 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1084 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1087 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1091 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1093 $paiement->datepaye = $now;
1094 if ($currencyCodeType ==
$conf->currency) {
1095 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1097 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1099 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1100 $ispostactionok = -1;
1103 $paiement->paiementid = $paymentTypeId;
1104 $paiement->num_payment =
'';
1105 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1108 if ($LONGTRANSACTIONID) {
1109 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1111 $paiement->ext_payment_id = $TRANSACTIONID;
1113 $paiement->ext_payment_site = $service;
1117 $result =
$object->validate($user);
1119 $postactionmessages[] =
$object->error;
1120 $ispostactionok = -1;
1123 $postactionmessages[] =
'Invoice validated';
1124 $ispostactionok = 1;
1129 $paiement_id = $paiement->create($user, 1);
1130 if ($paiement_id < 0) {
1131 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1132 $ispostactionok = -1;
1135 $postactionmessages[] =
'Payment created';
1136 $ispostactionok = 1;
1142 if ($paymentmethod ==
'paybox') {
1144 } elseif ($paymentmethod ==
'paypal') {
1146 } elseif ($paymentmethod ==
'stripe') {
1152 'paymentmethod' => $paymentmethod,
1154 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1155 if ($reshook >= 0) {
1156 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1157 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1158 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1161 if ($bankaccountid > 0) {
1162 $label =
'(CustomerInvoicePayment)';
1164 $label =
'(CustomerInvoicePaymentBack)';
1166 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1168 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1169 $ispostactionok = -1;
1172 $postactionmessages[] =
'Bank transaction of payment created';
1173 $ispostactionok = 1;
1176 $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.';
1177 $ispostactionok = -1;
1188 $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.';
1189 $ispostactionok = -1;
1192 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1193 $ispostactionok = -1;
1195 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1196 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1198 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1200 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1202 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1205 if ($paymentmethod ==
'paybox') {
1208 if ($paymentmethod ==
'paypal') {
1211 if ($paymentmethod ==
'stripe') {
1214 if (empty($paymentTypeId)) {
1215 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1217 if (empty($paymentType)) {
1218 $paymentType =
'CB';
1225 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1230 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1234 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1237 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1239 $result = $invoice->createFromOrder($object, $user);
1241 if ($FinalPaymentAmt !=
$object->total_ttc) {
1249 $object->classifyBilled($user);
1251 $invoice->validate($user);
1254 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1256 $paiement->datepaye = $now;
1257 if ($currencyCodeType ==
$conf->currency) {
1258 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1260 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1262 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1263 $ispostactionok = -1;
1266 $paiement->paiementid = $paymentTypeId;
1267 $paiement->num_payment =
'';
1268 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1271 if ($LONGTRANSACTIONID) {
1272 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1274 $paiement->ext_payment_id = $TRANSACTIONID;
1276 $paiement->ext_payment_site = $service;
1279 $paiement_id = $paiement->create($user, 1);
1280 if ($paiement_id < 0) {
1281 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1282 $ispostactionok = -1;
1285 $postactionmessages[] =
'Payment created';
1286 $ispostactionok = 1;
1292 if ($paymentmethod ==
'paybox') {
1294 } elseif ($paymentmethod ==
'paypal') {
1296 } elseif ($paymentmethod ==
'stripe') {
1302 'paymentmethod' => $paymentmethod,
1304 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1305 if ($reshook >= 0) {
1306 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1307 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1308 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1311 if ($bankaccountid > 0) {
1312 $label =
'(CustomerInvoicePayment)';
1314 $label =
'(CustomerInvoicePaymentBack)';
1316 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1318 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1319 $ispostactionok = -1;
1322 $postactionmessages[] =
'Bank transaction of payment created';
1323 $ispostactionok = 1;
1326 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1327 $ispostactionok = -1;
1332 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1333 $ispostactionok = -1;
1343 $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.';
1344 $ispostactionok = -1;
1347 $postactionmessages[] =
'Invoice module is not enable';
1348 $ispostactionok = -1;
1351 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1352 $ispostactionok = -1;
1354 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1355 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1357 $result = $don->fetch((
int) $tmptag[
'DON']);
1360 if ($paymentmethod ==
'paybox') {
1363 if ($paymentmethod ==
'paypal') {
1366 if ($paymentmethod ==
'stripe') {
1369 if (empty($paymentTypeId)) {
1370 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1372 if (empty($paymentType)) {
1373 $paymentType =
'CB';
1380 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1386 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1390 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1393 $totalpaid = $FinalPaymentAmt;
1395 if ($currencyCodeType ==
$conf->currency) {
1396 $paiement->amounts = array(
$object->id => $totalpaid);
1399 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1400 $ispostactionok = -1;
1404 $paiement->fk_donation = $don->id;
1405 $paiement->datep = $now;
1406 $paiement->paymenttype = $paymentTypeId;
1407 $paiement->num_payment =
'';
1408 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1411 if ($LONGTRANSACTIONID) {
1412 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1414 $paiement->ext_payment_id = $TRANSACTIONID;
1416 $paiement->ext_payment_site = $service;
1419 $paiement_id = $paiement->create($user, 1);
1420 if ($paiement_id < 0) {
1421 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1422 $ispostactionok = -1;
1425 $postactionmessages[] =
'Payment created';
1426 $ispostactionok = 1;
1428 if ($totalpaid >= $don->getRemainToPay()) {
1429 $don->valid_promesse($don->id, $user->id);
1430 $don->setPaid($don->id);
1437 if ($paymentmethod ==
'paybox') {
1439 } elseif ($paymentmethod ==
'paypal') {
1441 } elseif ($paymentmethod ==
'stripe') {
1447 'paymentmethod' => $paymentmethod,
1449 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1450 if ($reshook >= 0) {
1451 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1452 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1453 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1456 if ($bankaccountid > 0) {
1457 $label =
'(DonationPayment)';
1458 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1460 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1461 $ispostactionok = -1;
1464 $postactionmessages[] =
'Bank transaction of payment created';
1465 $ispostactionok = 1;
1468 $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.';
1469 $ispostactionok = -1;
1480 $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.';
1481 $ispostactionok = -1;
1484 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1485 $ispostactionok = -1;
1490 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1492 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1493 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1494 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1496 $result =
$object->fetch((
int) $ref);
1499 if ($paymentmethod ==
'paybox') {
1502 if ($paymentmethod ==
'paypal') {
1505 if ($paymentmethod ==
'stripe') {
1508 if (empty($paymentTypeId)) {
1509 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1511 if (empty($paymentType)) {
1512 $paymentType =
'CB';
1519 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1525 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1526 $resultvalidate =
$object->validate($user);
1527 if ($resultvalidate < 0) {
1528 $postactionmessages[] =
'Cannot validate invoice';
1529 $ispostactionok = -1;
1535 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1537 $paiement->datepaye = $now;
1538 if ($currencyCodeType ==
$conf->currency) {
1539 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1541 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1543 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1544 $ispostactionok = -1;
1547 $paiement->paiementid = $paymentTypeId;
1548 $paiement->num_payment =
'';
1549 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1552 if ($LONGTRANSACTIONID) {
1553 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1555 $paiement->ext_payment_id = $TRANSACTIONID;
1557 $paiement->ext_payment_site = $service;
1560 $paiement_id = $paiement->create($user, 1);
1561 if ($paiement_id < 0) {
1562 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1563 $ispostactionok = -1;
1566 $postactionmessages[] =
'Payment created';
1567 $ispostactionok = 1;
1573 if ($paymentmethod ==
'paybox') {
1575 } elseif ($paymentmethod ==
'paypal') {
1577 } elseif ($paymentmethod ==
'stripe') {
1583 'paymentmethod' => $paymentmethod,
1585 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1586 if ($reshook >= 0) {
1587 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1588 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1589 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1592 if ($bankaccountid > 0) {
1593 $label =
'(CustomerInvoicePayment)';
1595 $label =
'(CustomerInvoicePaymentBack)';
1597 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1599 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1600 $ispostactionok = -1;
1603 $postactionmessages[] =
'Bank transaction of payment created';
1604 $ispostactionok = 1;
1607 $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.';
1608 $ispostactionok = -1;
1617 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1618 if ($resultattendee < 0) {
1622 $attendeetovalidate->validate($user);
1624 $attendeetovalidate->amount = $FinalPaymentAmt;
1625 $attendeetovalidate->date_subscription =
dol_now();
1626 $attendeetovalidate->update($user);
1641 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1642 if ($resultthirdparty < 0) {
1645 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1646 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1650 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (
string) $thirdparty->default_lang);
1652 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1654 $arraydefaultmessage =
null;
1656 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1658 if (!empty($idoftemplatetouse)) {
1659 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1662 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1663 $subject = $arraydefaultmessage->topic;
1664 $msg = $arraydefaultmessage->content;
1666 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1667 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1670 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1676 $sendto = $attendeetovalidate->email;
1678 if ($thirdparty->email) {
1679 $cc = $thirdparty->email ??
'';
1681 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1682 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1687 $urlback = $_SERVER[
"REQUEST_URI"];
1693 $listofpaths = array();
1694 $listofnames = array();
1695 $listofmimes = array();
1696 if (is_object($object)) {
1697 $invoicediroutput =
$conf->facture->dir_output;
1699 $file = $fileparams[
'fullname'];
1701 $listofpaths = array($file);
1702 $listofnames = array(basename($file));
1706 $trackid =
'inv'.$object->id;
1708 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1710 $result = $mailfile->sendfile();
1712 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1714 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1720 $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.';
1721 $ispostactionok = -1;
1724 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1725 $ispostactionok = -1;
1727 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1729 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1730 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1731 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1733 $result =
$object->fetch((
int) $ref);
1735 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1738 if ($paymentmethod ==
'paybox') {
1741 if ($paymentmethod ==
'paypal') {
1744 if ($paymentmethod ==
'stripe') {
1747 if (empty($paymentTypeId)) {
1748 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1750 if (empty($paymentType)) {
1751 $paymentType =
'CB';
1758 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1764 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1765 $resultvalidate =
$object->validate($user);
1766 if ($resultvalidate < 0) {
1767 $postactionmessages[] =
'Cannot validate invoice';
1768 $ispostactionok = -1;
1774 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1776 $paiement->datepaye = $now;
1777 if ($currencyCodeType ==
$conf->currency) {
1778 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1780 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1782 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1783 $ispostactionok = -1;
1786 $paiement->paiementid = $paymentTypeId;
1787 $paiement->num_payment =
'';
1788 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1791 if ($LONGTRANSACTIONID) {
1792 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1794 $paiement->ext_payment_id = $TRANSACTIONID;
1796 $paiement->ext_payment_site = $service;
1799 $paiement_id = $paiement->create($user, 1);
1800 if ($paiement_id < 0) {
1801 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1802 $ispostactionok = -1;
1805 $postactionmessages[] =
'Payment created';
1806 $ispostactionok = 1;
1812 if ($paymentmethod ==
'paybox') {
1814 } elseif ($paymentmethod ==
'paypal') {
1816 } elseif ($paymentmethod ==
'stripe') {
1822 'paymentmethod' => $paymentmethod,
1824 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1825 if ($reshook >= 0) {
1826 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1827 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1828 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1831 if ($bankaccountid > 0) {
1832 $label =
'(CustomerInvoicePayment)';
1834 $label =
'(CustomerInvoicePaymentBack)';
1836 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1838 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1839 $ispostactionok = -1;
1842 $postactionmessages[] =
'Bank transaction of payment created';
1843 $ispostactionok = 1;
1846 $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.';
1847 $ispostactionok = -1;
1854 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1855 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1857 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1858 if ($resultbooth < 0) {
1862 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1863 $resultboothupdate = $booth->update($user);
1864 if ($resultboothupdate < 0) {
1867 $resultinvoice = $invoice->fetch((
int) $ref);
1868 if ($resultinvoice < 0) {
1869 $postactionmessages[] =
'Could not find the associated invoice.';
1870 $ispostactionok = -1;
1874 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1875 if ($resultthirdparty < 0) {
1882 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1883 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1887 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1889 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1891 $arraydefaultmessage =
null;
1893 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1895 if (!empty($idoftemplatetouse)) {
1896 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1899 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1900 $subject = $arraydefaultmessage->topic;
1901 $msg = $arraydefaultmessage->content;
1903 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1904 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1907 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1913 $sendto = $thirdparty->email;
1915 $urlback = $_SERVER[
"REQUEST_URI"];
1918 $trackid =
'inv'.$invoice->id;
1920 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1922 $result = $mailfile->sendfile();
1924 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1926 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1941 $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.';
1942 $ispostactionok = -1;
1945 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1946 $ispostactionok = -1;
1948 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1949 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1951 $result =
$object->fetch((
int) $tmptag[
'CON']);
1953 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1956 if ($paymentmethod ==
'paybox') {
1959 if ($paymentmethod ==
'paypal') {
1962 if ($paymentmethod ==
'stripe') {
1965 if (empty($paymentTypeId)) {
1966 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1968 if (empty($paymentType)) {
1969 $paymentType =
'CB';
1976 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1981 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1982 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1986 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1989 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1991 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1994 $invoice->validate($user);
1996 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1998 $paiement->datepaye = $now;
1999 if ($currencyCodeType ==
$conf->currency) {
2000 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
2002 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
2004 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
2005 $ispostactionok = -1;
2008 $paiement->paiementid = $paymentTypeId;
2009 $paiement->num_payment =
'';
2010 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
2013 if ($LONGTRANSACTIONID) {
2014 $paiement->ext_payment_id = $LONGTRANSACTIONID;
2016 $paiement->ext_payment_id = $TRANSACTIONID;
2018 $paiement->ext_payment_site = $service;
2021 $paiement_id = $paiement->create($user, 1);
2022 if ($paiement_id < 0) {
2023 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2024 $ispostactionok = -1;
2027 $postactionmessages[] =
'Payment created';
2028 $ispostactionok = 1;
2034 if ($paymentmethod ==
'paybox') {
2036 } elseif ($paymentmethod ==
'paypal') {
2038 } elseif ($paymentmethod ==
'stripe') {
2044 'paymentmethod' => $paymentmethod,
2046 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2047 if ($reshook >= 0) {
2048 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2049 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2050 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2053 if ($bankaccountid > 0) {
2054 $label =
'(CustomerInvoicePayment)';
2056 $label =
'(CustomerInvoicePaymentBack)';
2058 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2060 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2061 $ispostactionok = -1;
2064 $postactionmessages[] =
'Bank transaction of payment created';
2065 $ispostactionok = 1;
2068 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2069 $ispostactionok = -1;
2074 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2075 if (!empty($tmptag[
'COL'])) {
2076 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2078 $postactionmessages[] = $msg;
2079 $ispostactionok = -1;
2089 $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.';
2090 $ispostactionok = -1;
2093 $postactionmessages[] =
'Invoice module is not enable';
2094 $ispostactionok = -1;
2097 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2098 if (!empty($tmptag[
'COL'])) {
2099 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2101 $postactionmessages[] = $msg;
2102 $ispostactionok = -1;
2109dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2113 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2114 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2116 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2117 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2118 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2120 if (is_object($object) && method_exists($object,
'call_trigger')) {
2121 '@phan-var-force CommonObject $object';
2123 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2128 } elseif (get_class($object) ==
'stdClass') {
2130 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2132 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2141if (empty($doactionsthenredirect)) {
2143 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2144 if ($TRANSACTIONID) {
2145 print $langs->trans(
"ThisIsTransactionId").
" : ".$TRANSACTIONID.
"<br><br>\n";
2149 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2152 if ($ispostactionok > 0) {
2154 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2161 print
'<div class="warning marginleftonly marginrightonly">';
2162 print $langs->trans(
"PaymentRecordedButPostPocessingKo").
'<br>';
2164 if ($ErrorLongMsg) {
2165 $s .= $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2167 if ($ErrorShortMsg) {
2168 $s .= $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2171 $s .= $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2173 if ($ErrorSeverityCode) {
2174 $s .= $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2176 if (!empty($postactionmessages) && is_array($postactionmessages)) {
2177 foreach ($postactionmessages as $postactionmessage) {
2184 print
'<div class="small">';
2192 print
"Please, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2196 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2197 if ($ErrorLongMsg) {
2198 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2200 if ($ErrorShortMsg) {
2201 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2204 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2206 if ($ErrorSeverityCode) {
2207 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2212 print
"Please, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2224 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2230 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2237 $companylangs->setDefaultLang($myCompanyDefaultLang);
2238 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2240 $sendto = $sendemail;
2243 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2244 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2249 $urlback = $_SERVER[
"REQUEST_URI"];
2250 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2252 if (array_key_exists(
'MEM', $tmptag)) {
2253 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2254 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2255 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2256 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2257 } elseif (array_key_exists(
'INV', $tmptag)) {
2258 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2259 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2260 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2262 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2264 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2266 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2267 if ($ispostactionok > 0) {
2269 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2270 } elseif ($ispostactionok == 0) {
2271 $content .= $companylangs->transnoentitiesnoconv(
"None");
2273 $topic .=
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')';
2274 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2276 $content .=
'<br>'.
"\n";
2277 foreach ($postactionmessages as $postactionmessage) {
2278 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2280 if ($ispostactionok < 0) {
2281 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2283 $content .=
'<br>'.
"\n";
2285 $content .=
"<br>\n";
2286 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2287 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2288 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2289 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2290 $content .=
"<br>\n";
2291 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2293 if (!empty($ErrorCode)) {
2294 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2296 if (!empty($ErrorShortMsg)) {
2297 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2299 if (!empty($ErrorLongMsg)) {
2300 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2302 if (!empty($ErrorSeverityCode)) {
2303 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2306 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2311 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2312 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2314 $result = $mailfile->sendfile();
2316 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2319 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2327 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2328 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2330 $paymentType = $_SESSION[
'PaymentType'];
2331 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2332 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2334 if (is_object($object) && method_exists($object,
'call_trigger')) {
2336 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2346 $companylangs->setDefaultLang(
$mysoc->default_lang);
2347 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2349 $sendto = $sendemail;
2352 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2353 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2356 $urlback = $_SERVER[
"REQUEST_URI"];
2357 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2359 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2361 $content .=
"<br><br>\n";
2362 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2363 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2364 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2365 $content .=
"<br>\n";
2366 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2372 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2373 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2375 $result = $mailfile->sendfile();
2377 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2379 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2386unset($_SESSION[
"FinalPaymentAmt"]);
2387unset($_SESSION[
"TRANSACTIONID"]);
2391if (empty($doactionsthenredirect)) {
2394 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2399if (empty($doactionsthenredirect)) {
2410if (!empty($doactionsthenredirect)) {
2414 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2417 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2418 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2420 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2423 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2424 header(
"Location: ".$ext_urlok);
2429 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2432 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2433 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2435 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2438 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2439 header(
"Location: ".$ext_urlko);
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage members type.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage customers orders.
Class for ConferenceOrBoothAttendee.
Class for ConferenceOrBooth.
Class to manage donations.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage third parties objects (customers, suppliers, prospects...)
Stripe class @TODO No reason to extend CommonObject.
Class to manage translations.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
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_now($mode='gmt')
Return date for now.
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.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) formatLogObject($data)
Return a string serialized to be output on log with dol_syslog() An option allow to output log in one...
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.