28 if (!defined(
'NOLOGIN')) {
31 if (!defined(
'NOCSRFCHECK')) {
32 define(
"NOCSRFCHECK", 1);
34 if (!defined(
'NOIPCHECK')) {
35 define(
'NOIPCHECK',
'1');
37 if (!defined(
'NOBROWSERNOTIF')) {
38 define(
'NOBROWSERNOTIF',
'1');
44 $entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
45 if (is_numeric($entity)) {
46 define(
"DOLENTITY", $entity);
50 require
'../../main.inc.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
55 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
56 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
59 $langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
62 $PAYPALTOKEN =
GETPOST(
'TOKEN');
63 if (empty($PAYPALTOKEN)) {
64 $PAYPALTOKEN =
GETPOST(
'token');
66 $PAYPALPAYERID =
GETPOST(
'PAYERID');
67 if (empty($PAYPALPAYERID)) {
68 $PAYPALPAYERID =
GETPOST(
'PayerID');
77 if (empty($FULLTAG)) {
81 $suffix =
GETPOST(
"suffix",
'aZ09');
87 if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
88 $paymentmethod = $reg[1];
90 if (empty($paymentmethod)) {
91 dol_print_error(
null,
'The back url does not contains a parameter fulltag that should help us to find the payment method used');
98 $validpaymentmethod = array();
100 $validpaymentmethod[
'paypal'] =
'paypal';
103 $validpaymentmethod[
'paybox'] =
'paybox';
106 $validpaymentmethod[
'stripe'] =
'stripe';
111 if (empty($validpaymentmethod)) {
116 $object =
new stdClass();
130 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');
133 foreach ($_POST as $k => $v) {
134 $tracepost .=
"{$k} - {$v}\n";
136 dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
140 $appli = $mysoc->name;
143 if (!empty($_SESSION[
'ipaddress'])) {
146 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
147 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
149 $paymentType = $_SESSION[
'PaymentType'];
150 $currencyCodeType = $_SESSION[
'currencyCodeType'];
151 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
153 $ipaddress = $_SESSION[
'ipaddress'];
154 $errormessage = $_SESSION[
'errormessage'];
156 if (is_object($object) && method_exists($object,
'call_trigger')) {
158 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
167 if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) {
168 $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
173 $companylangs =
new Translate(
'', $conf);
174 $companylangs->setDefaultLang($mysoc->default_lang);
175 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
177 $from = $conf->global->MAILING_EMAIL_FROM;
178 $sendto = $sendemail;
180 $urlback = $_SERVER[
"REQUEST_URI"];
181 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
183 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
185 $content .=
"<br><br>\n";
186 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
187 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
188 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
189 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
190 $content .=
"<br>\n";
191 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
195 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
196 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
198 $result = $mailfile->sendfile();
200 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
202 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
206 unset($_SESSION[
'ipaddress']);
210 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
211 $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'?lang='.$langs->defaultlang.
'">'.
"\n";
214 $conf->dol_hide_topmenu = 1;
215 $conf->dol_hide_leftmenu = 1;
217 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
218 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
222 print
'<span id="dolpaymentspan"></span>'.
"\n";
223 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
227 $logosmall = $mysoc->logo_small;
228 $logo = $mysoc->logo;
229 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
230 if (!empty($conf->global->$paramlogo)) {
231 $logosmall = $conf->global->$paramlogo;
232 } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
233 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
239 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
240 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
241 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
242 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
243 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
244 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
249 print
'<div class="backgreypublicpayment">';
250 print
'<div class="logopublicpayment">';
251 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
254 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
255 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>';
259 if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
260 print
'<div class="backimagepublicpayment">';
261 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.$conf->global->MAIN_IMAGE_PUBLIC_PAYMENT.
'">';
269 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
271 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
272 if (!empty($conf->global->$key)) {
273 print $conf->global->$key;
277 $ref =
GETPOST(
'ref',
'alphanohtml');
278 $tag =
GETPOST(
'tag',
'alpha');
279 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
281 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
283 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
289 htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix);
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage translations.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.