34if (!defined(
'NOLOGIN')) {
37if (!defined(
'NOCSRFCHECK')) {
38 define(
"NOCSRFCHECK", 1);
40if (!defined(
'NOIPCHECK')) {
41 define(
'NOIPCHECK',
'1');
43if (!defined(
'NOBROWSERNOTIF')) {
44 define(
'NOBROWSERNOTIF',
'1');
47if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
48 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
54$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
55if (is_numeric($entity)) {
56 define(
"DOLENTITY", $entity);
60require
'../../main.inc.php';
71require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
72require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
73require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
75 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
76 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
82$hookmanager->initHooks(array(
'newpayment'));
84$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paypal",
"stripe"));
88$PAYPAL_API_PASSWORD =
"";
89$PAYPAL_API_SIGNATURE =
"";
90$PAYPAL_API_SANDBOX =
"";
99 $PAYPALTOKEN =
GETPOST(
'TOKEN');
100 if (empty($PAYPALTOKEN)) {
101 $PAYPALTOKEN =
GETPOST(
'token');
103 $PAYPALPAYERID =
GETPOST(
'PAYERID');
104 if (empty($PAYPALPAYERID)) {
105 $PAYPALPAYERID =
GETPOST(
'PayerID');
110if (empty($FULLTAG)) {
116$suffix =
GETPOST(
"suffix",
'aZ09');
123if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
124 $paymentmethod = $reg[1];
126if (empty($paymentmethod)) {
127 dol_syslog(
"***** paymentok.php was called with a non valid parameter FULLTAG=".$FULLTAG, LOG_DEBUG, 0,
'_payment');
128 dol_print_error(
null,
'The callback url does not contain a parameter fulltag that should help us to find the payment method used');
132dol_syslog(
"***** paymentok.php is called paymentmethod=".$paymentmethod.
" FULLTAG=".$FULLTAG.
" REQUEST_URI=".$_SERVER[
"REQUEST_URI"], LOG_DEBUG, 0,
'_payment');
136$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
138 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');
141$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
144if (empty($validpaymentmethod)) {
150$paramcreditor =
'ONLINE_PAYMENT_CREDITOR';
151$paramcreditorlong =
'ONLINE_PAYMENT_CREDITOR_'.$suffix;
161$PAYMENTSTATUS = $TRANSACTIONID = $LONGTRANSACTIONID = $TAXAMT = $NOTE =
'';
163$ErrorCode = $ErrorShortMsg = $ErrorLongMsg = $ErrorSeverityCode =
'';
171$ws_virtuelhost =
null;
173$doactionsthenredirect = 0;
175 $doactionsthenredirect = 1;
176 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
178 $result = $website->fetch(0, $ws);
180 $ws_virtuelhost = $website->virtualhost;
181 $ws_id = $website->id;
198dol_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');
199dol_syslog(
"_SERVER[SERVER_NAME] = ".(empty($_SERVER[
"SERVER_NAME"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_NAME"])), LOG_DEBUG, 0,
'_payment');
200dol_syslog(
"_SERVER[SERVER_ADDR] = ".(empty($_SERVER[
"SERVER_ADDR"]) ?
'' :
dol_escape_htmltag($_SERVER[
"SERVER_ADDR"])), LOG_DEBUG, 0,
'_payment');
203foreach ($_POST as $k => $v) {
204 if (is_scalar($k) && is_scalar($v)) {
205 $tracepost .=
"$k=$v\n";
208dol_syslog(
"POST: ".$tracepost, LOG_DEBUG, 0,
'_payment');
211foreach ($_SESSION as $k => $v) {
212 if (is_scalar($k) && is_scalar($v) && in_array($k, array(
'currencyCodeType',
'errormessage',
'FinalPaymentAmt',
'ipaddress',
'onlinetoken',
'payerID',
'paymentType',
'TRANSACTIONID',
'paymentoksessionkey',
'paymentkosessionkey'))) {
213 $tracesession .=
"$k=$v\n";
216dol_syslog(
"session_id=".session_id().
" SESSION: ".$tracesession, LOG_DEBUG, 0,
'_payment');
218dol_syslog(
"paymentoksessioncode=".
GETPOST(
'paymentoksessioncode').
" SESSION['paymentoksessioncode']=".$_SESSION[
'paymentoksessioncode'], LOG_DEBUG, 0,
'_payment');
222 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
225$conf->dol_hide_topmenu = 1;
226$conf->dol_hide_leftmenu = 1;
230if (empty($doactionsthenredirect)) {
231 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
232 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
236 print
'<span id="dolpaymentspan"></span>'.
"\n";
237 print
'<div id="dolpaymentdiv" class="center">'.
"\n";
242 $logosmall =
$mysoc->logo_small;
244 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
254 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
255 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
256 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
257 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
258 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
259 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
264 print
'<div class="backgreypublicpayment">';
265 print
'<div class="logopublicpayment">';
266 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
270 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>';
273 } elseif ($creditor) {
274 print
'<div class="backgreypublicpayment">';
275 print
'<div class="logopublicpayment">';
281 print
'<div class="backimagepublicpayment">';
282 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
287 print
'<br><br><br>';
292$service = $paymentmethod;
295if (
isModEnabled(
'paypal') && $paymentmethod ===
'paypal') {
296 if (!empty($PAYPALTOKEN)) {
299 $onlinetoken = $PAYPALTOKEN;
301 $payerID = !empty($PAYPALPAYERID) ? $PAYPALPAYERID :
'';
303 $ipaddress = $_SESSION[
'ipaddress'];
304 $currencyCodeType = $_SESSION[
'currencyCodeType'];
305 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
306 $paymentType = $_SESSION[
'PaymentType'];
308 dol_syslog(
"Call paymentok with token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
311 if (!empty($paymentType)) {
312 dol_syslog(
"We call GetExpressCheckoutDetails", LOG_DEBUG, 0,
'_payment');
316 $ack = strtoupper($resArray[
"ACK"]);
317 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
319 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
321 dol_syslog(
"Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, 0,
'_payment');
324 dol_syslog(
"We call DoExpressCheckoutPayment token=".$onlinetoken.
" paymentType=".$paymentType.
" currencyCodeType=".$currencyCodeType.
" payerID=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt.
" fulltag=".$fulltag, LOG_DEBUG, 0,
'_payment');
325 $resArray2 =
confirmPayment($onlinetoken, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $fulltag);
328 $ack = strtoupper($resArray2[
"ACK"]);
329 if ($ack ==
"SUCCESS" || $ack ==
"SUCCESSWITHWARNING") {
330 dol_syslog(
"Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0,
'_payment');
336 $object->resArray = $resArray2;
340 $PAYMENTSTATUS = urldecode($resArray2[
"PAYMENTSTATUS"]);
341 $TRANSACTIONID = urldecode($resArray2[
"TRANSACTIONID"]);
342 $TAXAMT = urldecode($resArray2[
"TAXAMT"]);
343 $NOTE = urldecode($resArray2[
"NOTE"]);
347 dol_syslog(
"Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0,
'_payment');
350 $ErrorCode = urldecode($resArray2[
"L_ERRORCODE0"]);
351 $ErrorShortMsg = urldecode($resArray2[
"L_SHORTMESSAGE0"]);
352 $ErrorLongMsg = urldecode($resArray2[
"L_LONGMESSAGE0"]);
353 $ErrorSeverityCode = urldecode($resArray2[
"L_SEVERITYCODE0"]);
356 $ErrorCode =
"SESSIONEXPIRED";
357 $ErrorLongMsg =
"Session expired. Can't retrieve PaymentType. Payment has not been validated.";
358 $ErrorShortMsg =
"Session expired";
360 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
364 $ErrorCode =
"PAYPALTOKENNOTDEFINED";
365 $ErrorLongMsg =
"The parameter PAYPALTOKEN was not defined. Payment has not been validated.";
366 $ErrorShortMsg =
"Parameter PAYPALTOKEN not defined";
368 dol_syslog($ErrorLongMsg, LOG_WARNING, 0,
'_payment');
374if (
isModEnabled(
'paybox') && $paymentmethod ===
'paybox') {
380if (
isModEnabled(
'stripe') && $paymentmethod ===
'stripe') {
382 if (empty($TRANSACTIONID)) {
383 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
384 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
386 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
389 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
390 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
392 $service =
'StripeTest';
395 $service =
'StripeLive';
400 if (
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
402 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
407 if (!$error && $TRANSACTIONID) {
410 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
411 $stripe =
new Stripe($db);
412 $stripeacc = $stripe->getStripeAccount($service);
415 global $stripearrayofkeysbyenv;
416 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
419 if (empty($stripeacc)) {
420 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
422 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
426 $expectedAmount = (int) round($FinalPaymentAmt * 100);
427 $expectedCurrency = strtolower($currencyCodeType);
429 if ((
int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
431 $errmsg =
'Stripe payment information mismatch: expected amount ' . $expectedAmount .
' and currency ' . $expectedCurrency .
', got amount ' . $paymentIntent->amount .
' and currency ' . $paymentIntent->currency;
434 if ($paymentIntent->status !==
'succeeded') {
436 $errmsg =
'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
443 if ($paymentIntent instanceof \
Stripe\PaymentIntent) {
444 $customerid = $paymentIntent->customer;
446 if (isset($stripearrayofkeysbyenv[$servicestatus][
'publishable_key'])) {
447 $pkey = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
450 if ($customerid && $pkey) {
451 $LONGTRANSACTIONID = $TRANSACTIONID.
':'.$customerid.
'@'.$pkey;
455 $errormessage =
"Stripe API error: ".$e->getMessage();
456 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
460 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
461 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
466 $errmsg =
'Stripe API error: ' . $e->getMessage();
471 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
479 $ispaymentok =
false;
484if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
488 'paymentmethod' => $paymentmethod,
490 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
492 if (isset($hookmanager->resArray[
'ispaymentok'])) {
493 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
494 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
503if (empty($ipaddress)) {
504 $ipaddress = $_SESSION[
'ipaddress'];
506if (empty($FinalPaymentAmt)) {
507 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
509if (empty($currencyCodeType)) {
510 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
512if (empty($paymentType)) {
513 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
516if (empty($TRANSACTIONID)) {
517 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
518 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
520 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
528dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
538$postactionmessages = array();
541 if (empty($user->rights->societe)) {
542 $user->rights->societe =
new stdClass();
544 if (empty($user->rights->facture)) {
545 $user->rights->facture =
new stdClass();
546 $user->rights->facture->invoice_advance =
new stdClass();
548 if (empty($user->rights->adherent)) {
549 $user->rights->adherent =
new stdClass();
550 $user->rights->adherent->cotisation =
new stdClass();
552 $user->rights->societe->creer = 1;
553 $user->rights->facture->creer = 1;
554 $user->rights->facture->invoice_advance->validate = 1;
555 $user->rights->adherent->cotisation->creer = 1;
557 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
564 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
565 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
566 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
570 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
571 $result2 = $adht->fetch(
$object->typeid);
573 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
574 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
576 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
578 if ($result1 > 0 && $result2 > 0) {
579 if ($paymentmethod ==
'paybox') {
582 if ($paymentmethod ==
'paypal') {
585 if ($paymentmethod ==
'stripe') {
588 if (empty($paymentTypeId)) {
589 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
591 if (empty($paymentType)) {
596 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
599 if (empty($paymentTypeId) || $paymentTypeId < 0) {
604 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
607 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
609 if (empty($adht->caneditamount)) {
610 if (
$object->status == $object::STATUS_DRAFT) {
612 $amountbytype = $adht->amountByType(1);
616 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
626 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
628 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
630 $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 ?';
631 $postactionmessages[] = $errmsg;
632 $ispostactionok = -1;
633 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
642 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' .
getDolGlobalString(
'MEMBER_MIN_AMOUNT').
'). May be a hack to try to pay a different amount ?';
643 $postactionmessages[] = $errmsg;
644 $ispostactionok = -1;
645 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
650 if ($currencyCodeType && $currencyCodeType != $conf->currency) {
652 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.$conf->currency.
'). May be a hack to try to pay a different amount ?';
653 $postactionmessages[] = $errmsg;
654 $ispostactionok = -1;
655 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
660 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
661 if ($result < 0 || empty(
$object->datevalid)) {
664 $postactionmessages[] = $errmsg;
665 $postactionmessages = array_merge($postactionmessages,
$object->errors);
666 $ispostactionok = -1;
667 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
672 $datesubscription =
$object->datevalid;
689 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
692 while ($datesubend < $now) {
694 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
701 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string)
$object->thirdparty->default_lang);
703 $amount = $FinalPaymentAmt;
704 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
705 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
709 if ($paymentmethod ==
'paybox') {
712 if ($paymentmethod ==
'paypal') {
715 if ($paymentmethod ==
'stripe') {
721 'paymentmethod' => $paymentmethod,
723 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
725 if (isset($hookmanager->resArray[
'bankaccountid'])) {
726 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
727 $accountid = $hookmanager->resArray[
'bankaccountid'];
730 if ($accountid < 0) {
732 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
733 $postactionmessages[] = $errmsg;
734 $ispostactionok = -1;
735 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
738 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
741 $emetteur_banque =
'';
745 $option =
'bankviainvoice';
747 $option =
'bankdirect';
749 $option =
'invoiceonly';
751 if (empty($option)) {
762 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
764 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
768 $postactionmessages[] = $errmsg;
769 $ispostactionok = -1;
771 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
776 $autocreatethirdparty = 0;
779 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
781 $autocreatethirdparty = 1;
783 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
788 $postactionmessages[] =
$object->error;
789 $postactionmessages = array_merge($postactionmessages,
$object->errors);
790 $ispostactionok = -1;
792 if ($option ==
'bankviainvoice') {
793 $postactionmessages[] =
'Invoice, payment and bank record created';
794 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
796 if ($option ==
'bankdirect') {
797 $postactionmessages[] =
'Bank record created';
798 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
800 if ($option ==
'invoiceonly') {
801 $postactionmessages[] =
'Invoice recorded';
802 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
812 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
815 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
817 $service =
'StripeTest';
820 $service =
'StripeLive';
825 $thirdparty =
new Societe($db);
826 $thirdparty->fetch($thirdparty_id);
828 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
829 $stripe =
new Stripe($db);
832 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
834 if (!$customer && $TRANSACTIONID) {
835 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
838 global $stripearrayofkeysbyenv;
839 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
841 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
843 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
846 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
850 $stripecu = $chpi->customer;
852 if (empty($stripecu)) {
854 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
857 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
858 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
861 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
862 $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)";
863 $resql = $db->query($sql);
866 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
868 $postactionmessages[] = $errmsg;
869 $ispostactionok = -1;
874 $errmsg =
'Failed to retrieve paymentintent or charge from id';
876 $postactionmessages[] = $errmsg;
877 $ispostactionok = -1;
881 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
883 $postactionmessages[] = $errmsg;
884 $ispostactionok = -1;
901 $nuser =
new User($db);
906 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
907 $resqlcount = $db->query($sql);
909 $objcount = $db->fetch_object($resqlcount);
911 $found = $objcount->nb;
916 $result = $nuser->create_from_member($tmpuser,
$object->login);
917 $newpassword = $nuser->setPassword($user,
'');
920 $outputlangs->load(
"errors");
921 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
923 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
924 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
927 $outputlangs->load(
"errors");
928 $postactionmessages[] =
'No user created because a user linked to member already exists';
934 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
937 if (
$object->email && $sendalsoemail) {
942 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
945 $outputlangs->loadLangs(array(
"main",
"members"));
947 $arraydefaultmessage =
null;
950 if (!empty($labeltouse)) {
951 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
954 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
955 $subject = $arraydefaultmessage->topic;
956 $msg = $arraydefaultmessage->content;
959 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
961 if ($infouserlogin) {
962 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
971 $listofpaths = array();
972 $listofnames = array();
973 $listofmimes = array();
974 if (is_object(
$object->invoice)) {
975 $invoicediroutput = $conf->facture->dir_output;
977 $file = $fileparams[
'fullname'];
979 $listofpaths = array($file);
980 $listofnames = array(basename($file));
984 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
986 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
990 $postactionmessages[] = $errmsg;
991 $ispostactionok = -1;
994 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
996 $postactionmessages[] =
'Email sent to member (without any attached document)';
1004 $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.';
1005 $ispostactionok = -1;
1008 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1009 $ispostactionok = -1;
1011 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1013 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1015 $result =
$object->fetch((
int) $tmptag[
'INV']);
1017 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1020 if ($paymentmethod ===
'paybox') {
1023 if ($paymentmethod ===
'paypal') {
1026 if ($paymentmethod ===
'stripe') {
1029 if (empty($paymentTypeId)) {
1030 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1032 if (empty($paymentType)) {
1033 $paymentType =
'CB';
1037 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1040 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1045 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1048 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1052 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1054 $paiement->datepaye = $now;
1055 if ($currencyCodeType == $conf->currency) {
1056 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1058 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1060 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1061 $ispostactionok = -1;
1064 $paiement->paiementid = $paymentTypeId;
1065 $paiement->num_payment =
'';
1066 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1069 if ($LONGTRANSACTIONID) {
1070 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1072 $paiement->ext_payment_id = $TRANSACTIONID;
1074 $paiement->ext_payment_site = $service;
1078 $result =
$object->validate($user);
1080 $postactionmessages[] =
$object->error;
1081 $ispostactionok = -1;
1084 $postactionmessages[] =
'Invoice validated';
1085 $ispostactionok = 1;
1090 $paiement_id = $paiement->create($user, 1);
1091 if ($paiement_id < 0) {
1092 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1093 $ispostactionok = -1;
1096 $postactionmessages[] =
'Payment created';
1097 $ispostactionok = 1;
1103 if ($paymentmethod ==
'paybox') {
1105 } elseif ($paymentmethod ==
'paypal') {
1107 } elseif ($paymentmethod ==
'stripe') {
1113 'paymentmethod' => $paymentmethod,
1115 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1116 if ($reshook >= 0) {
1117 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1118 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1119 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1122 if ($bankaccountid > 0) {
1123 $label =
'(CustomerInvoicePayment)';
1125 $label =
'(CustomerInvoicePaymentBack)';
1127 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1129 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1130 $ispostactionok = -1;
1133 $postactionmessages[] =
'Bank transaction of payment created';
1134 $ispostactionok = 1;
1137 $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.';
1138 $ispostactionok = -1;
1149 $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.';
1150 $ispostactionok = -1;
1153 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1154 $ispostactionok = -1;
1156 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1157 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1159 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1161 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1163 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1166 if ($paymentmethod ==
'paybox') {
1169 if ($paymentmethod ==
'paypal') {
1172 if ($paymentmethod ==
'stripe') {
1175 if (empty($paymentTypeId)) {
1176 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1178 if (empty($paymentType)) {
1179 $paymentType =
'CB';
1183 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1186 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1191 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1195 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1198 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1200 $result = $invoice->createFromOrder($object, $user);
1202 if ($FinalPaymentAmt !=
$object->total_ttc) {
1210 $object->classifyBilled($user);
1212 $invoice->validate($user);
1215 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1217 $paiement->datepaye = $now;
1218 if ($currencyCodeType == $conf->currency) {
1219 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1221 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1223 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1224 $ispostactionok = -1;
1227 $paiement->paiementid = $paymentTypeId;
1228 $paiement->num_payment =
'';
1229 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1232 if ($LONGTRANSACTIONID) {
1233 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1235 $paiement->ext_payment_id = $TRANSACTIONID;
1237 $paiement->ext_payment_site = $service;
1240 $paiement_id = $paiement->create($user, 1);
1241 if ($paiement_id < 0) {
1242 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1243 $ispostactionok = -1;
1246 $postactionmessages[] =
'Payment created';
1247 $ispostactionok = 1;
1253 if ($paymentmethod ==
'paybox') {
1255 } elseif ($paymentmethod ==
'paypal') {
1257 } elseif ($paymentmethod ==
'stripe') {
1263 'paymentmethod' => $paymentmethod,
1265 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1266 if ($reshook >= 0) {
1267 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1268 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1269 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1272 if ($bankaccountid > 0) {
1273 $label =
'(CustomerInvoicePayment)';
1275 $label =
'(CustomerInvoicePaymentBack)';
1277 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1279 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1280 $ispostactionok = -1;
1283 $postactionmessages[] =
'Bank transaction of payment created';
1284 $ispostactionok = 1;
1287 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1288 $ispostactionok = -1;
1293 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1294 $ispostactionok = -1;
1304 $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.';
1305 $ispostactionok = -1;
1308 $postactionmessages[] =
'Invoice module is not enable';
1309 $ispostactionok = -1;
1312 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1313 $ispostactionok = -1;
1315 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1316 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1317 $don =
new Don($db);
1318 $result = $don->fetch((
int) $tmptag[
'DON']);
1321 if ($paymentmethod ==
'paybox') {
1324 if ($paymentmethod ==
'paypal') {
1325 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1327 if ($paymentmethod ==
'stripe') {
1330 if (empty($paymentTypeId)) {
1331 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1333 if (empty($paymentType)) {
1334 $paymentType =
'CB';
1338 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1341 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1347 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1351 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1354 $totalpaid = $FinalPaymentAmt;
1356 if ($currencyCodeType == $conf->currency) {
1357 $paiement->amounts = array(
$object->id => $totalpaid);
1360 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1361 $ispostactionok = -1;
1365 $paiement->fk_donation = $don->id;
1366 $paiement->datep = $now;
1367 $paiement->paymenttype = $paymentTypeId;
1368 $paiement->num_payment =
'';
1369 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1372 if ($LONGTRANSACTIONID) {
1373 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1375 $paiement->ext_payment_id = $TRANSACTIONID;
1377 $paiement->ext_payment_site = $service;
1380 $paiement_id = $paiement->create($user, 1);
1381 if ($paiement_id < 0) {
1382 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1383 $ispostactionok = -1;
1386 $postactionmessages[] =
'Payment created';
1387 $ispostactionok = 1;
1389 if ($totalpaid >= $don->getRemainToPay()) {
1390 $don->valid_promesse($don->id, $user->id);
1391 $don->setPaid($don->id);
1398 if ($paymentmethod ==
'paybox') {
1400 } elseif ($paymentmethod ==
'paypal') {
1402 } elseif ($paymentmethod ==
'stripe') {
1408 'paymentmethod' => $paymentmethod,
1410 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1411 if ($reshook >= 0) {
1412 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1413 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1414 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1417 if ($bankaccountid > 0) {
1418 $label =
'(DonationPayment)';
1419 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1421 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1422 $ispostactionok = -1;
1425 $postactionmessages[] =
'Bank transaction of payment created';
1426 $ispostactionok = 1;
1429 $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.';
1430 $ispostactionok = -1;
1441 $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.';
1442 $ispostactionok = -1;
1445 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1446 $ispostactionok = -1;
1451 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1453 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1454 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1455 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1457 $result =
$object->fetch((
int) $ref);
1460 if ($paymentmethod ==
'paybox') {
1463 if ($paymentmethod ==
'paypal') {
1466 if ($paymentmethod ==
'stripe') {
1469 if (empty($paymentTypeId)) {
1470 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1472 if (empty($paymentType)) {
1473 $paymentType =
'CB';
1477 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1480 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1486 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1487 $resultvalidate =
$object->validate($user);
1488 if ($resultvalidate < 0) {
1489 $postactionmessages[] =
'Cannot validate invoice';
1490 $ispostactionok = -1;
1496 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1498 $paiement->datepaye = $now;
1499 if ($currencyCodeType == $conf->currency) {
1500 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1502 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1504 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1505 $ispostactionok = -1;
1508 $paiement->paiementid = $paymentTypeId;
1509 $paiement->num_payment =
'';
1510 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1513 if ($LONGTRANSACTIONID) {
1514 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1516 $paiement->ext_payment_id = $TRANSACTIONID;
1518 $paiement->ext_payment_site = $service;
1521 $paiement_id = $paiement->create($user, 1);
1522 if ($paiement_id < 0) {
1523 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1524 $ispostactionok = -1;
1527 $postactionmessages[] =
'Payment created';
1528 $ispostactionok = 1;
1534 if ($paymentmethod ==
'paybox') {
1536 } elseif ($paymentmethod ==
'paypal') {
1538 } elseif ($paymentmethod ==
'stripe') {
1544 'paymentmethod' => $paymentmethod,
1546 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1547 if ($reshook >= 0) {
1548 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1549 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1550 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1553 if ($bankaccountid > 0) {
1554 $label =
'(CustomerInvoicePayment)';
1556 $label =
'(CustomerInvoicePaymentBack)';
1558 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1560 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1561 $ispostactionok = -1;
1564 $postactionmessages[] =
'Bank transaction of payment created';
1565 $ispostactionok = 1;
1568 $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.';
1569 $ispostactionok = -1;
1578 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1579 if ($resultattendee < 0) {
1583 $attendeetovalidate->validate($user);
1585 $attendeetovalidate->amount = $FinalPaymentAmt;
1586 $attendeetovalidate->date_subscription =
dol_now();
1587 $attendeetovalidate->update($user);
1601 $thirdparty =
new Societe($db);
1602 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1603 if ($resultthirdparty < 0) {
1606 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1607 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1610 $outputlangs =
new Translate(
'', $conf);
1611 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string) $thirdparty->default_lang);
1613 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1615 $arraydefaultmessage =
null;
1617 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1619 if (!empty($idoftemplatetouse)) {
1620 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1623 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1624 $subject = $arraydefaultmessage->topic;
1625 $msg = $arraydefaultmessage->content;
1627 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1628 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1631 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1637 $sendto = $attendeetovalidate->email;
1639 if ($thirdparty->email) {
1640 $cc = $thirdparty->email ??
'';
1642 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1643 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1648 $urlback = $_SERVER[
"REQUEST_URI"];
1654 $listofpaths = array();
1655 $listofnames = array();
1656 $listofmimes = array();
1657 if (is_object($object)) {
1658 $invoicediroutput = $conf->facture->dir_output;
1660 $file = $fileparams[
'fullname'];
1662 $listofpaths = array($file);
1663 $listofnames = array(basename($file));
1667 $trackid =
'inv'.$object->id;
1669 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1671 $result = $mailfile->sendfile();
1673 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1675 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1681 $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.';
1682 $ispostactionok = -1;
1685 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1686 $ispostactionok = -1;
1688 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1690 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1691 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1692 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1694 $result =
$object->fetch((
int) $ref);
1696 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1699 if ($paymentmethod ==
'paybox') {
1702 if ($paymentmethod ==
'paypal') {
1705 if ($paymentmethod ==
'stripe') {
1708 if (empty($paymentTypeId)) {
1709 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1711 if (empty($paymentType)) {
1712 $paymentType =
'CB';
1716 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1719 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1725 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1726 $resultvalidate =
$object->validate($user);
1727 if ($resultvalidate < 0) {
1728 $postactionmessages[] =
'Cannot validate invoice';
1729 $ispostactionok = -1;
1735 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1737 $paiement->datepaye = $now;
1738 if ($currencyCodeType == $conf->currency) {
1739 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1741 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1743 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1744 $ispostactionok = -1;
1747 $paiement->paiementid = $paymentTypeId;
1748 $paiement->num_payment =
'';
1749 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1752 if ($LONGTRANSACTIONID) {
1753 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1755 $paiement->ext_payment_id = $TRANSACTIONID;
1757 $paiement->ext_payment_site = $service;
1760 $paiement_id = $paiement->create($user, 1);
1761 if ($paiement_id < 0) {
1762 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1763 $ispostactionok = -1;
1766 $postactionmessages[] =
'Payment created';
1767 $ispostactionok = 1;
1773 if ($paymentmethod ==
'paybox') {
1775 } elseif ($paymentmethod ==
'paypal') {
1777 } elseif ($paymentmethod ==
'stripe') {
1783 'paymentmethod' => $paymentmethod,
1785 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1786 if ($reshook >= 0) {
1787 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1788 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1789 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1792 if ($bankaccountid > 0) {
1793 $label =
'(CustomerInvoicePayment)';
1795 $label =
'(CustomerInvoicePaymentBack)';
1797 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1799 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1800 $ispostactionok = -1;
1803 $postactionmessages[] =
'Bank transaction of payment created';
1804 $ispostactionok = 1;
1807 $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.';
1808 $ispostactionok = -1;
1815 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1816 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1818 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1819 if ($resultbooth < 0) {
1823 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1824 $resultboothupdate = $booth->update($user);
1825 if ($resultboothupdate < 0) {
1828 $resultinvoice = $invoice->fetch((
int) $ref);
1829 if ($resultinvoice < 0) {
1830 $postactionmessages[] =
'Could not find the associated invoice.';
1831 $ispostactionok = -1;
1834 $thirdparty =
new Societe($db);
1835 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1836 if ($resultthirdparty < 0) {
1843 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1844 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1847 $outputlangs =
new Translate(
'', $conf);
1848 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1850 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1852 $arraydefaultmessage =
null;
1854 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1856 if (!empty($idoftemplatetouse)) {
1857 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1860 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1861 $subject = $arraydefaultmessage->topic;
1862 $msg = $arraydefaultmessage->content;
1864 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1865 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1868 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1874 $sendto = $thirdparty->email;
1876 $urlback = $_SERVER[
"REQUEST_URI"];
1879 $trackid =
'inv'.$invoice->id;
1881 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1883 $result = $mailfile->sendfile();
1885 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1887 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1902 $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.';
1903 $ispostactionok = -1;
1906 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1907 $ispostactionok = -1;
1909 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1910 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1912 $result =
$object->fetch((
int) $tmptag[
'CON']);
1914 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1917 if ($paymentmethod ==
'paybox') {
1920 if ($paymentmethod ==
'paypal') {
1923 if ($paymentmethod ==
'stripe') {
1926 if (empty($paymentTypeId)) {
1927 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1929 if (empty($paymentType)) {
1930 $paymentType =
'CB';
1934 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1937 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1942 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1943 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1947 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1950 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1952 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1955 $invoice->validate($user);
1957 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1959 $paiement->datepaye = $now;
1960 if ($currencyCodeType == $conf->currency) {
1961 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1963 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1965 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1966 $ispostactionok = -1;
1969 $paiement->paiementid = $paymentTypeId;
1970 $paiement->num_payment =
'';
1971 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1974 if ($LONGTRANSACTIONID) {
1975 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1977 $paiement->ext_payment_id = $TRANSACTIONID;
1979 $paiement->ext_payment_site = $service;
1982 $paiement_id = $paiement->create($user, 1);
1983 if ($paiement_id < 0) {
1984 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1985 $ispostactionok = -1;
1988 $postactionmessages[] =
'Payment created';
1989 $ispostactionok = 1;
1995 if ($paymentmethod ==
'paybox') {
1997 } elseif ($paymentmethod ==
'paypal') {
1999 } elseif ($paymentmethod ==
'stripe') {
2005 'paymentmethod' => $paymentmethod,
2007 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2008 if ($reshook >= 0) {
2009 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2010 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2011 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2014 if ($bankaccountid > 0) {
2015 $label =
'(CustomerInvoicePayment)';
2017 $label =
'(CustomerInvoicePaymentBack)';
2019 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2021 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2022 $ispostactionok = -1;
2025 $postactionmessages[] =
'Bank transaction of payment created';
2026 $ispostactionok = 1;
2029 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2030 $ispostactionok = -1;
2035 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2036 if (!empty($tmptag[
'COL'])) {
2037 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2039 $postactionmessages[] = $msg;
2040 $ispostactionok = -1;
2050 $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.';
2051 $ispostactionok = -1;
2054 $postactionmessages[] =
'Invoice module is not enable';
2055 $ispostactionok = -1;
2058 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2059 if (!empty($tmptag[
'COL'])) {
2060 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2062 $postactionmessages[] = $msg;
2063 $ispostactionok = -1;
2070dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2074 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2075 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2077 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2078 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2079 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2081 if (is_object($object) && method_exists($object,
'call_trigger')) {
2082 '@phan-var-force CommonObject $object';
2084 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2089 } elseif (get_class($object) ==
'stdClass') {
2091 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2093 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2102if (empty($doactionsthenredirect)) {
2104 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2105 if ($TRANSACTIONID) {
2106 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
2110 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2114 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2120 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2121 if ($ErrorLongMsg) {
2122 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2124 if ($ErrorShortMsg) {
2125 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2128 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2130 if ($ErrorSeverityCode) {
2131 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2135 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2147 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2152 $myCompanyDefaultLang = (string)
$mysoc->default_lang;
2153 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2159 $companylangs =
new Translate(
'', $conf);
2160 $companylangs->setDefaultLang($myCompanyDefaultLang);
2161 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2163 $sendto = $sendemail;
2166 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2167 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2172 $urlback = $_SERVER[
"REQUEST_URI"];
2173 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2175 if (array_key_exists(
'MEM', $tmptag)) {
2176 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2177 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2178 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2179 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2180 } elseif (array_key_exists(
'INV', $tmptag)) {
2181 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2182 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2183 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2185 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2187 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2189 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2190 if ($ispostactionok > 0) {
2192 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2193 } elseif ($ispostactionok == 0) {
2194 $content .= $companylangs->transnoentitiesnoconv(
"None");
2196 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2197 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2199 $content .=
'<br>'.
"\n";
2200 foreach ($postactionmessages as $postactionmessage) {
2201 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2203 if ($ispostactionok < 0) {
2204 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2206 $content .=
'<br>'.
"\n";
2208 $content .=
"<br>\n";
2209 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2210 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2211 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2212 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2213 $content .=
"<br>\n";
2214 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2216 if (!empty($ErrorCode)) {
2217 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2219 if (!empty($ErrorShortMsg)) {
2220 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2222 if (!empty($ErrorLongMsg)) {
2223 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2225 if (!empty($ErrorSeverityCode)) {
2226 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2229 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2234 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2235 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2237 $result = $mailfile->sendfile();
2239 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2242 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2250 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2251 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2253 $paymentType = $_SESSION[
'PaymentType'];
2254 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2255 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2257 if (is_object($object) && method_exists($object,
'call_trigger')) {
2259 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2268 $companylangs =
new Translate(
'', $conf);
2269 $companylangs->setDefaultLang(
$mysoc->default_lang);
2270 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2272 $sendto = $sendemail;
2275 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2276 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2279 $urlback = $_SERVER[
"REQUEST_URI"];
2280 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2282 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2284 $content .=
"<br><br>\n";
2285 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2286 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2287 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2288 $content .=
"<br>\n";
2289 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2295 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2296 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2298 $result = $mailfile->sendfile();
2300 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2302 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2309unset($_SESSION[
"FinalPaymentAmt"]);
2310unset($_SESSION[
"TRANSACTIONID"]);
2314if (empty($doactionsthenredirect)) {
2317 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2322if (empty($doactionsthenredirect)) {
2333if (!empty($doactionsthenredirect)) {
2337 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2340 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2341 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2343 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2346 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2347 header(
"Location: ".$ext_urlok);
2352 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2355 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2356 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2358 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2361 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2362 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)
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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...
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.