34if (!defined(
'NOLOGIN')) {
37if (!defined(
'NOCSRFCHECK')) {
38 define(
"NOCSRFCHECK", 1);
40if (!defined(
'NOIPCHECK')) {
41 define(
'NOIPCHECK',
'1');
43if (!defined(
'NOBROWSERNOTIF')) {
44 define(
'NOBROWSERNOTIF',
'1');
47if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
48 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
54$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
55if (is_numeric($entity)) {
56 define(
"DOLENTITY", $entity);
60require
'../../main.inc.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
64if (isModEnabled(
'paypal')) {
65 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
66 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
83$hookmanager->initHooks(array(
'newpayment'));
85$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
89$PAYPAL_API_PASSWORD =
"";
90$PAYPAL_API_SIGNATURE =
"";
91$PAYPAL_API_SANDBOX =
"";
94if (isModEnabled(
'paypal')) {
100 $PAYPALTOKEN =
GETPOST(
'TOKEN');
101 if (empty($PAYPALTOKEN)) {
102 $PAYPALTOKEN =
GETPOST(
'token');
104 $PAYPALPAYERID =
GETPOST(
'PAYERID');
105 if (empty($PAYPALPAYERID)) {
106 $PAYPALPAYERID =
GETPOST(
'PayerID');
111if (empty($FULLTAG)) {
117$suffix =
GETPOST(
"suffix",
'aZ09');
124if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
125 $paymentmethod = $reg[1];
127if (empty($paymentmethod)) {
128 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
129 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
133dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
137$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
139 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');
142$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
145if (empty($validpaymentmethod)) {
150$creditor = $mysoc->name;
151$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
152$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
162$PAYMENTSTATUS = $TRANSACTIONID = $TAXAMT = $NOTE =
'';
164$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
172$ws_virtuelhost =
null;
174$doactionsthenredirect = 0;
176 $doactionsthenredirect = 1;
177 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
179 $result = $website->fetch(0, $ws);
181 $ws_virtuelhost = $website->virtualhost;
182 $ws_id = $website->id;
199dol_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');
200dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
201dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
204foreach ($_POST as $k => $v) {
205 if (is_scalar($k) && is_scalar($v)) {
206 $tracepost .=
"$k=$v\n";
209dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
212foreach ($_SESSION as $k => $v) {
213 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
214 $tracesession .=
"$k=$v\n";
217dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
219dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
223 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
226$conf->dol_hide_topmenu = 1;
227$conf->dol_hide_leftmenu = 1;
231if (empty($doactionsthenredirect)) {
232 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
233 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
237 print
'<span id="dolpaymentspan"></span>'.
"\n";
238 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
243 $logosmall = $mysoc->logo_small;
244 $logo = $mysoc->logo;
245 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
255 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
256 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
257 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
258 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
259 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
265 print
'<div class="backgreypublicpayment">';
266 print
'<div class="logopublicpayment">';
267 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
271 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>';
274 } elseif ($creditor) {
275 print
'<div class="backgreypublicpayment">';
276 print
'<div class="logopublicpayment">';
282 print
'<div class="backimagepublicpayment">';
283 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
288 print
'<br><br><br>';
293$service = $paymentmethod;
296if (isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
297 if (!empty($PAYPALTOKEN)) {
300 $onlinetoken = $PAYPALTOKEN;
302 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
304 $ipaddress = $_SESSION[
'ipaddress'];
305 $currencyCodeType = $_SESSION[
'currencyCodeType'];
306 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
307 $paymentType = $_SESSION[
'PaymentType'];
309 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
312 if (!empty($paymentType)) {
313 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
317 $ack = strtoupper($resArray[
"ACK"]);
318 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
320 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
322 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, 0,
'_payment');
325 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
326 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
329 $ack = strtoupper($resArray2[
"ACK"]);
330 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
331 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
337 $object->resArray = $resArray2;
341 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
342 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
343 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
344 $NOTE = urldecode($resArray2[
"NOTE"]);
348 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
351 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
352 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
353 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
354 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
357 $ErrorCode =
"SESSIONEXPIRED";
358 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
359 $ErrorShortMsg =
"Session expired";
361 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
365 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
366 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
367 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
369 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
375if (isModEnabled(
'paybox') && $paymentmethod ===
'paybox') {
381if (isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
383 if (empty($TRANSACTIONID)) {
384 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
385 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
387 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
390 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
391 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
393 $service =
'StripeTest';
396 $service =
'StripeLive';
401 if (
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
403 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
408 if (!$error && $TRANSACTIONID) {
411 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
412 $stripe =
new Stripe($db);
413 $stripeacc = $stripe->getStripeAccount($service);
416 global $stripearrayofkeysbyenv;
417 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
420 if (empty($stripeacc)) {
421 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
423 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
427 $expectedAmount = (int) round($FinalPaymentAmt * 100);
428 $expectedCurrency = strtolower($currencyCodeType);
430 if ((
int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
432 $errmsg =
'Stripe payment information mismatch: expected amount ' . $expectedAmount .
' and currency ' . $expectedCurrency .
', got amount ' . $paymentIntent->amount .
' and currency ' . $paymentIntent->currency;
435 if ($paymentIntent->status !==
'succeeded') {
437 $errmsg =
'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
442 $errormessage =
"Stripe API error: ".$e->getMessage();
443 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
447 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
448 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
453 $errmsg =
'Stripe API error: ' . $e->getMessage();
458 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
466 $ispaymentok =
false;
471if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
475 'paymentmethod' => $paymentmethod,
477 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
479 if (isset($hookmanager->resArray[
'ispaymentok'])) {
480 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
481 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
488if (empty($ipaddress)) {
489 $ipaddress = $_SESSION[
'ipaddress'];
491if (empty($FinalPaymentAmt)) {
492 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
494if (empty($currencyCodeType)) {
495 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
497if (empty($paymentType)) {
498 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
501if (empty($TRANSACTIONID)) {
502 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
503 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
505 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
513dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
517$appli = $mysoc->name;
520if ($ispaymentok && !empty($TRANSACTIONID)) {
521 $sqltransaction =
"SELECT p.rowid FROM ".MAIN_DB_PREFIX.
"paiement as p";
522 $sqltransaction .=
" WHERE p.ext_payment_id = '".$db->escape($TRANSACTIONID).
"' OR p.ext_payment_id LIKE '".$db->escape($db->escapeforlike($TRANSACTIONID)).
":%'";
523 $sqltransaction .=
" UNION";
524 $sqltransaction .=
" SELECT pd.rowid FROM ".MAIN_DB_PREFIX.
"payment_donation as pd";
525 $sqltransaction .=
" WHERE pd.ext_payment_id = '".$db->escape($TRANSACTIONID).
"' OR pd.ext_payment_id LIKE '".$db->escape($db->escapeforlike($TRANSACTIONID)).
":%'";
526 $resqltransaction = $db->query($sqltransaction);
527 if (!$resqltransaction || $db->num_rows($resqltransaction) > 0) {
528 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');
529 $ispaymentok =
false;
530 $ErrorCode =
"ALREADYRECORDED";
531 $ErrorShortMsg =
"Payment already recorded";
532 $ErrorLongMsg =
"The transaction ".$TRANSACTIONID.
" of the payment service was already recorded for a payment. It is not recorded again.";
540$postactionmessages = array();
543 if (empty($user->rights->societe)) {
544 $user->rights->societe =
new stdClass();
546 if (empty($user->rights->facture)) {
547 $user->rights->facture =
new stdClass();
548 $user->rights->facture->invoice_advance =
new stdClass();
550 if (empty($user->rights->adherent)) {
551 $user->rights->adherent =
new stdClass();
552 $user->rights->adherent->cotisation =
new stdClass();
554 $user->rights->societe->creer = 1;
555 $user->rights->facture->creer = 1;
556 $user->rights->facture->invoice_advance->validate = 1;
557 $user->rights->adherent->cotisation->creer = 1;
559 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
566 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
567 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
568 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
572 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
573 $result2 = $adht->fetch(
$object->typeid);
575 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
576 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
578 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
580 if ($result1 > 0 && $result2 > 0) {
581 if ($paymentmethod ==
'paybox') {
584 if ($paymentmethod ==
'paypal') {
587 if ($paymentmethod ==
'stripe') {
590 if (empty($paymentTypeId)) {
591 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
593 if (empty($paymentType)) {
598 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
601 if (empty($paymentTypeId) || $paymentTypeId < 0) {
606 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
609 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
611 if (empty($adht->caneditamount)) {
612 if (
$object->status == $object::STATUS_DRAFT) {
614 $amountbytype = $adht->amountByType(1);
618 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
628 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
630 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
632 $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 ?';
633 $postactionmessages[] = $errmsg;
634 $ispostactionok = -1;
635 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
644 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' .
getDolGlobalString(
'MEMBER_MIN_AMOUNT').
'). May be a hack to try to pay a different amount ?';
645 $postactionmessages[] = $errmsg;
646 $ispostactionok = -1;
647 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
652 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
654 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
655 $postactionmessages[] = $errmsg;
656 $ispostactionok = -1;
657 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
662 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
663 if ($result < 0 || empty(
$object->datevalid)) {
666 $postactionmessages[] = $errmsg;
667 $postactionmessages = array_merge($postactionmessages,
$object->errors);
668 $ispostactionok = -1;
669 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
674 $datesubscription =
$object->datevalid;
691 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
694 while ($datesubend < $now) {
696 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
703 $outputlangs->setDefaultLang(!empty(
$object->default_lang) ? (
string)
$object->default_lang : (empty(
$object->thirdparty->default_lang) ? (string) $mysoc->default_lang : (string)
$object->thirdparty->default_lang));
705 $amount = $FinalPaymentAmt;
706 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
707 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
711 if ($paymentmethod ==
'paybox') {
714 if ($paymentmethod ==
'paypal') {
717 if ($paymentmethod ==
'stripe') {
723 'paymentmethod' => $paymentmethod,
725 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
727 if (isset($hookmanager->resArray[
'bankaccountid'])) {
728 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
729 $accountid = $hookmanager->resArray[
'bankaccountid'];
732 if ($accountid < 0) {
734 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
735 $postactionmessages[] = $errmsg;
736 $ispostactionok = -1;
737 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
740 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
743 $emetteur_banque =
'';
746 if (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankviainvoice' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
747 $option =
'bankviainvoice';
748 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'bankdirect' && isModEnabled(
"bank")) {
749 $option =
'bankdirect';
750 } elseif (
getDolGlobalString(
'ADHERENT_BANK_USE') ==
'invoiceonly' && isModEnabled(
"bank") && isModEnabled(
"societe") && isModEnabled(
'invoice')) {
751 $option =
'invoiceonly';
753 if (empty($option)) {
764 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
766 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
770 $postactionmessages[] = $errmsg;
771 $ispostactionok = -1;
773 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
778 $autocreatethirdparty = 0;
781 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
783 $autocreatethirdparty = 1;
785 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
790 $postactionmessages[] =
$object->error;
791 $postactionmessages = array_merge($postactionmessages,
$object->errors);
792 $ispostactionok = -1;
794 if ($option ==
'bankviainvoice') {
795 $postactionmessages[] =
'Invoice, payment and bank record created';
796 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
798 if ($option ==
'bankdirect') {
799 $postactionmessages[] =
'Bank record created';
800 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
802 if ($option ==
'invoiceonly') {
803 $postactionmessages[] =
'Invoice recorded';
804 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
814 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
817 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
819 $service =
'StripeTest';
822 $service =
'StripeLive';
827 $thirdparty =
new Societe($db);
828 $thirdparty->fetch($thirdparty_id);
830 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
831 $stripe =
new Stripe($db);
834 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
836 if (!$customer && $TRANSACTIONID) {
837 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
840 global $stripearrayofkeysbyenv;
841 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
843 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
845 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
848 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
852 $stripecu = $chpi->customer;
854 if (empty($stripecu)) {
856 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
859 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
860 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
863 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
864 $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)";
865 $resql = $db->query($sql);
868 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
870 $postactionmessages[] = $errmsg;
871 $ispostactionok = -1;
876 $errmsg =
'Failed to retrieve paymentintent or charge from id';
878 $postactionmessages[] = $errmsg;
879 $ispostactionok = -1;
883 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
885 $postactionmessages[] = $errmsg;
886 $ispostactionok = -1;
903 $nuser =
new User($db);
908 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
909 $resqlcount = $db->query($sql);
911 $objcount = $db->fetch_object($resqlcount);
913 $found = $objcount->nb;
918 $result = $nuser->create_from_member($tmpuser,
$object->login);
919 $newpassword = $nuser->setPassword($user,
'');
922 $outputlangs->load(
"errors");
923 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
925 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
926 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
929 $outputlangs->load(
"errors");
930 $postactionmessages[] =
'No user created because a user linked to member already exists';
936 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
939 if (
$object->email && $sendalsoemail) {
944 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
947 $outputlangs->loadLangs(array(
"main",
"members"));
949 $arraydefaultmessage =
null;
952 if (!empty($labeltouse)) {
953 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
956 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
957 $subject = $arraydefaultmessage->topic;
958 $msg = $arraydefaultmessage->content;
961 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
963 if ($infouserlogin) {
964 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
973 $listofpaths = array();
974 $listofnames = array();
975 $listofmimes = array();
976 if (is_object(
$object->invoice)) {
977 $invoicediroutput =
$conf->facture->dir_output;
979 $file = $fileparams[
'fullname'];
981 $listofpaths = array($file);
982 $listofnames = array(basename($file));
986 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
988 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
992 $postactionmessages[] = $errmsg;
993 $ispostactionok = -1;
996 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
998 $postactionmessages[] =
'Email sent to member (without any attached document)';
1006 $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.';
1007 $ispostactionok = -1;
1010 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1011 $ispostactionok = -1;
1013 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1015 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1017 $result =
$object->fetch((
int) $tmptag[
'INV']);
1019 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1022 if ($paymentmethod ===
'paybox') {
1025 if ($paymentmethod ===
'paypal') {
1028 if ($paymentmethod ===
'stripe') {
1031 if (empty($paymentTypeId)) {
1032 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1034 if (empty($paymentType)) {
1035 $paymentType =
'CB';
1039 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1042 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1047 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1050 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1054 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1056 $paiement->datepaye = $now;
1057 if ($currencyCodeType ==
$conf->currency) {
1058 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1060 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1062 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1063 $ispostactionok = -1;
1066 $paiement->paiementid = $paymentTypeId;
1067 $paiement->num_payment =
'';
1068 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1069 $paiement->ext_payment_id = $TRANSACTIONID;
1071 $paiement->ext_payment_site = $service;
1074 $paiement_id = $paiement->create($user, 1);
1075 if ($paiement_id < 0) {
1076 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1077 $ispostactionok = -1;
1080 $postactionmessages[] =
'Payment created';
1081 $ispostactionok = 1;
1085 if (!$error && isModEnabled(
"bank")) {
1087 if ($paymentmethod ==
'paybox') {
1089 } elseif ($paymentmethod ==
'paypal') {
1091 } elseif ($paymentmethod ==
'stripe') {
1097 'paymentmethod' => $paymentmethod,
1099 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1100 if ($reshook >= 0) {
1101 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1102 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1103 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1106 if ($bankaccountid > 0) {
1107 $label =
'(CustomerInvoicePayment)';
1109 $label =
'(CustomerInvoicePaymentBack)';
1111 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1113 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1114 $ispostactionok = -1;
1117 $postactionmessages[] =
'Bank transaction of payment created';
1118 $ispostactionok = 1;
1121 $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.';
1122 $ispostactionok = -1;
1133 $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.';
1134 $ispostactionok = -1;
1137 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1138 $ispostactionok = -1;
1140 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1141 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1143 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1145 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1147 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1150 if ($paymentmethod ==
'paybox') {
1153 if ($paymentmethod ==
'paypal') {
1156 if ($paymentmethod ==
'stripe') {
1159 if (empty($paymentTypeId)) {
1160 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1162 if (empty($paymentType)) {
1163 $paymentType =
'CB';
1167 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1170 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1175 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1178 if (isModEnabled(
'invoice')) {
1179 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1182 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1184 $result = $invoice->createFromOrder($object, $user);
1186 if ($FinalPaymentAmt !=
$object->total_ttc) {
1194 $object->classifyBilled($user);
1196 $invoice->validate($user);
1199 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1201 $paiement->datepaye = $now;
1202 if ($currencyCodeType ==
$conf->currency) {
1203 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1205 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1207 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1208 $ispostactionok = -1;
1211 $paiement->paiementid = $paymentTypeId;
1212 $paiement->num_payment =
'';
1213 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1214 $paiement->ext_payment_id = $TRANSACTIONID;
1215 $paiement->ext_payment_site = $service;
1218 $paiement_id = $paiement->create($user, 1);
1219 if ($paiement_id < 0) {
1220 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1221 $ispostactionok = -1;
1224 $postactionmessages[] =
'Payment created';
1225 $ispostactionok = 1;
1229 if (!$error && isModEnabled(
"bank")) {
1231 if ($paymentmethod ==
'paybox') {
1233 } elseif ($paymentmethod ==
'paypal') {
1235 } elseif ($paymentmethod ==
'stripe') {
1241 'paymentmethod' => $paymentmethod,
1243 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1244 if ($reshook >= 0) {
1245 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1246 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1247 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1250 if ($bankaccountid > 0) {
1251 $label =
'(CustomerInvoicePayment)';
1253 $label =
'(CustomerInvoicePaymentBack)';
1255 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1257 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1258 $ispostactionok = -1;
1261 $postactionmessages[] =
'Bank transaction of payment created';
1262 $ispostactionok = 1;
1265 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1266 $ispostactionok = -1;
1271 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1272 $ispostactionok = -1;
1282 $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.';
1283 $ispostactionok = -1;
1286 $postactionmessages[] =
'Invoice module is not enable';
1287 $ispostactionok = -1;
1290 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1291 $ispostactionok = -1;
1293 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1294 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1295 $don =
new Don($db);
1296 $result = $don->fetch((
int) $tmptag[
'DON']);
1299 if ($paymentmethod ==
'paybox') {
1302 if ($paymentmethod ==
'paypal') {
1303 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1305 if ($paymentmethod ==
'stripe') {
1308 if (empty($paymentTypeId)) {
1309 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1311 if (empty($paymentType)) {
1312 $paymentType =
'CB';
1316 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1319 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1325 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1329 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1332 $totalpaid = $FinalPaymentAmt;
1334 if ($currencyCodeType ==
$conf->currency) {
1335 $paiement->amounts = array(
$object->id => $totalpaid);
1338 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1339 $ispostactionok = -1;
1343 $paiement->fk_donation = $don->id;
1344 $paiement->datep = $now;
1345 $paiement->paymenttype = $paymentTypeId;
1346 $paiement->num_payment =
'';
1347 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1348 $paiement->ext_payment_id = $TRANSACTIONID;
1349 $paiement->ext_payment_site = $service;
1352 $paiement_id = $paiement->create($user, 1);
1353 if ($paiement_id < 0) {
1354 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1355 $ispostactionok = -1;
1358 $postactionmessages[] =
'Payment created';
1359 $ispostactionok = 1;
1361 if ($totalpaid >= $don->getRemainToPay()) {
1362 $don->valid_promesse($don->id, $user->id);
1363 $don->setPaid($don->id);
1368 if (!$error && isModEnabled(
"bank")) {
1370 if ($paymentmethod ==
'paybox') {
1372 } elseif ($paymentmethod ==
'paypal') {
1374 } elseif ($paymentmethod ==
'stripe') {
1380 'paymentmethod' => $paymentmethod,
1382 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1383 if ($reshook >= 0) {
1384 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1385 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1386 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1389 if ($bankaccountid > 0) {
1390 $label =
'(DonationPayment)';
1391 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1393 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1394 $ispostactionok = -1;
1397 $postactionmessages[] =
'Bank transaction of payment created';
1398 $ispostactionok = 1;
1401 $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.';
1402 $ispostactionok = -1;
1413 $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.';
1414 $ispostactionok = -1;
1417 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1418 $ispostactionok = -1;
1423 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1425 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1426 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1427 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1429 $result =
$object->fetch((
int) $ref);
1432 if ($paymentmethod ==
'paybox') {
1435 if ($paymentmethod ==
'paypal') {
1438 if ($paymentmethod ==
'stripe') {
1441 if (empty($paymentTypeId)) {
1442 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1444 if (empty($paymentType)) {
1445 $paymentType =
'CB';
1449 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1452 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1458 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1459 $resultvalidate =
$object->validate($user);
1460 if ($resultvalidate < 0) {
1461 $postactionmessages[] =
'Cannot validate invoice';
1462 $ispostactionok = -1;
1468 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1470 $paiement->datepaye = $now;
1471 if ($currencyCodeType ==
$conf->currency) {
1472 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1474 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1476 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1477 $ispostactionok = -1;
1480 $paiement->paiementid = $paymentTypeId;
1481 $paiement->num_payment =
'';
1482 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1483 $paiement->ext_payment_id = $TRANSACTIONID;
1484 $paiement->ext_payment_site = $service;
1487 $paiement_id = $paiement->create($user, 1);
1488 if ($paiement_id < 0) {
1489 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1490 $ispostactionok = -1;
1493 $postactionmessages[] =
'Payment created';
1494 $ispostactionok = 1;
1498 if (!$error && isModEnabled(
"bank")) {
1500 if ($paymentmethod ==
'paybox') {
1502 } elseif ($paymentmethod ==
'paypal') {
1504 } elseif ($paymentmethod ==
'stripe') {
1510 'paymentmethod' => $paymentmethod,
1512 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1513 if ($reshook >= 0) {
1514 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1515 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1516 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1519 if ($bankaccountid > 0) {
1520 $label =
'(CustomerInvoicePayment)';
1522 $label =
'(CustomerInvoicePaymentBack)';
1524 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1526 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1527 $ispostactionok = -1;
1530 $postactionmessages[] =
'Bank transaction of payment created';
1531 $ispostactionok = 1;
1534 $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.';
1535 $ispostactionok = -1;
1544 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1545 if ($resultattendee < 0) {
1549 $attendeetovalidate->validate($user);
1551 $attendeetovalidate->amount = $FinalPaymentAmt;
1552 $attendeetovalidate->date_subscription =
dol_now();
1553 $attendeetovalidate->update($user);
1567 $thirdparty =
new Societe($db);
1568 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1569 if ($resultthirdparty < 0) {
1572 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1573 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1577 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string) $mysoc->default_lang : (string) $thirdparty->default_lang);
1579 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1581 $arraydefaultmessage =
null;
1583 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1585 if (!empty($idoftemplatetouse)) {
1586 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1589 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1590 $subject = $arraydefaultmessage->topic;
1591 $msg = $arraydefaultmessage->content;
1593 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1594 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1597 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1603 $sendto = $attendeetovalidate->email;
1605 if ($thirdparty->email) {
1606 $cc = $thirdparty->email ??
'';
1608 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1609 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1614 $urlback = $_SERVER[
"REQUEST_URI"];
1620 $listofpaths = array();
1621 $listofnames = array();
1622 $listofmimes = array();
1623 if (is_object($object)) {
1624 $invoicediroutput =
$conf->facture->dir_output;
1626 $file = $fileparams[
'fullname'];
1628 $listofpaths = array($file);
1629 $listofnames = array(basename($file));
1633 $trackid =
'inv'.$object->id;
1635 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1637 $result = $mailfile->sendfile();
1639 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1641 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1647 $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.';
1648 $ispostactionok = -1;
1651 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1652 $ispostactionok = -1;
1654 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1656 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1657 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1658 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1660 $result =
$object->fetch((
int) $ref);
1662 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1665 if ($paymentmethod ==
'paybox') {
1668 if ($paymentmethod ==
'paypal') {
1671 if ($paymentmethod ==
'stripe') {
1674 if (empty($paymentTypeId)) {
1675 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1677 if (empty($paymentType)) {
1678 $paymentType =
'CB';
1682 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1685 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1691 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1692 $resultvalidate =
$object->validate($user);
1693 if ($resultvalidate < 0) {
1694 $postactionmessages[] =
'Cannot validate invoice';
1695 $ispostactionok = -1;
1701 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1703 $paiement->datepaye = $now;
1704 if ($currencyCodeType ==
$conf->currency) {
1705 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1707 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1709 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1710 $ispostactionok = -1;
1713 $paiement->paiementid = $paymentTypeId;
1714 $paiement->num_payment =
'';
1715 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1716 $paiement->ext_payment_id = $TRANSACTIONID;
1717 $paiement->ext_payment_site = $service;
1720 $paiement_id = $paiement->create($user, 1);
1721 if ($paiement_id < 0) {
1722 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1723 $ispostactionok = -1;
1726 $postactionmessages[] =
'Payment created';
1727 $ispostactionok = 1;
1731 if (!$error && isModEnabled(
"bank")) {
1733 if ($paymentmethod ==
'paybox') {
1735 } elseif ($paymentmethod ==
'paypal') {
1737 } elseif ($paymentmethod ==
'stripe') {
1743 'paymentmethod' => $paymentmethod,
1745 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1746 if ($reshook >= 0) {
1747 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1748 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1749 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1752 if ($bankaccountid > 0) {
1753 $label =
'(CustomerInvoicePayment)';
1755 $label =
'(CustomerInvoicePaymentBack)';
1757 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1759 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1760 $ispostactionok = -1;
1763 $postactionmessages[] =
'Bank transaction of payment created';
1764 $ispostactionok = 1;
1767 $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.';
1768 $ispostactionok = -1;
1775 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1776 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1778 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1779 if ($resultbooth < 0) {
1783 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1784 $resultboothupdate = $booth->update($user);
1785 if ($resultboothupdate < 0) {
1788 $resultinvoice = $invoice->fetch((
int) $ref);
1789 if ($resultinvoice < 0) {
1790 $postactionmessages[] =
'Could not find the associated invoice.';
1791 $ispostactionok = -1;
1794 $thirdparty =
new Societe($db);
1795 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1796 if ($resultthirdparty < 0) {
1803 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1804 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1808 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
1810 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1812 $arraydefaultmessage =
null;
1814 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1816 if (!empty($idoftemplatetouse)) {
1817 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1820 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1821 $subject = $arraydefaultmessage->topic;
1822 $msg = $arraydefaultmessage->content;
1824 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1825 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1828 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1834 $sendto = $thirdparty->email;
1836 $urlback = $_SERVER[
"REQUEST_URI"];
1839 $trackid =
'inv'.$invoice->id;
1841 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1843 $result = $mailfile->sendfile();
1845 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1847 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1862 $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.';
1863 $ispostactionok = -1;
1866 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1867 $ispostactionok = -1;
1869 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1870 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1872 $result =
$object->fetch((
int) $tmptag[
'CON']);
1874 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1877 if ($paymentmethod ==
'paybox') {
1880 if ($paymentmethod ==
'paypal') {
1883 if ($paymentmethod ==
'stripe') {
1886 if (empty($paymentTypeId)) {
1887 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1889 if (empty($paymentType)) {
1890 $paymentType =
'CB';
1894 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1897 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1902 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1903 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1906 if (isModEnabled(
'invoice')) {
1907 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1910 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1912 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1915 $invoice->validate($user);
1917 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1919 $paiement->datepaye = $now;
1920 if ($currencyCodeType ==
$conf->currency) {
1921 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1923 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1925 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1926 $ispostactionok = -1;
1929 $paiement->paiementid = $paymentTypeId;
1930 $paiement->num_payment =
'';
1931 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1932 $paiement->ext_payment_id = $TRANSACTIONID;
1933 $paiement->ext_payment_site = $service;
1936 $paiement_id = $paiement->create($user, 1);
1937 if ($paiement_id < 0) {
1938 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1939 $ispostactionok = -1;
1942 $postactionmessages[] =
'Payment created';
1943 $ispostactionok = 1;
1947 if (!$error && isModEnabled(
"bank")) {
1949 if ($paymentmethod ==
'paybox') {
1951 } elseif ($paymentmethod ==
'paypal') {
1953 } elseif ($paymentmethod ==
'stripe') {
1959 'paymentmethod' => $paymentmethod,
1961 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1962 if ($reshook >= 0) {
1963 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1964 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1965 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1968 if ($bankaccountid > 0) {
1969 $label =
'(CustomerInvoicePayment)';
1971 $label =
'(CustomerInvoicePaymentBack)';
1973 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1975 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1976 $ispostactionok = -1;
1979 $postactionmessages[] =
'Bank transaction of payment created';
1980 $ispostactionok = 1;
1983 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1984 $ispostactionok = -1;
1989 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
1990 if (!empty($tmptag[
'COL'])) {
1991 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
1993 $postactionmessages[] = $msg;
1994 $ispostactionok = -1;
2004 $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.';
2005 $ispostactionok = -1;
2008 $postactionmessages[] =
'Invoice module is not enable';
2009 $ispostactionok = -1;
2012 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2013 if (!empty($tmptag[
'COL'])) {
2014 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2016 $postactionmessages[] = $msg;
2017 $ispostactionok = -1;
2024dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2028 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2029 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2031 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2032 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2033 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2035 if (is_object($object) && method_exists($object,
'call_trigger')) {
2036 '@phan-var-force CommonObject $object';
2038 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2043 } elseif (get_class($object) ==
'stdClass') {
2045 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2047 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2056if (empty($doactionsthenredirect)) {
2058 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2059 if ($TRANSACTIONID) {
2060 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
2064 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2068 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2074 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2075 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2076 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2077 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2078 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2080 if ($mysoc->email) {
2081 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2093 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2098 $myCompanyDefaultLang = (string) $mysoc->default_lang;
2099 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2106 $companylangs->setDefaultLang($myCompanyDefaultLang);
2107 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2109 $sendto = $sendemail;
2112 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2113 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2118 $urlback = $_SERVER[
"REQUEST_URI"];
2119 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2121 if (array_key_exists(
'MEM', $tmptag)) {
2122 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2123 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2124 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2125 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2126 } elseif (array_key_exists(
'INV', $tmptag)) {
2127 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2128 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2129 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2131 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2133 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2135 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2136 if ($ispostactionok > 0) {
2138 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2139 } elseif ($ispostactionok == 0) {
2140 $content .= $companylangs->transnoentitiesnoconv(
"None");
2142 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2143 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2145 $content .=
'<br>'.
"\n";
2146 foreach ($postactionmessages as $postactionmessage) {
2147 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2149 if ($ispostactionok < 0) {
2150 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2152 $content .=
'<br>'.
"\n";
2154 $content .=
"<br>\n";
2155 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2156 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2157 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2158 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2159 $content .=
"<br>\n";
2160 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2162 if (!empty($ErrorCode)) {
2163 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2165 if (!empty($ErrorShortMsg)) {
2166 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2168 if (!empty($ErrorLongMsg)) {
2169 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2171 if (!empty($ErrorSeverityCode)) {
2172 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2175 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2180 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2181 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2183 $result = $mailfile->sendfile();
2185 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2188 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2196 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2197 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2199 $paymentType = $_SESSION[
'PaymentType'];
2200 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2201 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2203 if (is_object($object) && method_exists($object,
'call_trigger')) {
2205 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2215 $companylangs->setDefaultLang($mysoc->default_lang);
2216 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2218 $sendto = $sendemail;
2221 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2222 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2225 $urlback = $_SERVER[
"REQUEST_URI"];
2226 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2228 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2230 $content .=
"<br><br>\n";
2231 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2232 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2233 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2234 $content .=
"<br>\n";
2235 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2241 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2242 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2244 $result = $mailfile->sendfile();
2246 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2248 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2255unset($_SESSION[
"FinalPaymentAmt"]);
2256unset($_SESSION[
"TRANSACTIONID"]);
2260if (empty($doactionsthenredirect)) {
2263 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2268if (empty($doactionsthenredirect)) {
2279if (!empty($doactionsthenredirect)) {
2283 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2286 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2287 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2289 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2292 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2293 header(
"Location: ".$ext_urlok);
2298 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2301 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2302 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2304 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2307 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2308 header(
"Location: ".$ext_urlko);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 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)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0)
Return file(s) into a directory (by default most recent)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.