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);
49 require
'../../main.inc.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
53 if (!empty($conf->paypal->enabled)) {
54 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
55 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
58 $langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
60 if (!empty($conf->paypal->enabled)) {
61 $PAYPALTOKEN =
GETPOST(
'TOKEN');
62 if (empty($PAYPALTOKEN)) {
63 $PAYPALTOKEN =
GETPOST(
'token');
65 $PAYPALPAYERID =
GETPOST(
'PAYERID');
66 if (empty($PAYPALPAYERID)) {
67 $PAYPALPAYERID =
GETPOST(
'PayerID');
70 if (!empty($conf->paybox->enabled)) {
72 if (!empty($conf->stripe->enabled)) {
76 if (empty($FULLTAG)) {
80 $suffix =
GETPOST(
"suffix",
'aZ09');
86 if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
87 $paymentmethod = $reg[1];
89 if (empty($paymentmethod)) {
90 dol_print_error(null,
'The back url does not contains a parameter fulltag that should help us to find the payment method used');
97 $validpaymentmethod = array();
98 if (!empty($conf->paypal->enabled)) {
99 $validpaymentmethod[
'paypal'] =
'paypal';
101 if (!empty($conf->paybox->enabled)) {
102 $validpaymentmethod[
'paybox'] =
'paybox';
104 if (!empty($conf->stripe->enabled)) {
105 $validpaymentmethod[
'stripe'] =
'stripe';
110 if (empty($validpaymentmethod)) {
115 $object =
new stdClass();
129 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');
132 foreach ($_POST as $k => $v) {
133 $tracepost .=
"{$k} - {$v}\n";
135 dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
138 if (!empty($_SESSION[
'ipaddress'])) {
141 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
142 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
144 $paymentType = $_SESSION[
'PaymentType'];
145 $currencyCodeType = $_SESSION[
'currencyCodeType'];
146 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
148 $ipaddress = $_SESSION[
'ipaddress'];
149 $errormessage = $_SESSION[
'errormessage'];
151 if (is_object($object) && method_exists($object,
'call_trigger')) {
153 $result = $object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
162 if (!empty($conf->global->ONLINE_PAYMENT_SENDEMAIL)) {
163 $sendemail = $conf->global->ONLINE_PAYMENT_SENDEMAIL;
168 $companylangs =
new Translate(
'', $conf);
169 $companylangs->setDefaultLang($mysoc->default_lang);
170 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox'));
172 $from = $conf->global->MAILING_EMAIL_FROM;
173 $sendto = $sendemail;
176 $appli = constant(
'DOL_APPLICATION_TITLE');
177 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
178 $appli = $conf->global->MAIN_APPLICATION_TITLE;
179 if (preg_match(
'/\d\.\d/', $appli)) {
180 if (!preg_match(
'/'.preg_quote(DOL_VERSION).
'/', $appli)) {
181 $appli .=
" (".DOL_VERSION.
")";
184 $appli .=
" ".DOL_VERSION;
187 $appli .=
" ".DOL_VERSION;
190 $urlback = $_SERVER[
"REQUEST_URI"];
191 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
193 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
195 $content .=
"<br><br>\n";
196 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
197 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
198 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
199 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
200 $content .=
"<br>\n";
201 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
205 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
206 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
208 $result = $mailfile->sendfile();
210 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
212 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
216 unset($_SESSION[
'ipaddress']);
220 if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
221 $head =
'<link rel="stylesheet" type="text/css" href="'.$conf->global->ONLINE_PAYMENT_CSS_URL.
'?lang='.$langs->defaultlang.
'">'.
"\n";
224 $conf->dol_hide_topmenu = 1;
225 $conf->dol_hide_leftmenu = 1;
227 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
228 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
232 print
'<span id="dolpaymentspan"></span>'.
"\n";
233 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
237 $logosmall = $mysoc->logo_small;
238 $logo = $mysoc->logo;
239 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
240 if (!empty($conf->global->$paramlogo)) {
241 $logosmall = $conf->global->$paramlogo;
242 } elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
243 $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
249 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
250 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
251 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
252 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
253 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
254 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
259 print
'<div class="backgreypublicpayment">';
260 print
'<div class="logopublicpayment">';
261 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
264 if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
265 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>';
269 if (!empty($conf->global->MAIN_IMAGE_PUBLIC_PAYMENT)) {
270 print
'<div class="backimagepublicpayment">';
271 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="'.$conf->global->MAIN_IMAGE_PUBLIC_PAYMENT.
'">';
279 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
281 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
282 if (!empty($conf->global->$key)) {
283 print $conf->global->$key;
287 $ref =
GETPOST(
'ref',
'alphanohtml');
288 $tag =
GETPOST(
'tag',
'alpha');
289 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
291 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
293 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
299 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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) 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,$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.
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.