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)) {
126 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
127 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
131dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
135$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
137 dol_syslog(
"paymentok.php page is invoked from a website with ref ".$ws.
". It performs actions and then redirects back to this website. A page with ref paymentok must be created for this website.", LOG_DEBUG, 0,
'_payment');
140$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
143if (empty($validpaymentmethod)) {
149$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
150$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
160$PAYMENTSTATUS = $TRANSACTIONID = $LONGTRANSACTIONID = $TAXAMT = $NOTE =
'';
162$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
170$ws_virtuelhost =
null;
172$doactionsthenredirect = 0;
174 $doactionsthenredirect = 1;
175 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
177 $result = $website->fetch(0, $ws);
179 $ws_virtuelhost = $website->virtualhost;
180 $ws_id = $website->id;
197dol_syslog(
"Callback url when a payment was done. doactionsthenredirect=".$doactionsthenredirect.
" query_string=".(empty($_SERVER[
"QUERY_STRING"]) ?
'' :
dol_escape_htmltag($_SERVER[
"QUERY_STRING"])).
" script_uri=".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SCRIPT_URI"])), LOG_DEBUG, 0,
'_payment');
198dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
199dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
202foreach ($_POST as $k => $v) {
203 if (is_scalar($k) && is_scalar($v)) {
204 $tracepost .=
"$k=$v\n";
207dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
210foreach ($_SESSION as $k => $v) {
211 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
212 $tracesession .=
"$k=$v\n";
215dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
217dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
221 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
224$conf->dol_hide_topmenu = 1;
225$conf->dol_hide_leftmenu = 1;
229if (empty($doactionsthenredirect)) {
230 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
231 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
235 print
'<span id="dolpaymentspan"></span>'.
"\n";
236 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
241 $logosmall =
$mysoc->logo_small;
243 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
253 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
254 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
255 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
256 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
257 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
263 print
'<div class="backgreypublicpayment">';
264 print
'<div class="logopublicpayment">';
265 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
269 print
'<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans(
"PoweredBy").
'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.
'/theme/dolibarr_logo.svg" width="80px"></a></div>';
272 } elseif ($creditor) {
273 print
'<div class="backgreypublicpayment">';
274 print
'<div class="logopublicpayment">';
280 print
'<div class="backimagepublicpayment">';
281 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
286 print
'<br><br><br>';
291$service = $paymentmethod;
294if (
isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
295 if (!empty($PAYPALTOKEN)) {
298 $onlinetoken = $PAYPALTOKEN;
300 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
302 $ipaddress = $_SESSION[
'ipaddress'];
303 $currencyCodeType = $_SESSION[
'currencyCodeType'];
304 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
305 $paymentType = $_SESSION[
'PaymentType'];
307 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
310 if (!empty($paymentType)) {
311 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
315 $ack = strtoupper($resArray[
"ACK"]);
316 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
318 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
323 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
324 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
327 $ack = strtoupper($resArray2[
"ACK"]);
328 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
329 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
335 $object->resArray = $resArray2;
339 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
340 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
341 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
342 $NOTE = urldecode($resArray2[
"NOTE"]);
349 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
350 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
351 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
352 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
355 $ErrorCode =
"SESSIONEXPIRED";
356 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
357 $ErrorShortMsg =
"Session expired";
359 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
363 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
364 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
365 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
367 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
373if (
isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
375 if (empty($TRANSACTIONID)) {
376 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
377 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
379 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
382 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
383 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
385 $service =
'StripeTest';
388 $service =
'StripeLive';
395 if (empty(
GETPOST(
'payment_intent',
'alphanohtml')) &&
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
397 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
402 if (!$error && $TRANSACTIONID) {
405 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
407 $stripeacc = $stripe->getStripeAccount($service);
410 global $stripearrayofkeysbyenv;
411 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
414 if (empty($stripeacc)) {
415 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
417 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
422 $zeroDecimalCurrencies = array(
'BIF',
'CLP',
'DJF',
'GNF',
'JPY',
'KMF',
'KRW',
'MGA',
'PYG',
'RWF',
'VND',
'VUV',
'XAF',
'XOF',
'XPF');
423 if (in_array(strtoupper($currencyCodeType), $zeroDecimalCurrencies)) {
424 $expectedAmount = (int) round($FinalPaymentAmt);
426 $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;
444 if ($paymentIntent instanceof \
Stripe\PaymentIntent) {
445 $customerid = $paymentIntent->customer;
447 if (isset($stripearrayofkeysbyenv[$servicestatus][
'publishable_key'])) {
448 $pkey = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
451 if ($customerid && $pkey) {
452 $LONGTRANSACTIONID = $TRANSACTIONID.
':'.$customerid.
'@'.$pkey;
456 $errormessage =
"Stripe API error: ".$e->getMessage();
457 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
461 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
462 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
467 $errmsg =
'Stripe API error: ' . $e->getMessage();
472 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
480 $ispaymentok =
false;
485if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
489 'paymentmethod' => $paymentmethod,
491 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
493 if (isset($hookmanager->resArray[
'ispaymentok'])) {
494 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
495 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
504if (empty($ipaddress)) {
505 $ipaddress = $_SESSION[
'ipaddress'];
507if (empty($FinalPaymentAmt)) {
508 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
510if (empty($currencyCodeType)) {
511 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
513if (empty($paymentType)) {
514 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
517if (empty($TRANSACTIONID)) {
518 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
519 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
521 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
539$postactionmessages = array();
542 if (empty($user->rights->societe)) {
543 $user->rights->societe =
new stdClass();
545 if (empty($user->rights->facture)) {
546 $user->rights->facture =
new stdClass();
547 $user->rights->facture->invoice_advance =
new stdClass();
549 if (empty($user->rights->adherent)) {
550 $user->rights->adherent =
new stdClass();
551 $user->rights->adherent->cotisation =
new stdClass();
553 $user->rights->societe->creer = 1;
554 $user->rights->facture->creer = 1;
555 $user->rights->facture->invoice_advance->validate = 1;
556 $user->rights->adherent->cotisation->creer = 1;
558 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
565 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
566 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
567 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
571 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
572 $result2 = $adht->fetch(
$object->typeid);
574 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
575 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
577 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
579 if ($result1 > 0 && $result2 > 0) {
580 if ($paymentmethod ==
'paybox') {
583 if ($paymentmethod ==
'paypal') {
586 if ($paymentmethod ==
'stripe') {
589 if (empty($paymentTypeId)) {
590 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
592 if (empty($paymentType)) {
600 if (empty($paymentTypeId) || $paymentTypeId < 0) {
605 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
608 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
610 $amountbytype = $adht->amountByType(1);
611 $minimumamountbytype = $adht->minimumamountbytype(1);
612 $minimumamount = empty($minimumamountbytype[$typeid]) ? 0 : $minimumamountbytype[$typeid];
614 if (empty($adht->caneditamount)) {
615 if (
$object->status == $object::STATUS_DRAFT) {
618 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
624 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"), (
float) $minimumamount);
626 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
628 $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 ?';
629 $postactionmessages[] = $errmsg;
630 $ispostactionok = -1;
631 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
638 if ($FinalPaymentAmt <
getDolGlobalInt(
'MEMBER_MIN_AMOUNT') || $FinalPaymentAmt < $minimumamount) {
640 $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 ?';
641 $postactionmessages[] = $errmsg;
642 $ispostactionok = -1;
643 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
648 if ($currencyCodeType && $currencyCodeType !=
$conf->currency) {
650 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.
$conf->currency.
'). May be a hack to try to pay a different amount ?';
651 $postactionmessages[] = $errmsg;
652 $ispostactionok = -1;
653 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
658 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
659 if ($result < 0 || empty(
$object->datevalid)) {
662 $postactionmessages[] = $errmsg;
663 $postactionmessages = array_merge($postactionmessages,
$object->errors);
664 $ispostactionok = -1;
665 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
670 $datesubscription =
$object->datevalid;
687 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
690 while ($datesubend < $now) {
692 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
699 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (
string)
$object->thirdparty->default_lang);
701 $amount = $FinalPaymentAmt;
702 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
703 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
707 if ($paymentmethod ==
'paybox') {
710 if ($paymentmethod ==
'paypal') {
713 if ($paymentmethod ==
'stripe') {
719 'paymentmethod' => $paymentmethod,
721 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
723 if (isset($hookmanager->resArray[
'bankaccountid'])) {
724 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
725 $accountid = $hookmanager->resArray[
'bankaccountid'];
728 if ($accountid < 0) {
730 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
731 $postactionmessages[] = $errmsg;
732 $ispostactionok = -1;
733 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
739 $emetteur_banque =
'';
743 $option =
'bankviainvoice';
745 $option =
'bankdirect';
747 $option =
'invoiceonly';
749 if (empty($option)) {
760 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
762 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
766 $postactionmessages[] = $errmsg;
767 $ispostactionok = -1;
769 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
774 $autocreatethirdparty = 0;
777 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
779 $autocreatethirdparty = 1;
781 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
786 $postactionmessages[] =
$object->error;
787 $postactionmessages = array_merge($postactionmessages,
$object->errors);
788 $ispostactionok = -1;
790 if ($option ==
'bankviainvoice') {
791 $postactionmessages[] =
'Invoice, payment and bank record created';
792 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
794 if ($option ==
'bankdirect') {
795 $postactionmessages[] =
'Bank record created';
796 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
798 if ($option ==
'invoiceonly') {
799 $postactionmessages[] =
'Invoice recorded';
800 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
810 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
813 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
815 $service =
'StripeTest';
818 $service =
'StripeLive';
824 $thirdparty->fetch($thirdparty_id);
826 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
830 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
832 if (!$customer && $TRANSACTIONID) {
833 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
836 global $stripearrayofkeysbyenv;
837 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
839 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
841 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
844 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
848 $stripecu = $chpi->customer;
850 if (empty($stripecu)) {
852 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
855 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
856 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
859 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
860 $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)";
861 $resql =
$db->query($sql);
864 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
866 $postactionmessages[] = $errmsg;
867 $ispostactionok = -1;
872 $errmsg =
'Failed to retrieve paymentintent or charge from id';
874 $postactionmessages[] = $errmsg;
875 $ispostactionok = -1;
879 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
881 $postactionmessages[] = $errmsg;
882 $ispostactionok = -1;
904 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
905 $resqlcount =
$db->query($sql);
907 $objcount =
$db->fetch_object($resqlcount);
909 $found = $objcount->nb;
914 $result = $nuser->create_from_member($tmpuser,
$object->login);
915 $newpassword = $nuser->setPassword($user,
'');
918 $outputlangs->load(
"errors");
919 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
921 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
922 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
925 $outputlangs->load(
"errors");
926 $postactionmessages[] =
'No user created because a user linked to member already exists';
932 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
935 if (
$object->email && $sendalsoemail) {
940 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
943 $outputlangs->loadLangs(array(
"main",
"members"));
945 $arraydefaultmessage =
null;
948 if (!empty($labeltouse)) {
949 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
952 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
953 $subject = $arraydefaultmessage->topic;
954 $msg = $arraydefaultmessage->content;
957 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
959 if ($infouserlogin) {
960 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
969 $listofpaths = array();
970 $listofnames = array();
971 $listofmimes = array();
972 if (is_object(
$object->invoice)) {
973 $invoicediroutput =
$conf->facture->dir_output;
975 $file = $fileparams[
'fullname'];
977 $listofpaths = array($file);
978 $listofnames = array(basename($file));
979 $listofmimes = array(dol_mimetype($file));
982 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
984 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
988 $postactionmessages[] = $errmsg;
989 $ispostactionok = -1;
992 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
994 $postactionmessages[] =
'Email sent to member (without any attached document)';
1002 $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.';
1003 $ispostactionok = -1;
1006 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1007 $ispostactionok = -1;
1009 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1011 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1014 $result =
$object->fetch((
int) $tmptag[
'INV']);
1016 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1019 if ($paymentmethod ===
'paybox') {
1022 if ($paymentmethod ===
'paypal') {
1025 if ($paymentmethod ===
'stripe') {
1028 if (empty($paymentTypeId)) {
1029 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1031 if (empty($paymentType)) {
1032 $paymentType =
'CB';
1039 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1044 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1047 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1051 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1053 $paiement->datepaye = $now;
1054 if ($currencyCodeType ==
$conf->currency) {
1055 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1057 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1059 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1060 $ispostactionok = -1;
1063 $paiement->paiementid = $paymentTypeId;
1064 $paiement->num_payment =
'';
1065 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1068 if ($LONGTRANSACTIONID) {
1069 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1071 $paiement->ext_payment_id = $TRANSACTIONID;
1073 $paiement->ext_payment_site = $service;
1077 $result =
$object->validate($user);
1079 $postactionmessages[] =
$object->error;
1080 $ispostactionok = -1;
1083 $postactionmessages[] =
'Invoice validated';
1084 $ispostactionok = 1;
1089 $paiement_id = $paiement->create($user, 1);
1090 if ($paiement_id < 0) {
1091 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1092 $ispostactionok = -1;
1095 $postactionmessages[] =
'Payment created';
1096 $ispostactionok = 1;
1102 if ($paymentmethod ==
'paybox') {
1104 } elseif ($paymentmethod ==
'paypal') {
1106 } elseif ($paymentmethod ==
'stripe') {
1112 'paymentmethod' => $paymentmethod,
1114 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1115 if ($reshook >= 0) {
1116 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1117 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1118 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1121 if ($bankaccountid > 0) {
1122 $label =
'(CustomerInvoicePayment)';
1124 $label =
'(CustomerInvoicePaymentBack)';
1126 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1128 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1129 $ispostactionok = -1;
1132 $postactionmessages[] =
'Bank transaction of payment created';
1133 $ispostactionok = 1;
1136 $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.';
1137 $ispostactionok = -1;
1148 $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.';
1149 $ispostactionok = -1;
1152 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1153 $ispostactionok = -1;
1155 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1156 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1158 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1160 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1162 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1165 if ($paymentmethod ==
'paybox') {
1168 if ($paymentmethod ==
'paypal') {
1171 if ($paymentmethod ==
'stripe') {
1174 if (empty($paymentTypeId)) {
1175 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1177 if (empty($paymentType)) {
1178 $paymentType =
'CB';
1185 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1190 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1194 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1197 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1199 $result = $invoice->createFromOrder($object, $user);
1201 if ($FinalPaymentAmt !=
$object->total_ttc) {
1209 $object->classifyBilled($user);
1211 $invoice->validate($user);
1214 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1216 $paiement->datepaye = $now;
1217 if ($currencyCodeType ==
$conf->currency) {
1218 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1220 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1222 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1223 $ispostactionok = -1;
1226 $paiement->paiementid = $paymentTypeId;
1227 $paiement->num_payment =
'';
1228 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1231 if ($LONGTRANSACTIONID) {
1232 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1234 $paiement->ext_payment_id = $TRANSACTIONID;
1236 $paiement->ext_payment_site = $service;
1239 $paiement_id = $paiement->create($user, 1);
1240 if ($paiement_id < 0) {
1241 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1242 $ispostactionok = -1;
1245 $postactionmessages[] =
'Payment created';
1246 $ispostactionok = 1;
1252 if ($paymentmethod ==
'paybox') {
1254 } elseif ($paymentmethod ==
'paypal') {
1256 } elseif ($paymentmethod ==
'stripe') {
1262 'paymentmethod' => $paymentmethod,
1264 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1265 if ($reshook >= 0) {
1266 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1267 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1268 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1271 if ($bankaccountid > 0) {
1272 $label =
'(CustomerInvoicePayment)';
1274 $label =
'(CustomerInvoicePaymentBack)';
1276 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1278 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1279 $ispostactionok = -1;
1282 $postactionmessages[] =
'Bank transaction of payment created';
1283 $ispostactionok = 1;
1286 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1287 $ispostactionok = -1;
1292 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1293 $ispostactionok = -1;
1303 $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.';
1304 $ispostactionok = -1;
1307 $postactionmessages[] =
'Invoice module is not enable';
1308 $ispostactionok = -1;
1311 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1312 $ispostactionok = -1;
1314 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1315 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1317 $result = $don->fetch((
int) $tmptag[
'DON']);
1320 if ($paymentmethod ==
'paybox') {
1323 if ($paymentmethod ==
'paypal') {
1326 if ($paymentmethod ==
'stripe') {
1329 if (empty($paymentTypeId)) {
1330 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1332 if (empty($paymentType)) {
1333 $paymentType =
'CB';
1340 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1346 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1350 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1353 $totalpaid = $FinalPaymentAmt;
1355 if ($currencyCodeType ==
$conf->currency) {
1356 $paiement->amounts = array(
$object->id => $totalpaid);
1359 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1360 $ispostactionok = -1;
1364 $paiement->fk_donation = $don->id;
1365 $paiement->datep = $now;
1366 $paiement->paymenttype = $paymentTypeId;
1367 $paiement->num_payment =
'';
1368 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1371 if ($LONGTRANSACTIONID) {
1372 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1374 $paiement->ext_payment_id = $TRANSACTIONID;
1376 $paiement->ext_payment_site = $service;
1379 $paiement_id = $paiement->create($user, 1);
1380 if ($paiement_id < 0) {
1381 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1382 $ispostactionok = -1;
1385 $postactionmessages[] =
'Payment created';
1386 $ispostactionok = 1;
1388 if ($totalpaid >= $don->getRemainToPay()) {
1389 $don->valid_promesse($don->id, $user->id);
1390 $don->setPaid($don->id);
1397 if ($paymentmethod ==
'paybox') {
1399 } elseif ($paymentmethod ==
'paypal') {
1401 } elseif ($paymentmethod ==
'stripe') {
1407 'paymentmethod' => $paymentmethod,
1409 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1410 if ($reshook >= 0) {
1411 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1412 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1413 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1416 if ($bankaccountid > 0) {
1417 $label =
'(DonationPayment)';
1418 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1420 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1421 $ispostactionok = -1;
1424 $postactionmessages[] =
'Bank transaction of payment created';
1425 $ispostactionok = 1;
1428 $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.';
1429 $ispostactionok = -1;
1440 $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.';
1441 $ispostactionok = -1;
1444 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1445 $ispostactionok = -1;
1450 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1452 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1453 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1454 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1456 $result =
$object->fetch((
int) $ref);
1459 if ($paymentmethod ==
'paybox') {
1462 if ($paymentmethod ==
'paypal') {
1465 if ($paymentmethod ==
'stripe') {
1468 if (empty($paymentTypeId)) {
1469 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1471 if (empty($paymentType)) {
1472 $paymentType =
'CB';
1479 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1485 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1486 $resultvalidate =
$object->validate($user);
1487 if ($resultvalidate < 0) {
1488 $postactionmessages[] =
'Cannot validate invoice';
1489 $ispostactionok = -1;
1495 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1497 $paiement->datepaye = $now;
1498 if ($currencyCodeType ==
$conf->currency) {
1499 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1501 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1503 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1504 $ispostactionok = -1;
1507 $paiement->paiementid = $paymentTypeId;
1508 $paiement->num_payment =
'';
1509 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1512 if ($LONGTRANSACTIONID) {
1513 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1515 $paiement->ext_payment_id = $TRANSACTIONID;
1517 $paiement->ext_payment_site = $service;
1520 $paiement_id = $paiement->create($user, 1);
1521 if ($paiement_id < 0) {
1522 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1523 $ispostactionok = -1;
1526 $postactionmessages[] =
'Payment created';
1527 $ispostactionok = 1;
1533 if ($paymentmethod ==
'paybox') {
1535 } elseif ($paymentmethod ==
'paypal') {
1537 } elseif ($paymentmethod ==
'stripe') {
1543 'paymentmethod' => $paymentmethod,
1545 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1546 if ($reshook >= 0) {
1547 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1548 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1549 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1552 if ($bankaccountid > 0) {
1553 $label =
'(CustomerInvoicePayment)';
1555 $label =
'(CustomerInvoicePaymentBack)';
1557 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1559 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1560 $ispostactionok = -1;
1563 $postactionmessages[] =
'Bank transaction of payment created';
1564 $ispostactionok = 1;
1567 $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.';
1568 $ispostactionok = -1;
1577 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1578 if ($resultattendee < 0) {
1582 $attendeetovalidate->validate($user);
1584 $attendeetovalidate->amount = $FinalPaymentAmt;
1585 $attendeetovalidate->date_subscription =
dol_now();
1586 $attendeetovalidate->update($user);
1601 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1602 if ($resultthirdparty < 0) {
1605 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1606 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1610 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (
string) $thirdparty->default_lang);
1612 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1614 $arraydefaultmessage =
null;
1616 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1618 if (!empty($idoftemplatetouse)) {
1619 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1622 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1623 $subject = $arraydefaultmessage->topic;
1624 $msg = $arraydefaultmessage->content;
1626 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1627 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1630 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1636 $sendto = $attendeetovalidate->email;
1638 if ($thirdparty->email) {
1639 $cc = $thirdparty->email ??
'';
1641 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1642 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1647 $urlback = $_SERVER[
"REQUEST_URI"];
1653 $listofpaths = array();
1654 $listofnames = array();
1655 $listofmimes = array();
1656 if (is_object($object)) {
1657 $invoicediroutput =
$conf->facture->dir_output;
1659 $file = $fileparams[
'fullname'];
1661 $listofpaths = array($file);
1662 $listofnames = array(basename($file));
1663 $listofmimes = array(dol_mimetype($file));
1666 $trackid =
'inv'.$object->id;
1668 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1670 $result = $mailfile->sendfile();
1672 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1674 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1680 $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.';
1681 $ispostactionok = -1;
1684 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1685 $ispostactionok = -1;
1687 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1689 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1690 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1691 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1693 $result =
$object->fetch((
int) $ref);
1695 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1698 if ($paymentmethod ==
'paybox') {
1701 if ($paymentmethod ==
'paypal') {
1704 if ($paymentmethod ==
'stripe') {
1707 if (empty($paymentTypeId)) {
1708 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1710 if (empty($paymentType)) {
1711 $paymentType =
'CB';
1718 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1724 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1725 $resultvalidate =
$object->validate($user);
1726 if ($resultvalidate < 0) {
1727 $postactionmessages[] =
'Cannot validate invoice';
1728 $ispostactionok = -1;
1734 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1736 $paiement->datepaye = $now;
1737 if ($currencyCodeType ==
$conf->currency) {
1738 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1740 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1742 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1743 $ispostactionok = -1;
1746 $paiement->paiementid = $paymentTypeId;
1747 $paiement->num_payment =
'';
1748 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1751 if ($LONGTRANSACTIONID) {
1752 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1754 $paiement->ext_payment_id = $TRANSACTIONID;
1756 $paiement->ext_payment_site = $service;
1759 $paiement_id = $paiement->create($user, 1);
1760 if ($paiement_id < 0) {
1761 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1762 $ispostactionok = -1;
1765 $postactionmessages[] =
'Payment created';
1766 $ispostactionok = 1;
1772 if ($paymentmethod ==
'paybox') {
1774 } elseif ($paymentmethod ==
'paypal') {
1776 } elseif ($paymentmethod ==
'stripe') {
1782 'paymentmethod' => $paymentmethod,
1784 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1785 if ($reshook >= 0) {
1786 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1787 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1788 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1791 if ($bankaccountid > 0) {
1792 $label =
'(CustomerInvoicePayment)';
1794 $label =
'(CustomerInvoicePaymentBack)';
1796 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1798 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1799 $ispostactionok = -1;
1802 $postactionmessages[] =
'Bank transaction of payment created';
1803 $ispostactionok = 1;
1806 $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.';
1807 $ispostactionok = -1;
1814 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1815 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1817 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1818 if ($resultbooth < 0) {
1822 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1823 $resultboothupdate = $booth->update($user);
1824 if ($resultboothupdate < 0) {
1827 $resultinvoice = $invoice->fetch((
int) $ref);
1828 if ($resultinvoice < 0) {
1829 $postactionmessages[] =
'Could not find the associated invoice.';
1830 $ispostactionok = -1;
1834 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1835 if ($resultthirdparty < 0) {
1842 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1843 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1847 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1849 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1851 $arraydefaultmessage =
null;
1853 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1855 if (!empty($idoftemplatetouse)) {
1856 $arraydefaultmessage = $formmail->getEMailTemplate(
$db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1859 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1860 $subject = $arraydefaultmessage->topic;
1861 $msg = $arraydefaultmessage->content;
1863 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1864 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1867 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1873 $sendto = $thirdparty->email;
1875 $urlback = $_SERVER[
"REQUEST_URI"];
1878 $trackid =
'inv'.$invoice->id;
1880 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1882 $result = $mailfile->sendfile();
1884 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1886 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1901 $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.';
1902 $ispostactionok = -1;
1905 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1906 $ispostactionok = -1;
1908 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1909 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1911 $result =
$object->fetch((
int) $tmptag[
'CON']);
1913 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1916 if ($paymentmethod ==
'paybox') {
1919 if ($paymentmethod ==
'paypal') {
1922 if ($paymentmethod ==
'stripe') {
1925 if (empty($paymentTypeId)) {
1926 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1928 if (empty($paymentType)) {
1929 $paymentType =
'CB';
1936 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1941 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1942 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1946 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1949 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1951 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1954 $invoice->validate($user);
1956 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1958 $paiement->datepaye = $now;
1959 if ($currencyCodeType ==
$conf->currency) {
1960 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1962 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1964 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.
$conf->currency.
')';
1965 $ispostactionok = -1;
1968 $paiement->paiementid = $paymentTypeId;
1969 $paiement->num_payment =
'';
1970 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1973 if ($LONGTRANSACTIONID) {
1974 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1976 $paiement->ext_payment_id = $TRANSACTIONID;
1978 $paiement->ext_payment_site = $service;
1981 $paiement_id = $paiement->create($user, 1);
1982 if ($paiement_id < 0) {
1983 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1984 $ispostactionok = -1;
1987 $postactionmessages[] =
'Payment created';
1988 $ispostactionok = 1;
1994 if ($paymentmethod ==
'paybox') {
1996 } elseif ($paymentmethod ==
'paypal') {
1998 } elseif ($paymentmethod ==
'stripe') {
2004 'paymentmethod' => $paymentmethod,
2006 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2007 if ($reshook >= 0) {
2008 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2009 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2010 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2013 if ($bankaccountid > 0) {
2014 $label =
'(CustomerInvoicePayment)';
2016 $label =
'(CustomerInvoicePaymentBack)';
2018 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2020 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2021 $ispostactionok = -1;
2024 $postactionmessages[] =
'Bank transaction of payment created';
2025 $ispostactionok = 1;
2028 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2029 $ispostactionok = -1;
2034 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2035 if (!empty($tmptag[
'COL'])) {
2036 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2038 $postactionmessages[] = $msg;
2039 $ispostactionok = -1;
2049 $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.';
2050 $ispostactionok = -1;
2053 $postactionmessages[] =
'Invoice module is not enable';
2054 $ispostactionok = -1;
2057 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2058 if (!empty($tmptag[
'COL'])) {
2059 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2061 $postactionmessages[] = $msg;
2062 $ispostactionok = -1;
2069dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2073 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2074 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2076 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2077 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2078 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2080 if (is_object($object) && method_exists($object,
'call_trigger')) {
2081 '@phan-var-force CommonObject $object';
2083 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2088 } elseif (get_class($object) ==
'stdClass') {
2090 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2092 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2101if (empty($doactionsthenredirect)) {
2103 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2104 if ($TRANSACTIONID) {
2105 print $langs->trans(
"ThisIsTransactionId").
" : ".$TRANSACTIONID.
"<br><br>\n";
2109 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2113 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2119 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2120 if ($ErrorLongMsg) {
2121 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2123 if ($ErrorShortMsg) {
2124 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2127 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2129 if ($ErrorSeverityCode) {
2130 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2134 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2146 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2152 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2159 $companylangs->setDefaultLang($myCompanyDefaultLang);
2160 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2162 $sendto = $sendemail;
2165 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2166 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2171 $urlback = $_SERVER[
"REQUEST_URI"];
2172 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2174 if (array_key_exists(
'MEM', $tmptag)) {
2175 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2176 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2177 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2178 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2179 } elseif (array_key_exists(
'INV', $tmptag)) {
2180 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2181 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2182 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2184 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2186 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2188 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2189 if ($ispostactionok > 0) {
2191 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2192 } elseif ($ispostactionok == 0) {
2193 $content .= $companylangs->transnoentitiesnoconv(
"None");
2195 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2196 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2198 $content .=
'<br>'.
"\n";
2199 foreach ($postactionmessages as $postactionmessage) {
2200 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2202 if ($ispostactionok < 0) {
2203 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2205 $content .=
'<br>'.
"\n";
2207 $content .=
"<br>\n";
2208 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2209 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2210 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2211 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2212 $content .=
"<br>\n";
2213 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2215 if (!empty($ErrorCode)) {
2216 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2218 if (!empty($ErrorShortMsg)) {
2219 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2221 if (!empty($ErrorLongMsg)) {
2222 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2224 if (!empty($ErrorSeverityCode)) {
2225 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2228 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2233 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2234 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2236 $result = $mailfile->sendfile();
2238 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2241 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2249 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2250 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2252 $paymentType = $_SESSION[
'PaymentType'];
2253 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2254 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2256 if (is_object($object) && method_exists($object,
'call_trigger')) {
2258 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2268 $companylangs->setDefaultLang(
$mysoc->default_lang);
2269 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2271 $sendto = $sendemail;
2274 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2275 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2278 $urlback = $_SERVER[
"REQUEST_URI"];
2279 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2281 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2283 $content .=
"<br><br>\n";
2284 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2285 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2286 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2287 $content .=
"<br>\n";
2288 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2294 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2295 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2297 $result = $mailfile->sendfile();
2299 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2301 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2308unset($_SESSION[
"FinalPaymentAmt"]);
2309unset($_SESSION[
"TRANSACTIONID"]);
2313if (empty($doactionsthenredirect)) {
2316 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2321if (empty($doactionsthenredirect)) {
2332if (!empty($doactionsthenredirect)) {
2336 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2339 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2340 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2342 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2345 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2346 header(
"Location: ".$ext_urlok);
2351 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2354 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2355 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2357 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2360 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2361 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)
Return file(s) into a directory (by default most recent)
dol_now($mode='gmt')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) formatLogObject($data)
Return a string serialized to be output on log with dol_syslog() An option allow to output log in one...
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag)
Validate payment.
getDetails($token)
Prepares the parameters for the GetExpressCheckoutDetails API Call.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.