28 if (!defined(
'NOLOGIN')) define(
"NOLOGIN", 1);
29 if (!defined(
'NOCSRFCHECK')) define(
"NOCSRFCHECK", 1);
30 if (!defined(
'NOIPCHECK')) define(
'NOIPCHECK',
'1');
31 if (!defined(
'NOBROWSERNOTIF')) define(
'NOBROWSERNOTIF',
'1');
36 $entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
37 if (is_numeric($entity)) define(
"DOLENTITY", $entity);
39 require
'../../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
43 if (!empty($conf->paypal->enabled))
45 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
49 $langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
51 if (!empty($conf->paypal->enabled))
53 $PAYPALTOKEN =
GETPOST(
'TOKEN');
54 if (empty($PAYPALTOKEN)) $PAYPALTOKEN =
GETPOST(
'token');
55 $PAYPALPAYERID =
GETPOST(
'PAYERID');
56 if (empty($PAYPALPAYERID)) $PAYPALPAYERID =
GETPOST(
'PayerID');
58 if (!empty($conf->paybox->enabled))
61 if (!empty($conf->stripe->enabled))
66 if (empty($FULLTAG)) $FULLTAG =
GETPOST(
'fulltag');
68 $suffix =
GETPOST(
"suffix",
'aZ09');
74 if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg))
76 $paymentmethod = $reg[1];
78 if (empty($paymentmethod))
80 dol_print_error(null,
'The back url does not contains a parameter fulltag that should help us to find the payment method used');
87 $validpaymentmethod = array();
88 if (!empty($conf->paypal->enabled)) $validpaymentmethod[
'paypal'] =
'paypal';
89 if (!empty($conf->paybox->enabled)) $validpaymentmethod[
'paybox'] =
'paybox';
90 if (!empty($conf->stripe->enabled)) $validpaymentmethod[
'stripe'] =
'stripe';
97 $object =
new stdClass();
111 dol_syslog(
"Callback url when an online payment is refused or canceled. query_string=".(empty(
$_SERVER[
"QUERY_STRING"]) ?
'' :
$_SERVER[
"QUERY_STRING"]).
" script_uri=".(empty($_SERVER[
"SCRIPT_URI"]) ?
'' : $_SERVER[
"SCRIPT_URI"]), LOG_DEBUG, 0,
'_payment');
114 foreach ($_POST as $k => $v) $tracepost .=
"{$k} - {$v}\n";
115 dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
118 if (!empty($_SESSION[
'ipaddress']))
122 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
123 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
125 $paymentType = $_SESSION[
'PaymentType'];
126 $currencyCodeType = $_SESSION[
'currencyCodeType'];
127 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
129 $ipaddress = $_SESSION[
'ipaddress'];
130 $errormessage = $_SESSION[
'errormessage'];
132 if (is_object($object) && method_exists($object,
'call_trigger')) {
134 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
135 if ($result < 0) $error++;
141 if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL))
143 $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
149 $companylangs =
new Translate(
'', $conf);
150 $companylangs->setDefaultLang($mysoc->default_lang);
151 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
153 $from = $conf->global->MAILING_EMAIL_FROM;
154 $sendto = $sendemail;
157 $appli = constant(
'DOL_APPLICATION_TITLE');
158 if (!empty($conf->global->MAIN_APPLICATION_TITLE))
160 $appli = $conf->global->MAIN_APPLICATION_TITLE;
161 if (preg_match(
'/\d\.\d/', $appli))
163 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) $appli .=
" (".DOL_VERSION.
")";
164 }
else $appli .=
" ".DOL_VERSION;
165 }
else $appli .=
" ".DOL_VERSION;
167 $urlback = $_SERVER[
"REQUEST_URI"];
168 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
170 $content .=
'<font color="orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</font>\n";
172 $content .=
"<br><br>\n";
173 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
174 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
175 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
176 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
177 $content .=
"<br>\n";
178 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
182 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
183 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
185 $result = $mailfile->sendfile();
188 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
190 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
194 unset($_SESSION[
'ipaddress']);
198 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'?lang='.$langs->defaultlang.
'">'.
"\n";
200 $conf->dol_hide_topmenu = 1;
201 $conf->dol_hide_leftmenu = 1;
203 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
204 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
208 print '<span id="dolpaymentspan"></span>'.
"\n";
209 print '<div id="dolpaymentdiv" align="center">'.
"\n";
213 $logosmall = $mysoc->logo_small;
214 $logo = $mysoc->logo;
215 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
216 if (!empty($conf->global->$paramlogo)) $logosmall = $conf->global->$paramlogo;
217 elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
222 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall))
224 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
225 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
226 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo))
228 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
229 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
235 print '<div class="backgreypublicpayment">';
236 print '<div class="logopublicpayment">';
237 print '<img id="dolpaymentlogo" src="'.$urllogo.
'"';
240 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
241 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>';
250 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
252 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
253 if (!empty($conf->global->$key))
print $conf->global->$key;
256 $ref =
GETPOST(
'ref',
'alphanohtml');
257 $tag =
GETPOST(
'tag',
'alpha');
258 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
261 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
263 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
269 htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto); $mailfile->sendfile();.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_textishtml($msg, $option=0)
Return if a text is a html content.