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';
402 if (!
GETPOST(
'payment_intent',
'alphanohtml') &&
GETPOST(
'paymentoksessioncode') !== $_SESSION[
'paymentoksessioncode']) {
404 $errmsg =
'Attempted direct access to the paymentok page without a valid session.';
409 if (!$error && $TRANSACTIONID) {
412 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
413 $stripe =
new Stripe($db);
414 $stripeacc = $stripe->getStripeAccount($service);
417 global $stripearrayofkeysbyenv;
418 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
421 if (empty($stripeacc)) {
422 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
424 $paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array(
"stripe_account" => $stripeacc));
428 $expectedAmount = (int) round($FinalPaymentAmt * 100);
429 $expectedCurrency = strtolower($currencyCodeType);
431 if ((
int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
433 $errmsg =
'Stripe payment information mismatch: expected amount ' . $expectedAmount .
' and currency ' . $expectedCurrency .
', got amount ' . $paymentIntent->amount .
' and currency ' . $paymentIntent->currency;
436 if ($paymentIntent->status !==
'succeeded') {
438 $errmsg =
'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
445 if ($paymentIntent instanceof \
Stripe\PaymentIntent) {
446 $customerid = $paymentIntent->customer;
448 if (isset($stripearrayofkeysbyenv[$servicestatus][
'publishable_key'])) {
449 $pkey = $stripearrayofkeysbyenv[$servicestatus][
'publishable_key'];
452 if ($customerid && $pkey) {
453 $LONGTRANSACTIONID = $TRANSACTIONID.
':'.$customerid.
'@'.$pkey;
457 $errormessage =
"Stripe API error: ".$e->getMessage();
458 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
462 $errormessage =
"CantRetrievePaymentIntent: ".$e->getMessage();
463 dol_syslog($errormessage, LOG_ERR, 0,
'_payment');
468 $errmsg =
'Stripe API error: ' . $e->getMessage();
473 $errmsg =
'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
481 $ispaymentok =
false;
486if (!in_array($paymentmethod, array(
'paypal',
'paybox',
'stripe'))) {
490 'paymentmethod' => $paymentmethod,
492 $reshook = $hookmanager->executeHooks(
'isPaymentOK', $parameters, $object, $action);
494 if (isset($hookmanager->resArray[
'ispaymentok'])) {
495 dol_syslog(
'ispaymentok overwrite by hook return with value='.$hookmanager->resArray[
'ispaymentok'], LOG_DEBUG, 0,
'_payment');
496 $ispaymentok = $hookmanager->resArray[
'ispaymentok'];
505if (empty($ipaddress)) {
506 $ipaddress = $_SESSION[
'ipaddress'];
508if (empty($FinalPaymentAmt)) {
509 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
511if (empty($currencyCodeType)) {
512 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
514if (empty($paymentType)) {
515 $paymentType = empty($_SESSION[
"paymentType"]) ?
'' : $_SESSION[
"paymentType"];
518if (empty($TRANSACTIONID)) {
519 $TRANSACTIONID = empty($_SESSION[
'TRANSACTIONID']) ?
'' : $_SESSION[
'TRANSACTIONID'];
520 if (empty($TRANSACTIONID) &&
GETPOST(
'payment_intent',
'alphanohtml')) {
522 $TRANSACTIONID =
GETPOST(
'payment_intent',
'alphanohtml');
530dol_syslog(
"ispaymentok=".$ispaymentok.
" tmptag=".var_export($tmptag,
true), LOG_DEBUG, 0,
'_payment');
540$postactionmessages = array();
543 if (empty($user->rights->societe)) {
544 $user->rights->societe =
new stdClass();
546 if (empty($user->rights->facture)) {
547 $user->rights->facture =
new stdClass();
548 $user->rights->facture->invoice_advance =
new stdClass();
550 if (empty($user->rights->adherent)) {
551 $user->rights->adherent =
new stdClass();
552 $user->rights->adherent->cotisation =
new stdClass();
554 $user->rights->societe->creer = 1;
555 $user->rights->facture->creer = 1;
556 $user->rights->facture->invoice_advance->validate = 1;
557 $user->rights->adherent->cotisation->creer = 1;
559 if (array_key_exists(
'MEM', $tmptag) && $tmptag[
'MEM'] > 0) {
566 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
567 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
568 include_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
572 $result1 =
$object->fetch((
int) $tmptag[
'MEM']);
573 $result2 = $adht->fetch(
$object->typeid);
575 $defaultdelay = !empty($adht->duration_value) ? $adht->duration_value : 1;
576 $defaultdelayunit = !empty($adht->duration_unit) ? $adht->duration_unit :
'y';
578 dol_syslog(
"We have to process member with id=".$tmptag[
'MEM'].
" result1=".$result1.
" result2=".$result2, LOG_DEBUG, 0,
'_payment');
580 if ($result1 > 0 && $result2 > 0) {
581 if ($paymentmethod ==
'paybox') {
584 if ($paymentmethod ==
'paypal') {
587 if ($paymentmethod ==
'stripe') {
590 if (empty($paymentTypeId)) {
591 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
593 if (empty($paymentType)) {
598 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
601 if (empty($paymentTypeId) || $paymentTypeId < 0) {
606 dol_syslog(
"FinalPaymentAmt=".$FinalPaymentAmt.
" paymentTypeId=".$paymentTypeId.
" currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0,
'_payment');
609 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
611 if (empty($adht->caneditamount)) {
612 if (
$object->status == $object::STATUS_DRAFT) {
614 $amountbytype = $adht->amountByType(1);
618 $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid];
628 $amountexpected = max(0, (
float) $amountexpected, (
float)
getDolGlobalInt(
"MEMBER_MIN_AMOUNT"));
630 if ($amountexpected && $amountexpected != $FinalPaymentAmt) {
632 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') propagated by payment page differs from the expected value for membership ('.$amountexpected.
'). May be a hack to try to pay a different amount ?';
633 $postactionmessages[] = $errmsg;
634 $ispostactionok = -1;
635 dol_syslog(
"Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0,
'_payment');
644 $errmsg =
'Value of FinalPayment ('.$FinalPaymentAmt.
') is lower than the minimum allowed (' .
getDolGlobalString(
'MEMBER_MIN_AMOUNT').
'). May be a hack to try to pay a different amount ?';
645 $postactionmessages[] = $errmsg;
646 $ispostactionok = -1;
647 dol_syslog(
"Failed to validate member (amount propagated from payment page is lower than allowed minimum): ".$errmsg, LOG_ERR, 0,
'_payment');
652 if ($currencyCodeType && $currencyCodeType != $conf->currency) {
654 $errmsg =
'Value of currencyCodeType ('.$currencyCodeType.
') differs from value expected for membership ('.$conf->currency.
'). May be a hack to try to pay a different amount ?';
655 $postactionmessages[] = $errmsg;
656 $ispostactionok = -1;
657 dol_syslog(
"Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0,
'_payment');
662 $result = (
$object->status == $object::STATUS_EXCLUDED) ? -1 :
$object->validate($user);
663 if ($result < 0 || empty(
$object->datevalid)) {
666 $postactionmessages[] = $errmsg;
667 $postactionmessages = array_merge($postactionmessages,
$object->errors);
668 $ispostactionok = -1;
669 dol_syslog(
"Failed to validate member: ".$errmsg, LOG_ERR, 0,
'_payment');
674 $datesubscription =
$object->datevalid;
691 if ($datesubscription && $defaultdelay && $defaultdelayunit) {
694 while ($datesubend < $now) {
696 $datesubscription =
dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit);
703 $outputlangs->setDefaultLang(empty(
$object->thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string)
$object->thirdparty->default_lang);
705 $amount = $FinalPaymentAmt;
706 $formatteddate =
dol_print_date($paymentdate,
'dayhour',
'auto', $outputlangs);
707 $label = $langs->trans(
"OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID);
711 if ($paymentmethod ==
'paybox') {
714 if ($paymentmethod ==
'paypal') {
717 if ($paymentmethod ==
'stripe') {
723 'paymentmethod' => $paymentmethod,
725 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
727 if (isset($hookmanager->resArray[
'bankaccountid'])) {
728 dol_syslog(
'accountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
729 $accountid = $hookmanager->resArray[
'bankaccountid'];
732 if ($accountid < 0) {
734 $errmsg =
'Setup of bank account to use for payment is not correctly done for payment method '.$paymentmethod;
735 $postactionmessages[] = $errmsg;
736 $ispostactionok = -1;
737 dol_syslog(
"Failed to get the bank account to record payment: ".$errmsg, LOG_ERR, 0,
'_payment');
740 $operation =
dol_getIdFromCode($db, $paymentTypeId,
'c_paiement',
'id',
'code', 1);
743 $emetteur_banque =
'';
747 $option =
'bankviainvoice';
749 $option =
'bankdirect';
751 $option =
'invoiceonly';
753 if (empty($option)) {
764 dol_syslog(
"Call ->subscription to create subscription", LOG_DEBUG, 0,
'_payment');
766 $crowid =
$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $membertypeid);
770 $postactionmessages[] = $errmsg;
771 $ispostactionok = -1;
773 $postactionmessages[] =
'Subscription created (id='.$crowid.
')';
778 $autocreatethirdparty = 0;
781 dol_syslog(
"Call ->subscriptionComplementaryActions option=".$option, LOG_DEBUG, 0,
'_payment');
783 $autocreatethirdparty = 1;
785 $result =
$object->subscriptionComplementaryActions($crowid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom, $emetteur_banque, $autocreatethirdparty, $TRANSACTIONID, $service);
790 $postactionmessages[] =
$object->error;
791 $postactionmessages = array_merge($postactionmessages,
$object->errors);
792 $ispostactionok = -1;
794 if ($option ==
'bankviainvoice') {
795 $postactionmessages[] =
'Invoice, payment and bank record created';
796 dol_syslog(
"Invoice, payment and bank record created", LOG_DEBUG, 0,
'_payment');
798 if ($option ==
'bankdirect') {
799 $postactionmessages[] =
'Bank record created';
800 dol_syslog(
"Bank record created", LOG_DEBUG, 0,
'_payment');
802 if ($option ==
'invoiceonly') {
803 $postactionmessages[] =
'Invoice recorded';
804 dol_syslog(
"Invoice recorded", LOG_DEBUG, 0,
'_payment');
814 if ($paymentmethod ==
'stripe' && $autocreatethirdparty && $option ==
'bankviainvoice') {
817 dol_syslog(
"Search existing Stripe customer profile for thirdparty_id=".$thirdparty_id, LOG_DEBUG, 0,
'_payment');
819 $service =
'StripeTest';
822 $service =
'StripeLive';
827 $thirdparty =
new Societe($db);
828 $thirdparty->fetch($thirdparty_id);
830 include_once DOL_DOCUMENT_ROOT.
'/stripe/class/stripe.class.php';
831 $stripe =
new Stripe($db);
834 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 0);
836 if (!$customer && $TRANSACTIONID) {
837 dol_syslog(
"No stripe profile found, so we add it for TRANSACTIONID = ".$TRANSACTIONID, LOG_DEBUG, 0,
'_payment');
840 global $stripearrayofkeysbyenv;
841 \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus][
'secret_key']);
843 if (preg_match(
'/^pi_/', $TRANSACTIONID)) {
845 $chpi = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
848 $chpi = \Stripe\Charge::retrieve($TRANSACTIONID);
852 $stripecu = $chpi->customer;
854 if (empty($stripecu)) {
856 $customer = $stripe->customerStripe($thirdparty, $stripeacc, $servicestatus, 1);
859 if (preg_match(
'/^pi_/', $TRANSACTIONID) && $customer) {
860 \Stripe\PaymentIntent::update($chpi->id, array(
'customer' => $customer->id));
863 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"societe_account (fk_soc, login, key_account, site, site_account, status, entity, date_creation, fk_user_creat)";
864 $sql .=
" VALUES (".((int) $thirdparty_id).
", '', '".$db->escape($stripecu).
"', 'stripe', '".$db->escape($stripearrayofkeysbyenv[$servicestatus][
'publishable_key']).
"', ".((int) $servicestatus).
", ".((int) $conf->entity).
", '".$db->idate(
dol_now()).
"', 0)";
865 $resql = $db->query($sql);
868 $errmsg =
'Failed to insert customer stripe id in database : '.$db->lasterror();
870 $postactionmessages[] = $errmsg;
871 $ispostactionok = -1;
876 $errmsg =
'Failed to retrieve paymentintent or charge from id';
878 $postactionmessages[] = $errmsg;
879 $ispostactionok = -1;
883 $errmsg =
'Failed to get or save customer stripe id in database : '.$e->getMessage();
885 $postactionmessages[] = $errmsg;
886 $ispostactionok = -1;
903 $nuser =
new User($db);
908 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE fk_member = ".((int)
$object->id);
909 $resqlcount = $db->query($sql);
911 $objcount = $db->fetch_object($resqlcount);
913 $found = $objcount->nb;
918 $result = $nuser->create_from_member($tmpuser,
$object->login);
919 $newpassword = $nuser->setPassword($user,
'');
922 $outputlangs->load(
"errors");
923 $postactionmessages[] =
'Error in create external user : '.$nuser->error;
925 $infouserlogin = $outputlangs->trans(
"Login").
': '.$nuser->login.
' '.
"\n".$outputlangs->trans(
"Password").
': '.$newpassword;
926 $postactionmessages[] = $langs->trans(
"NewUserCreated", $nuser->login);
929 $outputlangs->load(
"errors");
930 $postactionmessages[] =
'No user created because a user linked to member already exists';
936 dol_syslog(
"Send email to customer to ".
$object->email.
" if we have to (sendalsoemail = ".$sendalsoemail.
")", LOG_DEBUG, 0,
'_payment');
939 if (
$object->email && $sendalsoemail) {
944 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
947 $outputlangs->loadLangs(array(
"main",
"members"));
949 $arraydefaultmessage =
null;
952 if (!empty($labeltouse)) {
953 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'member', $user, $outputlangs, 0, 1, $labeltouse);
956 if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
957 $subject = $arraydefaultmessage->topic;
958 $msg = $arraydefaultmessage->content;
961 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $object);
963 if ($infouserlogin) {
964 $substitutionarray[
'__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin;
973 $listofpaths = array();
974 $listofnames = array();
975 $listofmimes = array();
976 if (is_object(
$object->invoice)) {
977 $invoicediroutput = $conf->facture->dir_output;
979 $file = $fileparams[
'fullname'];
981 $listofpaths = array($file);
982 $listofnames = array(basename($file));
986 $moreinheader =
'X-Dolibarr-Info: send_an_email by public/payment/paymentok.php'.
"\r\n";
988 $result =
$object->sendEmail($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames,
"",
"", 0, -1,
"", $moreinheader);
992 $postactionmessages[] = $errmsg;
993 $ispostactionok = -1;
996 $postactionmessages[] =
'Email sent to member (with invoice document attached)';
998 $postactionmessages[] =
'Email sent to member (without any attached document)';
1006 $postactionmessages[] =
'Failed to get a valid value for "amount paid" or "payment type" to record the payment of subscription for member '.$tmptag[
'MEM'].
'. May be payment was already recorded.';
1007 $ispostactionok = -1;
1010 $postactionmessages[] =
'Member '.$tmptag[
'MEM'].
' for subscription paid was not found';
1011 $ispostactionok = -1;
1013 } elseif (array_key_exists(
'INV', $tmptag) && $tmptag[
'INV'] > 0) {
1015 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1017 $result =
$object->fetch((
int) $tmptag[
'INV']);
1019 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1022 if ($paymentmethod ===
'paybox') {
1025 if ($paymentmethod ===
'paypal') {
1028 if ($paymentmethod ===
'stripe') {
1031 if (empty($paymentTypeId)) {
1032 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1034 if (empty($paymentType)) {
1035 $paymentType =
'CB';
1039 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1042 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1047 dol_syslog(
"FinalPaymentAmt = ".$FinalPaymentAmt.
" paymentTypeId = ".$paymentTypeId, LOG_DEBUG, 0,
'_payment');
1050 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1054 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1056 $paiement->datepaye = $now;
1057 if ($currencyCodeType == $conf->currency) {
1058 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1060 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1062 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1063 $ispostactionok = -1;
1066 $paiement->paiementid = $paymentTypeId;
1067 $paiement->num_payment =
'';
1068 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1071 if ($LONGTRANSACTIONID) {
1072 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1074 $paiement->ext_payment_id = $TRANSACTIONID;
1076 $paiement->ext_payment_site = $service;
1080 $result =
$object->validate($user);
1082 $postactionmessages[] =
$object->error;
1083 $ispostactionok = -1;
1086 $postactionmessages[] =
'Invoice validated';
1087 $ispostactionok = 1;
1092 $paiement_id = $paiement->create($user, 1);
1093 if ($paiement_id < 0) {
1094 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1095 $ispostactionok = -1;
1098 $postactionmessages[] =
'Payment created';
1099 $ispostactionok = 1;
1105 if ($paymentmethod ==
'paybox') {
1107 } elseif ($paymentmethod ==
'paypal') {
1109 } elseif ($paymentmethod ==
'stripe') {
1115 'paymentmethod' => $paymentmethod,
1117 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1118 if ($reshook >= 0) {
1119 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1120 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1121 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1124 if ($bankaccountid > 0) {
1125 $label =
'(CustomerInvoicePayment)';
1127 $label =
'(CustomerInvoicePaymentBack)';
1129 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1131 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1132 $ispostactionok = -1;
1135 $postactionmessages[] =
'Bank transaction of payment created';
1136 $ispostactionok = 1;
1139 $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.';
1140 $ispostactionok = -1;
1151 $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.';
1152 $ispostactionok = -1;
1155 $postactionmessages[] =
'Invoice paid '.$tmptag[
'INV'].
' was not found';
1156 $ispostactionok = -1;
1158 } elseif (array_key_exists(
'ORD', $tmptag) && $tmptag[
'ORD'] > 0) {
1159 include_once DOL_DOCUMENT_ROOT .
'/commande/class/commande.class.php';
1161 $result =
$object->fetch((
int) $tmptag[
'ORD']);
1163 dol_syslog(
"We have loaded the order id=".
$object->id.
" to use to create the invoice", LOG_DEBUG, 0,
'_payment');
1165 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1168 if ($paymentmethod ==
'paybox') {
1171 if ($paymentmethod ==
'paypal') {
1174 if ($paymentmethod ==
'stripe') {
1177 if (empty($paymentTypeId)) {
1178 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1180 if (empty($paymentType)) {
1181 $paymentType =
'CB';
1185 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1188 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1193 dol_syslog(
"The payment type id to use is paymentTypeId=".$paymentTypeId.
" and FinalPaymentAmt=".$FinalPaymentAmt, LOG_DEBUG, 0,
'_payment');
1197 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1200 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1202 $result = $invoice->createFromOrder($object, $user);
1204 if ($FinalPaymentAmt !=
$object->total_ttc) {
1212 $object->classifyBilled($user);
1214 $invoice->validate($user);
1217 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1219 $paiement->datepaye = $now;
1220 if ($currencyCodeType == $conf->currency) {
1221 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1223 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1225 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1226 $ispostactionok = -1;
1229 $paiement->paiementid = $paymentTypeId;
1230 $paiement->num_payment =
'';
1231 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1234 if ($LONGTRANSACTIONID) {
1235 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1237 $paiement->ext_payment_id = $TRANSACTIONID;
1239 $paiement->ext_payment_site = $service;
1242 $paiement_id = $paiement->create($user, 1);
1243 if ($paiement_id < 0) {
1244 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1245 $ispostactionok = -1;
1248 $postactionmessages[] =
'Payment created';
1249 $ispostactionok = 1;
1255 if ($paymentmethod ==
'paybox') {
1257 } elseif ($paymentmethod ==
'paypal') {
1259 } elseif ($paymentmethod ==
'stripe') {
1265 'paymentmethod' => $paymentmethod,
1267 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1268 if ($reshook >= 0) {
1269 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1270 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1271 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1274 if ($bankaccountid > 0) {
1275 $label =
'(CustomerInvoicePayment)';
1277 $label =
'(CustomerInvoicePaymentBack)';
1279 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1281 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1282 $ispostactionok = -1;
1285 $postactionmessages[] =
'Bank transaction of payment created';
1286 $ispostactionok = 1;
1289 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
1290 $ispostactionok = -1;
1295 $postactionmessages[] =
'Failed to create invoice form order ' . $tmptag[
'ORD'] .
'.';
1296 $ispostactionok = -1;
1306 $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.';
1307 $ispostactionok = -1;
1310 $postactionmessages[] =
'Invoice module is not enable';
1311 $ispostactionok = -1;
1314 $postactionmessages[] =
'Order paid ' . $tmptag[
'ORD'] .
' was not found';
1315 $ispostactionok = -1;
1317 } elseif (array_key_exists(
'DON', $tmptag) && $tmptag[
'DON'] > 0) {
1318 include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
1319 $don =
new Don($db);
1320 $result = $don->fetch((
int) $tmptag[
'DON']);
1323 if ($paymentmethod ==
'paybox') {
1326 if ($paymentmethod ==
'paypal') {
1327 $paymentTypeId =
getDolGlobalInt(
'global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS');
1329 if ($paymentmethod ==
'stripe') {
1332 if (empty($paymentTypeId)) {
1333 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1335 if (empty($paymentType)) {
1336 $paymentType =
'CB';
1340 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1343 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1349 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1353 include_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
1356 $totalpaid = $FinalPaymentAmt;
1358 if ($currencyCodeType == $conf->currency) {
1359 $paiement->amounts = array(
$object->id => $totalpaid);
1362 $postactionmessages[] =
'Payment donation can\'t be paid with different currency than '.$conf->currency;
1363 $ispostactionok = -1;
1367 $paiement->fk_donation = $don->id;
1368 $paiement->datep = $now;
1369 $paiement->paymenttype = $paymentTypeId;
1370 $paiement->num_payment =
'';
1371 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1374 if ($LONGTRANSACTIONID) {
1375 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1377 $paiement->ext_payment_id = $TRANSACTIONID;
1379 $paiement->ext_payment_site = $service;
1382 $paiement_id = $paiement->create($user, 1);
1383 if ($paiement_id < 0) {
1384 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1385 $ispostactionok = -1;
1388 $postactionmessages[] =
'Payment created';
1389 $ispostactionok = 1;
1391 if ($totalpaid >= $don->getRemainToPay()) {
1392 $don->valid_promesse($don->id, $user->id);
1393 $don->setPaid($don->id);
1400 if ($paymentmethod ==
'paybox') {
1402 } elseif ($paymentmethod ==
'paypal') {
1404 } elseif ($paymentmethod ==
'stripe') {
1410 'paymentmethod' => $paymentmethod,
1412 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1413 if ($reshook >= 0) {
1414 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1415 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1416 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1419 if ($bankaccountid > 0) {
1420 $label =
'(DonationPayment)';
1421 $result = $paiement->addPaymentToBank($user,
'payment_donation', $label, $bankaccountid,
'',
'');
1423 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1424 $ispostactionok = -1;
1427 $postactionmessages[] =
'Bank transaction of payment created';
1428 $ispostactionok = 1;
1431 $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.';
1432 $ispostactionok = -1;
1443 $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.';
1444 $ispostactionok = -1;
1447 $postactionmessages[] =
'Donation paid '.$tmptag[
'DON'].
' was not found';
1448 $ispostactionok = -1;
1453 } elseif (array_key_exists(
'ATT', $tmptag) && $tmptag[
'ATT'] > 0) {
1455 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1456 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1457 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1459 $result =
$object->fetch((
int) $ref);
1462 if ($paymentmethod ==
'paybox') {
1465 if ($paymentmethod ==
'paypal') {
1468 if ($paymentmethod ==
'stripe') {
1471 if (empty($paymentTypeId)) {
1472 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1474 if (empty($paymentType)) {
1475 $paymentType =
'CB';
1479 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1482 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1488 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1489 $resultvalidate =
$object->validate($user);
1490 if ($resultvalidate < 0) {
1491 $postactionmessages[] =
'Cannot validate invoice';
1492 $ispostactionok = -1;
1498 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1500 $paiement->datepaye = $now;
1501 if ($currencyCodeType == $conf->currency) {
1502 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1504 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1506 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1507 $ispostactionok = -1;
1510 $paiement->paiementid = $paymentTypeId;
1511 $paiement->num_payment =
'';
1512 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress.
' for event registration';
1515 if ($LONGTRANSACTIONID) {
1516 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1518 $paiement->ext_payment_id = $TRANSACTIONID;
1520 $paiement->ext_payment_site = $service;
1523 $paiement_id = $paiement->create($user, 1);
1524 if ($paiement_id < 0) {
1525 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1526 $ispostactionok = -1;
1529 $postactionmessages[] =
'Payment created';
1530 $ispostactionok = 1;
1536 if ($paymentmethod ==
'paybox') {
1538 } elseif ($paymentmethod ==
'paypal') {
1540 } elseif ($paymentmethod ==
'stripe') {
1546 'paymentmethod' => $paymentmethod,
1548 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1549 if ($reshook >= 0) {
1550 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1551 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1552 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1555 if ($bankaccountid > 0) {
1556 $label =
'(CustomerInvoicePayment)';
1558 $label =
'(CustomerInvoicePaymentBack)';
1560 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1562 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1563 $ispostactionok = -1;
1566 $postactionmessages[] =
'Bank transaction of payment created';
1567 $ispostactionok = 1;
1570 $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.';
1571 $ispostactionok = -1;
1580 $resultattendee = $attendeetovalidate->fetch((
int) $tmptag[
'ATT']);
1581 if ($resultattendee < 0) {
1585 $attendeetovalidate->validate($user);
1587 $attendeetovalidate->amount = $FinalPaymentAmt;
1588 $attendeetovalidate->date_subscription =
dol_now();
1589 $attendeetovalidate->update($user);
1603 $thirdparty =
new Societe($db);
1604 $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
1605 if ($resultthirdparty < 0) {
1608 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1609 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1612 $outputlangs =
new Translate(
'', $conf);
1613 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? (
string)
$mysoc->default_lang : (string) $thirdparty->default_lang);
1615 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1617 $arraydefaultmessage =
null;
1619 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT');
1621 if (!empty($idoftemplatetouse)) {
1622 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1625 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1626 $subject = $arraydefaultmessage->topic;
1627 $msg = $arraydefaultmessage->content;
1629 $subject =
'['.$appli.
'] '.
$object->ref.
' - '.$outputlangs->trans(
"NewRegistration");
1630 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfRegistrationWasReceived");
1633 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1639 $sendto = $attendeetovalidate->email;
1641 if ($thirdparty->email) {
1642 $cc = $thirdparty->email ??
'';
1644 if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) {
1645 $cc = ($cc ?
', ' :
'').$attendeetovalidate->email_company;
1650 $urlback = $_SERVER[
"REQUEST_URI"];
1656 $listofpaths = array();
1657 $listofnames = array();
1658 $listofmimes = array();
1659 if (is_object($object)) {
1660 $invoicediroutput = $conf->facture->dir_output;
1662 $file = $fileparams[
'fullname'];
1664 $listofpaths = array($file);
1665 $listofnames = array(basename($file));
1669 $trackid =
'inv'.$object->id;
1671 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, $listofpaths, $listofmimes, $listofnames, $cc,
'', 0, ($ishtml ? 1 : 0),
'',
'', $trackid,
'',
'standard');
1673 $result = $mailfile->sendfile();
1675 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1677 dol_syslog(
"Failed to send EMail to ".$sendto.
' - '.$mailfile->error, LOG_ERR, 0,
'_payment');
1683 $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.';
1684 $ispostactionok = -1;
1687 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1688 $ispostactionok = -1;
1690 } elseif (array_key_exists(
'BOO', $tmptag) && $tmptag[
'BOO'] > 0) {
1692 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1693 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1694 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1696 $result =
$object->fetch((
int) $ref);
1698 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1701 if ($paymentmethod ==
'paybox') {
1704 if ($paymentmethod ==
'paypal') {
1707 if ($paymentmethod ==
'stripe') {
1710 if (empty($paymentTypeId)) {
1711 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1713 if (empty($paymentType)) {
1714 $paymentType =
'CB';
1718 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1721 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1727 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1728 $resultvalidate =
$object->validate($user);
1729 if ($resultvalidate < 0) {
1730 $postactionmessages[] =
'Cannot validate invoice';
1731 $ispostactionok = -1;
1737 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
1739 $paiement->datepaye = $now;
1740 if ($currencyCodeType == $conf->currency) {
1741 $paiement->amounts = array(
$object->id => $FinalPaymentAmt);
1743 $paiement->multicurrency_amounts = array(
$object->id => $FinalPaymentAmt);
1745 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1746 $ispostactionok = -1;
1749 $paiement->paiementid = $paymentTypeId;
1750 $paiement->num_payment =
'';
1751 $paiement->note_public =
'Online payment '.dol_print_date($now,
'standard').
' from '.$ipaddress;
1754 if ($LONGTRANSACTIONID) {
1755 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1757 $paiement->ext_payment_id = $TRANSACTIONID;
1759 $paiement->ext_payment_site = $service;
1762 $paiement_id = $paiement->create($user, 1);
1763 if ($paiement_id < 0) {
1764 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1765 $ispostactionok = -1;
1768 $postactionmessages[] =
'Payment created';
1769 $ispostactionok = 1;
1775 if ($paymentmethod ==
'paybox') {
1777 } elseif ($paymentmethod ==
'paypal') {
1779 } elseif ($paymentmethod ==
'stripe') {
1785 'paymentmethod' => $paymentmethod,
1787 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
1788 if ($reshook >= 0) {
1789 if (isset($hookmanager->resArray[
'bankaccountid'])) {
1790 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
1791 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
1794 if ($bankaccountid > 0) {
1795 $label =
'(CustomerInvoicePayment)';
1797 $label =
'(CustomerInvoicePaymentBack)';
1799 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
1801 $postactionmessages[] = $paiement->error.
' '.implode(
"<br>\n", $paiement->errors);
1802 $ispostactionok = -1;
1805 $postactionmessages[] =
'Bank transaction of payment created';
1806 $ispostactionok = 1;
1809 $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.';
1810 $ispostactionok = -1;
1817 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
1818 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorbooth.class.php';
1820 $resultbooth = $booth->fetch((
int) $tmptag[
'BOO']);
1821 if ($resultbooth < 0) {
1825 $booth->status = ConferenceOrBooth::STATUS_SUGGESTED;
1826 $resultboothupdate = $booth->update($user);
1827 if ($resultboothupdate < 0) {
1830 $resultinvoice = $invoice->fetch((
int) $ref);
1831 if ($resultinvoice < 0) {
1832 $postactionmessages[] =
'Could not find the associated invoice.';
1833 $ispostactionok = -1;
1836 $thirdparty =
new Societe($db);
1837 $resultthirdparty = $thirdparty->fetch($invoice->socid);
1838 if ($resultthirdparty < 0) {
1845 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
1846 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1849 $outputlangs =
new Translate(
'', $conf);
1850 $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ?
$mysoc->default_lang : $thirdparty->default_lang);
1852 $outputlangs->loadLangs(array(
"main",
"members",
"eventorganization"));
1854 $arraydefaultmessage =
null;
1856 $idoftemplatetouse =
getDolGlobalInt(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_BOOTH');
1858 if (!empty($idoftemplatetouse)) {
1859 $arraydefaultmessage = $formmail->getEMailTemplate($db,
'conferenceorbooth', $user, $outputlangs, $idoftemplatetouse, 1,
'');
1862 if (!empty($idoftemplatetouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
1863 $subject = $arraydefaultmessage->topic;
1864 $msg = $arraydefaultmessage->content;
1866 $subject =
'['.$appli.
'] '.$booth->ref.
' - '.$outputlangs->trans(
"NewRegistration").
']';
1867 $msg = $outputlangs->trans(
"OrganizationEventPaymentOfBoothWasReceived");
1870 $substitutionarray = getCommonSubstitutionArray($outputlangs, 0,
null, $thirdparty);
1876 $sendto = $thirdparty->email;
1878 $urlback = $_SERVER[
"REQUEST_URI"];
1881 $trackid =
'inv'.$invoice->id;
1883 $mailfile =
new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
1885 $result = $mailfile->sendfile();
1887 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
1889 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
1904 $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.';
1905 $ispostactionok = -1;
1908 $postactionmessages[] =
'Invoice paid '.$tmptag[
'ATT'].
' was not found';
1909 $ispostactionok = -1;
1911 } elseif (array_key_exists(
'CON', $tmptag) && $tmptag[
'CON'] > 0) {
1912 include_once DOL_DOCUMENT_ROOT .
'/contrat/class/contrat.class.php';
1914 $result =
$object->fetch((
int) $tmptag[
'CON']);
1916 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
1919 if ($paymentmethod ==
'paybox') {
1922 if ($paymentmethod ==
'paypal') {
1925 if ($paymentmethod ==
'stripe') {
1928 if (empty($paymentTypeId)) {
1929 dol_syslog(
"paymentType = ".$paymentType, LOG_DEBUG, 0,
'_payment');
1931 if (empty($paymentType)) {
1932 $paymentType =
'CB';
1936 $paymentTypeId =
dol_getIdFromCode($db, $paymentType,
'c_paiement',
'code',
'id', 1);
1939 if (empty($paymentTypeId) || $paymentTypeId < 0) {
1944 $currencyCodeType = $_SESSION[
'currencyCodeType'];
1945 $contract_lines = (array_key_exists(
'COL', $tmptag) && $tmptag[
'COL'] > 0) ? $tmptag[
'COL'] : null;
1949 if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
1952 include_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
1954 $result = $invoice->createFromContract($object, $user, array((
int) $contract_lines));
1957 $invoice->validate($user);
1959 include_once DOL_DOCUMENT_ROOT .
'/compta/paiement/class/paiement.class.php';
1961 $paiement->datepaye = $now;
1962 if ($currencyCodeType == $conf->currency) {
1963 $paiement->amounts = array($invoice->id => $FinalPaymentAmt);
1965 $paiement->multicurrency_amounts = array($invoice->id => $FinalPaymentAmt);
1967 $postactionmessages[] =
'Payment was done in a currency ('.$currencyCodeType.
') other than the expected currency of company ('.$conf->currency.
')';
1968 $ispostactionok = -1;
1971 $paiement->paiementid = $paymentTypeId;
1972 $paiement->num_payment =
'';
1973 $paiement->note_public =
'Online payment ' .
dol_print_date($now,
'standard') .
' from ' . $ipaddress;
1976 if ($LONGTRANSACTIONID) {
1977 $paiement->ext_payment_id = $LONGTRANSACTIONID;
1979 $paiement->ext_payment_id = $TRANSACTIONID;
1981 $paiement->ext_payment_site = $service;
1984 $paiement_id = $paiement->create($user, 1);
1985 if ($paiement_id < 0) {
1986 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
1987 $ispostactionok = -1;
1990 $postactionmessages[] =
'Payment created';
1991 $ispostactionok = 1;
1997 if ($paymentmethod ==
'paybox') {
1999 } elseif ($paymentmethod ==
'paypal') {
2001 } elseif ($paymentmethod ==
'stripe') {
2007 'paymentmethod' => $paymentmethod,
2009 $reshook = $hookmanager->executeHooks(
'getBankAccountPaymentMethod', $parameters, $object, $action);
2010 if ($reshook >= 0) {
2011 if (isset($hookmanager->resArray[
'bankaccountid'])) {
2012 dol_syslog(
'bankaccountid overwrite by hook return with value='.$hookmanager->resArray[
'bankaccountid'], LOG_DEBUG, 0,
'_payment');
2013 $bankaccountid = $hookmanager->resArray[
'bankaccountid'];
2016 if ($bankaccountid > 0) {
2017 $label =
'(CustomerInvoicePayment)';
2019 $label =
'(CustomerInvoicePaymentBack)';
2021 $result = $paiement->addPaymentToBank($user,
'payment', $label, $bankaccountid,
'',
'');
2023 $postactionmessages[] = $paiement->error .
' ' . implode(
"<br>\n", $paiement->errors);
2024 $ispostactionok = -1;
2027 $postactionmessages[] =
'Bank transaction of payment created';
2028 $ispostactionok = 1;
2031 $postactionmessages[] =
'Setup of bank account to use in module ' . $paymentmethod .
' was not set. No way to record the payment.';
2032 $ispostactionok = -1;
2037 $msg =
'Failed to create invoice form contract ' . $tmptag[
'CON'];
2038 if (!empty($tmptag[
'COL'])) {
2039 $msg .=
' and col '. $tmptag[
'COL'] .
'.';
2041 $postactionmessages[] = $msg;
2042 $ispostactionok = -1;
2052 $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.';
2053 $ispostactionok = -1;
2056 $postactionmessages[] =
'Invoice module is not enable';
2057 $ispostactionok = -1;
2060 $msg =
'Contract paid ' . $tmptag[
'CON'] .
' was not found';
2061 if (!empty($tmptag[
'COL'])) {
2062 $msg .=
' for col '.$tmptag[
'COL'] .
'.';
2064 $postactionmessages[] = $msg;
2065 $ispostactionok = -1;
2072dol_syslog(
"ispaymentok=".$ispaymentok.
" ispostactionok=".$ispostactionok.
" doactionsthenredirect=".$doactionsthenredirect, LOG_DEBUG, 0,
'_payment');
2076 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2077 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2079 $currencyCodeType = empty($_SESSION[
'currencyCodeType']) ?
'' : $_SESSION[
'currencyCodeType'];
2080 $FinalPaymentAmt = empty($_SESSION[
"FinalPaymentAmt"]) ?
'' : $_SESSION[
"FinalPaymentAmt"];
2081 $paymentType = empty($_SESSION[
'PaymentType']) ?
'' : $_SESSION[
'PaymentType'];
2083 if (is_object($object) && method_exists($object,
'call_trigger')) {
2084 '@phan-var-force CommonObject $object';
2086 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2091 } elseif (get_class($object) ==
'stdClass') {
2093 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
2095 $result = $paiement->call_trigger(
'PAYMENTONLINE_PAYMENT_OK', $user);
2104if (empty($doactionsthenredirect)) {
2106 print $langs->trans(
"YourPaymentHasBeenRecorded").
"<br>\n";
2107 if ($TRANSACTIONID) {
2108 print $langs->trans(
"ThisIsTransactionId", $TRANSACTIONID).
"<br><br>\n";
2112 print
img_picto(
'',
'tick',
'class="green fa-2x"');
2116 $key =
'ONLINE_PAYMENT_MESSAGE_OK';
2122 print $langs->trans(
'DoExpressCheckoutPaymentAPICallFailed').
"<br>\n";
2123 if ($ErrorLongMsg) {
2124 print $langs->trans(
'DetailedErrorMessage').
": ".$ErrorLongMsg.
"<br>\n";
2126 if ($ErrorShortMsg) {
2127 print $langs->trans(
'ShortErrorMessage').
": ".$ErrorShortMsg.
"<br>\n";
2130 print $langs->trans(
'ErrorCode').
": ".$ErrorCode.
"<br>\n";
2132 if ($ErrorSeverityCode) {
2133 print $langs->trans(
'ErrorSeverityCode').
": ".$ErrorSeverityCode.
"<br>\n";
2137 print
"\nPlease, send a screenshot of this page to ".$mysoc->email.
"<br>\n";
2149 dol_syslog(
"Send email to admins if we have to (sendemail = ".$sendemail.
")", LOG_DEBUG, 0,
'_payment');
2154 $myCompanyDefaultLang = (string)
$mysoc->default_lang;
2155 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
2161 $companylangs =
new Translate(
'', $conf);
2162 $companylangs->setDefaultLang($myCompanyDefaultLang);
2163 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2165 $sendto = $sendemail;
2168 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2169 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2174 $urlback = $_SERVER[
"REQUEST_URI"];
2175 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived");
2177 if (array_key_exists(
'MEM', $tmptag)) {
2178 $url = $urlwithroot.
"/adherents/subscription.php?rowid=".((int) $tmptag[
'MEM']);
2179 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"PaymentSubscription").
"</strong><br><br>\n";
2180 $content .= $companylangs->transnoentitiesnoconv(
"MemberId").
': <strong>'.$tmptag[
'MEM'].
"</strong><br>\n";
2181 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2182 } elseif (array_key_exists(
'INV', $tmptag)) {
2183 $url = $urlwithroot.
"/compta/facture/card.php?id=".((int) $tmptag[
'INV']);
2184 $content .=
'<strong>'.$companylangs->transnoentitiesnoconv(
"Payment").
"</strong><br><br>\n";
2185 $content .= $companylangs->transnoentitiesnoconv(
"InvoiceId").
': <strong>'.$tmptag[
'INV'].
"</strong><br>\n";
2187 $content .= $companylangs->transnoentitiesnoconv(
"Link").
': <a href="'.$url.
'">'.$url.
'</a>'.
"<br>\n";
2189 $content .= $companylangs->transnoentitiesnoconv(
"NewOnlinePaymentReceived").
"<br>\n";
2191 $content .= $companylangs->transnoentitiesnoconv(
"PostActionAfterPayment").
' : ';
2192 if ($ispostactionok > 0) {
2194 $content .=
'<span style="color: green">'.$companylangs->transnoentitiesnoconv(
"OK").
'</span>';
2195 } elseif ($ispostactionok == 0) {
2196 $content .= $companylangs->transnoentitiesnoconv(
"None");
2198 $topic .= ($ispostactionok ?
'' :
' ('.$companylangs->trans(
"WarningPostActionErrorAfterPayment").
')');
2199 $content .=
'<span class="star">'.$companylangs->transnoentitiesnoconv(
"Error").
'</span>';
2201 $content .=
'<br>'.
"\n";
2202 foreach ($postactionmessages as $postactionmessage) {
2203 $content .=
' * '.$postactionmessage.
'<br>'.
"\n";
2205 if ($ispostactionok < 0) {
2206 $content .= $langs->transnoentitiesnoconv(
"ARollbackWasPerformedOnPostActions");
2208 $content .=
'<br>'.
"\n";
2210 $content .=
"<br>\n";
2211 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2212 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2213 $content .= $companylangs->transnoentitiesnoconv(
"ThisIsTransactionId").
': <strong>'.$TRANSACTIONID.
"</strong><br>\n";
2214 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2215 $content .=
"<br>\n";
2216 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2218 if (!empty($ErrorCode)) {
2219 $content .=
"ErrorCode = ".$ErrorCode.
"<br>\n";
2221 if (!empty($ErrorShortMsg)) {
2222 $content .=
"ErrorShortMsg = ".$ErrorShortMsg.
"<br>\n";
2224 if (!empty($ErrorLongMsg)) {
2225 $content .=
"ErrorLongMsg = ".$ErrorLongMsg.
"<br>\n";
2227 if (!empty($ErrorSeverityCode)) {
2228 $content .=
"ErrorSeverityCode = ".$ErrorSeverityCode.
"<br>\n";
2231 dol_syslog(
"Content of email: ".$content, LOG_DEBUG, 0,
'_payment');
2236 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2237 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2239 $result = $mailfile->sendfile();
2241 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2244 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2252 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
2253 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
2255 $paymentType = $_SESSION[
'PaymentType'];
2256 $currencyCodeType = $_SESSION[
'currencyCodeType'];
2257 $FinalPaymentAmt = $_SESSION[
"FinalPaymentAmt"];
2259 if (is_object($object) && method_exists($object,
'call_trigger')) {
2261 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
2270 $companylangs =
new Translate(
'', $conf);
2271 $companylangs->setDefaultLang(
$mysoc->default_lang);
2272 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
2274 $sendto = $sendemail;
2277 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2278 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2281 $urlback = $_SERVER[
"REQUEST_URI"];
2282 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"ValidationOfPaymentFailed");
2284 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"PaymentSystemConfirmPaymentPageWasCalledButFailed").
"</span>\n";
2286 $content .=
"<br><br>\n";
2287 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
2288 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
2289 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
2290 $content .=
"<br>\n";
2291 $content .=
"tag=".$fulltag.
"<br>\ntoken=".$onlinetoken.
"<br>\npaymentType=".$paymentType.
"<br>\ncurrencycodeType=".$currencyCodeType.
"<br>\npayerId=".$payerID.
"<br>\nipaddress=".$ipaddress.
"<br>\nFinalPaymentAmt=".$FinalPaymentAmt.
"<br>\n";
2297 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
2298 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0,
'',
'', $trackid,
'',
'standard');
2300 $result = $mailfile->sendfile();
2302 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
2304 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
2311unset($_SESSION[
"FinalPaymentAmt"]);
2312unset($_SESSION[
"TRANSACTIONID"]);
2316if (empty($doactionsthenredirect)) {
2319 print
"<!-- Info for payment: FinalPaymentAmt=".dol_escape_htmltag($FinalPaymentAmt).
" paymentTypeId=".
dol_escape_htmltag((
string) $paymentTypeId).
" currencyCodeType=".
dol_escape_htmltag($currencyCodeType).
" -->\n";
2324if (empty($doactionsthenredirect)) {
2335if (!empty($doactionsthenredirect)) {
2339 $_SESSION[
'paymentoksessioncode'] = $randomseckey;
2342 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2343 $ext_urlok = $ws_virtuelhost .
'/paymentok.php?paymentoksessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2345 $ext_urlok = DOL_URL_ROOT.
'/public/website/index.php?paymentoksessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentok&fulltag='.$FULLTAG;
2348 dol_syslog(
"Now do a redirect using a Location: ".$ext_urlok, LOG_DEBUG, 0,
'_payment');
2349 header(
"Location: ".$ext_urlok);
2354 $_SESSION[
'paymentkosessioncode'] = $randomseckey;
2357 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
2358 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
2360 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
2363 dol_syslog(
"Now do a redirect using a Location:".$ext_urlko, LOG_DEBUG, 0,
'_payment');
2364 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.