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');
364 dol_print_error(
null,
'Session expired');
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');
372 dol_print_error(
null,
'PAYPALTOKEN not defined');
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';
410 $stripe =
new Stripe($db);
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');
462 setEventMessages($e->getMessage(),
null,
'errors');
465 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
466 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
467 setEventMessages($e->getMessage(),
null,
'errors');
471 $errmsg =
'Stripe API error: ' . $e->getMessage();
476 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
478 setEventMessages($errmsg,
null,
'errors');
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'];
502 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
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');
543$postactionmessages = array();
546 if (empty($user->rights->societe)) {
547 $user->rights->societe =
new stdClass();
549 if (empty($user->rights->facture)) {
550 $user->rights->facture =
new stdClass();
551 $user->rights->facture->invoice_advance =
new stdClass();
553 if (empty($user->rights->adherent)) {
554 $user->rights->adherent =
new stdClass();
555 $user->rights->adherent->cotisation =
new stdClass();
557 $user->rights->societe->creer = 1;
558 $user->rights->facture->creer = 1;
559 $user->rights->facture->invoice_advance->validate = 1;
560 $user->rights->adherent->cotisation->creer = 1;
562 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
569 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
570 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
571 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
575 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
576 $result2 = $adht->fetch(
$object->typeid);
578 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
579 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
581 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
583 if ($result1 > 0 && $result2 > 0) {
584 if ($paymentmethod ==
'paybox') {
587 if ($paymentmethod ==
'paypal') {
590 if ($paymentmethod ==
'stripe') {
593 if (empty($paymentTypeId)) {
594 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
596 if (empty($paymentType)) {
601 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
604 if (empty($paymentTypeId) || $paymentTypeId < 0) {
609 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
612 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
614 $amountbytype = $adht->amountByType(1);
615 $minimumamountbytype = $adht->minimumamountbytype(1);
616 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
618 if (empty($adht->caneditamount)) {
619 if (
$object->status == $object::STATUS_DRAFT) {
622 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
628 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), (
float) $minimumamount);
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');
642 if ($FinalPaymentAmt <
getDolGlobalInt(
'MEMBER_MIN_AMOUNT') || $FinalPaymentAmt < $minimumamount) {
644 $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 ?';
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);
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');
672 if (empty(
$object->datevalid)) {
673 dol_syslog(
"Member date of validation is empty. We define it", LOG_WARNING, 0,
'_payment');
675 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent SET";
676 $sql .=
" datevalid = '".$db->idate($now).
"'";
677 $sql .=
" WHERE rowid = ".((int)
$object->id);
678 $result = $db->query($sql);
682 $errmsg = $db->error();
683 $postactionmessages[] = $errmsg;
685 $ispostactionok = -1;
686 dol_syslog(
"Failed to set date of validation: ".$errmsg, LOG_ERR, 0,
'_payment');
692 $datesubscription =
$object->datevalid;
709 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
712 while ($datesubend < $now) {
714 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
721 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string)
$object->thirdparty->default_lang);
723 $amount = $FinalPaymentAmt;
724 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
725 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
729 if ($paymentmethod ==
'paybox') {
732 if ($paymentmethod ==
'paypal') {
735 if ($paymentmethod ==
'stripe') {
741 'paymentmethod' => $paymentmethod,
743 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
745 if (isset($hookmanager->resArray[
'bankaccountid'])) {
746 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
747 $accountid = $hookmanager->resArray[
'bankaccountid'];
750 if ($accountid < 0) {
752 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
753 $postactionmessages[] = $errmsg;
754 $ispostactionok = -1;
755 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
758 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
761 $emetteur_banque =
'';
765 $option =
'bankviainvoice';
767 $option =
'bankdirect';
769 $option =
'invoiceonly';
771 if (empty($option)) {
782 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
784 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
788 $postactionmessages[] = $errmsg;
789 $ispostactionok = -1;
791 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
796 $autocreatethirdparty = 0;
799 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
801 $autocreatethirdparty = 1;
803 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
808 $postactionmessages[] =
$object->error;
809 $postactionmessages = array_merge($postactionmessages,
$object->errors);
810 $ispostactionok = -1;
812 if ($option ==
'bankviainvoice') {
813 $postactionmessages[] =
'Invoice, payment and bank record created';
814 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
816 if ($option ==
'bankdirect') {
817 $postactionmessages[] =
'Bank record created';
818 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
820 if ($option ==
'invoiceonly') {
821 $postactionmessages[] =
'Invoice recorded';
822 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
832 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
835 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
837 $service =
'StripeTest';
840 $service =
'StripeLive';
845 $thirdparty =
new Societe($db);
846 $thirdparty->fetch($thirdparty_id);
848 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
849 $stripe =
new Stripe($db);
852 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
854 if (!$customer && $TRANSACTIONID) {
855 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
858 global $stripearrayofkeysbyenv;
859 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
861 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
863 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
866 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
870 $stripecu = $chpi->customer;
872 if (empty($stripecu)) {
874 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
877 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
878 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
881 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
882 $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)";
883 $resql = $db->query($sql);
886 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
888 $postactionmessages[] = $errmsg;
889 $ispostactionok = -1;
894 $errmsg =
'Failed to retrieve paymentintent or charge from id';
896 $postactionmessages[] = $errmsg;
897 $ispostactionok = -1;
901 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
903 $postactionmessages[] = $errmsg;
904 $ispostactionok = -1;
921 $nuser =
new User($db);
926 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
927 $resqlcount = $db->query($sql);
929 $objcount = $db->fetch_object($resqlcount);
931 $found = $objcount->nb;
936 $result = $nuser->create_from_member($tmpuser,
$object->login);
937 $newpassword = $nuser->setPassword($user,
'');
940 $outputlangs->load(
"errors");
941 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
943 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
944 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
947 $outputlangs->load(
"errors");
948 $postactionmessages[] =
'No user created because a user linked to member already exists';
954 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
957 if (
$object->email && $sendalsoemail) {
962 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
965 $outputlangs->loadLangs(array(
"main",
"members"));
967 $arraydefaultmessage =
null;
970 if (!empty($labeltouse)) {
971 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
974 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
975 $subject = $arraydefaultmessage->topic;
976 $msg = $arraydefaultmessage->content;
979 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
981 if ($infouserlogin) {
982 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
991 $listofpaths = array();
992 $listofnames = array();
993 $listofmimes = array();
994 if (is_object(
$object->invoice)) {
995 $invoicediroutput =
$conf->facture->dir_output;
997 $file = $fileparams[
'fullname'];
999 $listofpaths = array($file);
1000 $listofnames = array(basename($file));
1004 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
1006 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
1010 $postactionmessages[] = $errmsg;
1011 $ispostactionok = -1;
1014 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
1016 $postactionmessages[] =
'Email sent to member (without any attached document)';
1024 $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.';
1025 $ispostactionok = -1;
1028 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1029 $ispostactionok = -1;
1031 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1033 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1036 $result =
$object->fetch((
int) $tmptag[
'INV']);
1038 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1041 if ($paymentmethod ===
'paybox') {
1044 if ($paymentmethod ===
'paypal') {
1047 if ($paymentmethod ===
'stripe') {
1050 if (empty($paymentTypeId)) {
1051 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1053 if (empty($paymentType)) {
1054 $paymentType =
'CB';
1058 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1061 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1066 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1069 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1073 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1075 $paiement->datepaye = $now;
1076 if ($currencyCodeType ==
$conf->currency) {
1077 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1079 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1081 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1082 $ispostactionok = -1;
1085 $paiement->paiementid = $paymentTypeId;
1086 $paiement->num_payment =
'';
1087 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1090 if ($LONGTRANSACTIONID) {
1091 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1093 $paiement->ext_payment_id = $TRANSACTIONID;
1095 $paiement->ext_payment_site = $service;
1099 $result =
$object->validate($user);
1101 $postactionmessages[] =
$object->error;
1102 $ispostactionok = -1;
1105 $postactionmessages[] =
'Invoice validated';
1106 $ispostactionok = 1;
1111 $paiement_id = $paiement->create($user, 1);
1112 if ($paiement_id < 0) {
1113 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1114 $ispostactionok = -1;
1117 $postactionmessages[] =
'Payment created';
1118 $ispostactionok = 1;
1124 if ($paymentmethod ==
'paybox') {
1126 } elseif ($paymentmethod ==
'paypal') {
1128 } elseif ($paymentmethod ==
'stripe') {
1134 'paymentmethod' => $paymentmethod,
1136 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1137 if ($reshook >= 0) {
1138 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1139 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1140 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1143 if ($bankaccountid > 0) {
1144 $label =
'(CustomerInvoicePayment)';
1146 $label =
'(CustomerInvoicePaymentBack)';
1148 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1150 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1151 $ispostactionok = -1;
1154 $postactionmessages[] =
'Bank transaction of payment created';
1155 $ispostactionok = 1;
1158 $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.';
1159 $ispostactionok = -1;
1170 $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.';
1171 $ispostactionok = -1;
1174 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1175 $ispostactionok = -1;
1177 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1178 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1180 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1182 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1184 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1187 if ($paymentmethod ==
'paybox') {
1190 if ($paymentmethod ==
'paypal') {
1193 if ($paymentmethod ==
'stripe') {
1196 if (empty($paymentTypeId)) {
1197 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1199 if (empty($paymentType)) {
1200 $paymentType =
'CB';
1204 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1207 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1212 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1216 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1219 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1221 $result = $invoice->createFromOrder($object, $user);
1223 if ($FinalPaymentAmt !=
$object->total_ttc) {
1231 $object->classifyBilled($user);
1233 $invoice->validate($user);
1236 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1238 $paiement->datepaye = $now;
1239 if ($currencyCodeType ==
$conf->currency) {
1240 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1242 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1244 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1245 $ispostactionok = -1;
1248 $paiement->paiementid = $paymentTypeId;
1249 $paiement->num_payment =
'';
1250 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1253 if ($LONGTRANSACTIONID) {
1254 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1256 $paiement->ext_payment_id = $TRANSACTIONID;
1258 $paiement->ext_payment_site = $service;
1261 $paiement_id = $paiement->create($user, 1);
1262 if ($paiement_id < 0) {
1263 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1264 $ispostactionok = -1;
1267 $postactionmessages[] =
'Payment created';
1268 $ispostactionok = 1;
1274 if ($paymentmethod ==
'paybox') {
1276 } elseif ($paymentmethod ==
'paypal') {
1278 } elseif ($paymentmethod ==
'stripe') {
1284 'paymentmethod' => $paymentmethod,
1286 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1287 if ($reshook >= 0) {
1288 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1289 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1290 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1293 if ($bankaccountid > 0) {
1294 $label =
'(CustomerInvoicePayment)';
1296 $label =
'(CustomerInvoicePaymentBack)';
1298 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1300 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1301 $ispostactionok = -1;
1304 $postactionmessages[] =
'Bank transaction of payment created';
1305 $ispostactionok = 1;
1308 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1309 $ispostactionok = -1;
1314 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1315 $ispostactionok = -1;
1325 $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.';
1326 $ispostactionok = -1;
1329 $postactionmessages[] =
'Invoice module is not enable';
1330 $ispostactionok = -1;
1333 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1334 $ispostactionok = -1;
1336 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1337 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1338 $don =
new Don($db);
1339 $result = $don->fetch((
int) $tmptag[
'DON']);
1342 if ($paymentmethod ==
'paybox') {
1345 if ($paymentmethod ==
'paypal') {
1348 if ($paymentmethod ==
'stripe') {
1351 if (empty($paymentTypeId)) {
1352 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1354 if (empty($paymentType)) {
1355 $paymentType =
'CB';
1359 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1362 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1368 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1372 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1375 $totalpaid = $FinalPaymentAmt;
1377 if ($currencyCodeType ==
$conf->currency) {
1378 $paiement->amounts = array(
$object->id => $totalpaid);
1381 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1382 $ispostactionok = -1;
1386 $paiement->fk_donation = $don->id;
1387 $paiement->datep = $now;
1388 $paiement->paymenttype = $paymentTypeId;
1389 $paiement->num_payment =
'';
1390 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1393 if ($LONGTRANSACTIONID) {
1394 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1396 $paiement->ext_payment_id = $TRANSACTIONID;
1398 $paiement->ext_payment_site = $service;
1401 $paiement_id = $paiement->create($user, 1);
1402 if ($paiement_id < 0) {
1403 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1404 $ispostactionok = -1;
1407 $postactionmessages[] =
'Payment created';
1408 $ispostactionok = 1;
1410 if ($totalpaid >= $don->getRemainToPay()) {
1411 $don->valid_promesse($don->id, $user->id);
1412 $don->setPaid($don->id);
1419 if ($paymentmethod ==
'paybox') {
1421 } elseif ($paymentmethod ==
'paypal') {
1423 } elseif ($paymentmethod ==
'stripe') {
1429 'paymentmethod' => $paymentmethod,
1431 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1432 if ($reshook >= 0) {
1433 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1434 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1435 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1438 if ($bankaccountid > 0) {
1439 $label =
'(DonationPayment)';
1440 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1442 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1443 $ispostactionok = -1;
1446 $postactionmessages[] =
'Bank transaction of payment created';
1447 $ispostactionok = 1;
1450 $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.';
1451 $ispostactionok = -1;
1462 $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.';
1463 $ispostactionok = -1;
1466 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1467 $ispostactionok = -1;
1472 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1474 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1475 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1476 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1478 $result =
$object->fetch((
int) $ref);
1481 if ($paymentmethod ==
'paybox') {
1484 if ($paymentmethod ==
'paypal') {
1487 if ($paymentmethod ==
'stripe') {
1490 if (empty($paymentTypeId)) {
1491 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1493 if (empty($paymentType)) {
1494 $paymentType =
'CB';
1498 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1501 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1507 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1508 $resultvalidate =
$object->validate($user);
1509 if ($resultvalidate < 0) {
1510 $postactionmessages[] =
'Cannot validate invoice';
1511 $ispostactionok = -1;
1517 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1519 $paiement->datepaye = $now;
1520 if ($currencyCodeType ==
$conf->currency) {
1521 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1523 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1525 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1526 $ispostactionok = -1;
1529 $paiement->paiementid = $paymentTypeId;
1530 $paiement->num_payment =
'';
1531 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1534 if ($LONGTRANSACTIONID) {
1535 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1537 $paiement->ext_payment_id = $TRANSACTIONID;
1539 $paiement->ext_payment_site = $service;
1542 $paiement_id = $paiement->create($user, 1);
1543 if ($paiement_id < 0) {
1544 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1545 $ispostactionok = -1;
1548 $postactionmessages[] =
'Payment created';
1549 $ispostactionok = 1;
1555 if ($paymentmethod ==
'paybox') {
1557 } elseif ($paymentmethod ==
'paypal') {
1559 } elseif ($paymentmethod ==
'stripe') {
1565 'paymentmethod' => $paymentmethod,
1567 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1568 if ($reshook >= 0) {
1569 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1570 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1571 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1574 if ($bankaccountid > 0) {
1575 $label =
'(CustomerInvoicePayment)';
1577 $label =
'(CustomerInvoicePaymentBack)';
1579 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1581 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1582 $ispostactionok = -1;
1585 $postactionmessages[] =
'Bank transaction of payment created';
1586 $ispostactionok = 1;
1589 $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.';
1590 $ispostactionok = -1;
1599 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1600 if ($resultattendee < 0) {
1602 setEventMessages(
null, $attendeetovalidate->errors,
"errors");
1604 $attendeetovalidate->validate($user);
1606 $attendeetovalidate->amount = $FinalPaymentAmt;
1607 $attendeetovalidate->date_subscription =
dol_now();
1608 $attendeetovalidate->update($user);
1615 setEventMessages(
null, $postactionmessages,
'warnings');
1622 $thirdparty =
new Societe($db);
1623 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1624 if ($resultthirdparty < 0) {
1625 setEventMessages($thirdparty->error, $thirdparty->errors,
"errors");
1627 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1628 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1632 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string) $thirdparty->default_lang);
1634 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1636 $arraydefaultmessage =
null;
1638 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1640 if (!empty($idoftemplatetouse)) {
1641 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1644 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1645 $subject = $arraydefaultmessage->topic;
1646 $msg = $arraydefaultmessage->content;
1648 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1649 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1652 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1658 $sendto = $attendeetovalidate->email;
1660 if ($thirdparty->email) {
1661 $cc = $thirdparty->email ??
'';
1663 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1664 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1669 $urlback = $_SERVER[
"REQUEST_URI"];
1675 $listofpaths = array();
1676 $listofnames = array();
1677 $listofmimes = array();
1678 if (is_object($object)) {
1679 $invoicediroutput =
$conf->facture->dir_output;
1681 $file = $fileparams[
'fullname'];
1683 $listofpaths = array($file);
1684 $listofnames = array(basename($file));
1688 $trackid =
'inv'.$object->id;
1690 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1692 $result = $mailfile->sendfile();
1694 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1696 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1702 $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.';
1703 $ispostactionok = -1;
1706 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1707 $ispostactionok = -1;
1709 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1711 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1712 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1713 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1715 $result =
$object->fetch((
int) $ref);
1717 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1720 if ($paymentmethod ==
'paybox') {
1723 if ($paymentmethod ==
'paypal') {
1726 if ($paymentmethod ==
'stripe') {
1729 if (empty($paymentTypeId)) {
1730 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1732 if (empty($paymentType)) {
1733 $paymentType =
'CB';
1737 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1740 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1746 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1747 $resultvalidate =
$object->validate($user);
1748 if ($resultvalidate < 0) {
1749 $postactionmessages[] =
'Cannot validate invoice';
1750 $ispostactionok = -1;
1756 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1758 $paiement->datepaye = $now;
1759 if ($currencyCodeType ==
$conf->currency) {
1760 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1762 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1764 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1765 $ispostactionok = -1;
1768 $paiement->paiementid = $paymentTypeId;
1769 $paiement->num_payment =
'';
1770 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1773 if ($LONGTRANSACTIONID) {
1774 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1776 $paiement->ext_payment_id = $TRANSACTIONID;
1778 $paiement->ext_payment_site = $service;
1781 $paiement_id = $paiement->create($user, 1);
1782 if ($paiement_id < 0) {
1783 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1784 $ispostactionok = -1;
1787 $postactionmessages[] =
'Payment created';
1788 $ispostactionok = 1;
1794 if ($paymentmethod ==
'paybox') {
1796 } elseif ($paymentmethod ==
'paypal') {
1798 } elseif ($paymentmethod ==
'stripe') {
1804 'paymentmethod' => $paymentmethod,
1806 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1807 if ($reshook >= 0) {
1808 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1809 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1810 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1813 if ($bankaccountid > 0) {
1814 $label =
'(CustomerInvoicePayment)';
1816 $label =
'(CustomerInvoicePaymentBack)';
1818 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1820 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1821 $ispostactionok = -1;
1824 $postactionmessages[] =
'Bank transaction of payment created';
1825 $ispostactionok = 1;
1828 $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.';
1829 $ispostactionok = -1;
1836 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1837 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1839 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1840 if ($resultbooth < 0) {
1842 setEventMessages(
null, $booth->errors,
"errors");
1844 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1845 $resultboothupdate = $booth->update($user);
1846 if ($resultboothupdate < 0) {
1849 $resultinvoice = $invoice->fetch((
int) $ref);
1850 if ($resultinvoice < 0) {
1851 $postactionmessages[] =
'Could not find the associated invoice.';
1852 $ispostactionok = -1;
1855 $thirdparty =
new Societe($db);
1856 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1857 if ($resultthirdparty < 0) {
1859 setEventMessages(
null, $thirdparty->errors,
"errors");
1864 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1865 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1869 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1871 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1873 $arraydefaultmessage =
null;
1875 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1877 if (!empty($idoftemplatetouse)) {
1878 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1881 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1882 $subject = $arraydefaultmessage->topic;
1883 $msg = $arraydefaultmessage->content;
1885 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1886 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1889 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1895 $sendto = $thirdparty->email;
1897 $urlback = $_SERVER[
"REQUEST_URI"];
1900 $trackid =
'inv'.$invoice->id;
1902 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1904 $result = $mailfile->sendfile();
1906 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1908 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1923 $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.';
1924 $ispostactionok = -1;
1927 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1928 $ispostactionok = -1;
1930 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1931 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1933 $result =
$object->fetch((
int) $tmptag[
'CON']);
1935 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1938 if ($paymentmethod ==
'paybox') {
1941 if ($paymentmethod ==
'paypal') {
1944 if ($paymentmethod ==
'stripe') {
1947 if (empty($paymentTypeId)) {
1948 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1950 if (empty($paymentType)) {
1951 $paymentType =
'CB';
1955 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1958 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1963 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1964 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1968 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1971 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1973 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1976 $invoice->validate($user);
1978 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1980 $paiement->datepaye = $now;
1981 if ($currencyCodeType ==
$conf->currency) {
1982 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1984 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1986 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1987 $ispostactionok = -1;
1990 $paiement->paiementid = $paymentTypeId;
1991 $paiement->num_payment =
'';
1992 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1995 if ($LONGTRANSACTIONID) {
1996 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1998 $paiement->ext_payment_id = $TRANSACTIONID;
2000 $paiement->ext_payment_site = $service;
2003 $paiement_id = $paiement->create($user, 1);
2004 if ($paiement_id < 0) {
2005 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2006 $ispostactionok = -1;
2009 $postactionmessages[] =
'Payment created';
2010 $ispostactionok = 1;
2016 if ($paymentmethod ==
'paybox') {
2018 } elseif ($paymentmethod ==
'paypal') {
2020 } elseif ($paymentmethod ==
'stripe') {
2026 'paymentmethod' => $paymentmethod,
2028 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2029 if ($reshook >= 0) {
2030 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2031 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2032 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2035 if ($bankaccountid > 0) {
2036 $label =
'(CustomerInvoicePayment)';
2038 $label =
'(CustomerInvoicePaymentBack)';
2040 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2042 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2043 $ispostactionok = -1;
2046 $postactionmessages[] =
'Bank transaction of payment created';
2047 $ispostactionok = 1;
2050 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2051 $ispostactionok = -1;
2056 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2057 if (!empty($tmptag[
'COL'])) {
2058 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2060 $postactionmessages[] = $msg;
2061 $ispostactionok = -1;
2071 $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.';
2072 $ispostactionok = -1;
2075 $postactionmessages[] =
'Invoice module is not enable';
2076 $ispostactionok = -1;
2079 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2080 if (!empty($tmptag[
'COL'])) {
2081 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2083 $postactionmessages[] = $msg;
2084 $ispostactionok = -1;
2091dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2095 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2096 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2098 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2099 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2100 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2102 if (is_object($object) && method_exists($object,
'call_trigger')) {
2103 '@phan-var-force CommonObject $object';
2105 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2110 } elseif (get_class($object) ==
'stdClass') {
2112 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2114 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2123if (empty($doactionsthenredirect)) {
2125 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2126 if ($TRANSACTIONID) {
2127 print $langs->trans(
"ThisIsTransactionId").
" : ".$TRANSACTIONID.
"<br><br>\n";
2131 print img_picto(
'',
'tick',
'class="green fa-2x"');
2135 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2141 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2142 if ($ErrorLongMsg) {
2143 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2145 if ($ErrorShortMsg) {
2146 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2149 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2151 if ($ErrorSeverityCode) {
2152 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2156 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2168 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2173 $myCompanyDefaultLang = (string)
$mysoc->default_lang;
2174 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2181 $companylangs->setDefaultLang($myCompanyDefaultLang);
2182 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2184 $sendto = $sendemail;
2187 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2188 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2193 $urlback = $_SERVER[
"REQUEST_URI"];
2194 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2196 if (array_key_exists(
'MEM', $tmptag)) {
2197 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2198 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2199 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2200 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2201 } elseif (array_key_exists(
'INV', $tmptag)) {
2202 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2203 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2204 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2206 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2208 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2210 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2211 if ($ispostactionok > 0) {
2213 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2214 } elseif ($ispostactionok == 0) {
2215 $content .= $companylangs->transnoentitiesnoconv(
"None");
2217 $topic .=
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')';
2218 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2220 $content .=
'<br>'.
"\n";
2221 foreach ($postactionmessages as $postactionmessage) {
2222 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2224 if ($ispostactionok < 0) {
2225 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2227 $content .=
'<br>'.
"\n";
2229 $content .=
"<br>\n";
2230 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2231 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2232 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</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";
2237 if (!empty($ErrorCode)) {
2238 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2240 if (!empty($ErrorShortMsg)) {
2241 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2243 if (!empty($ErrorLongMsg)) {
2244 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2246 if (!empty($ErrorSeverityCode)) {
2247 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2250 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2255 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2256 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2258 $result = $mailfile->sendfile();
2260 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2263 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2271 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2272 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2274 $paymentType = $_SESSION[
'PaymentType'];
2275 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2276 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2278 if (is_object($object) && method_exists($object,
'call_trigger')) {
2280 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2290 $companylangs->setDefaultLang(
$mysoc->default_lang);
2291 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2293 $sendto = $sendemail;
2296 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2297 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2300 $urlback = $_SERVER[
"REQUEST_URI"];
2301 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2303 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2305 $content .=
"<br><br>\n";
2306 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2307 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2308 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2309 $content .=
"<br>\n";
2310 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2316 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2317 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2319 $result = $mailfile->sendfile();
2321 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2323 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2330unset($_SESSION[
"FinalPaymentAmt"]);
2331unset($_SESSION[
"TRANSACTIONID"]);
2335if (empty($doactionsthenredirect)) {
2338 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2343if (empty($doactionsthenredirect)) {
2354if (!empty($doactionsthenredirect)) {
2358 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2361 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2362 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2364 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2367 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2368 header(
"Location: ".$ext_urlok);
2373 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2376 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2377 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2379 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2382 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2383 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)
Add a delay to a date.
dol_most_recent_file($dir, $regexfilter='', $excludefilter=array('(\.meta|_preview.*\.png) $', '^\.'), $nohook=0, $mode=0, $limit=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.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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).
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)
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.