28if (!defined(
'NOLOGIN')) {
31if (!defined(
'NOCSRFCHECK')) {
32 define(
"NOCSRFCHECK", 1);
34if (!defined(
'NOIPCHECK')) {
35 define(
'NOIPCHECK',
'1');
37if (!defined(
'NOBROWSERNOTIF')) {
38 define(
'NOBROWSERNOTIF',
'1');
44$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
45if (is_numeric($entity)) {
46 define(
"DOLENTITY", $entity);
49'@phan-var-force CommonObject $object';
52require
'../../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
56if (isModEnabled(
'paypal')) {
57 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
58 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
61$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
63if (isModEnabled(
'paypal')) {
64 $PAYPALTOKEN =
GETPOST(
'TOKEN');
65 if (empty($PAYPALTOKEN)) {
66 $PAYPALTOKEN =
GETPOST(
'token');
68 $PAYPALPAYERID =
GETPOST(
'PAYERID');
69 if (empty($PAYPALPAYERID)) {
70 $PAYPALPAYERID =
GETPOST(
'PayerID');
73if (isModEnabled(
'paybox')) {
75if (isModEnabled(
'stripe')) {
83$suffix =
GETPOST(
"suffix",
'aZ09');
89if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
90 $paymentmethod = $reg[1];
92if (empty($paymentmethod)) {
93 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
100$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
102 dol_syslog(
"Paymentko.php page is invoked from a website with ref ".$ws.
". It performs actions and then redirects back to this website. A page with ref paymentko must be created for this website.", LOG_DEBUG, 0,
'_payment');
106$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
109if (empty($validpaymentmethod)) {
131 $doactionsthenredirect = 1;
135dol_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');
138foreach ($_POST as $k => $v) {
139 if (is_scalar($k) && is_scalar($v)) {
140 $tracepost .=
"$k - $v\n";
143dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
147$appli = $mysoc->name;
150if (!empty($_SESSION[
'ipaddress'])) {
153 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
154 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
156 $paymentType = $_SESSION[
'PaymentType'];
157 $currencyCodeType = $_SESSION[
'currencyCodeType'];
158 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
160 $ipaddress = $_SESSION[
'ipaddress'];
161 $errormessage = $_SESSION[
'errormessage'];
163 if (is_object($object) && method_exists($object,
'call_trigger')) {
165 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
177 $companylangs =
new Translate(
'', $conf);
178 $companylangs->setDefaultLang($mysoc->default_lang);
179 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
182 $sendto = $sendemail;
184 $urlback = $_SERVER[
"REQUEST_URI"];
185 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
187 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
189 $content .=
"<br><br>\n";
190 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
191 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
192 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
193 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
194 $content .=
"<br>\n";
195 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
199 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
200 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml);
202 $result = $mailfile->sendfile();
204 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
206 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
210 unset($_SESSION[
'ipaddress']);
214if (empty($doactionsthenredirect)) {
217 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
220 $conf->dol_hide_topmenu = 1;
221 $conf->dol_hide_leftmenu = 1;
223 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
224 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
228 print
'<span id="dolpaymentspan"></span>'.
"\n";
229 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
233 $logosmall = $mysoc->logo_small;
234 $logo = $mysoc->logo;
235 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
236 if (!empty($conf->global->$paramlogo)) {
245 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
246 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
247 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
248 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
249 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
250 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
255 print
'<div class="backgreypublicpayment">';
256 print
'<div class="logopublicpayment">';
257 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
261 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>';
266 print
'<div class="backimagepublicpayment">';
267 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
275 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
277 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
278 if (!empty($conf->global->$key)) {
279 print $conf->global->$key;
283 $ref =
GETPOST(
'ref',
'alphanohtml');
284 $tag =
GETPOST(
'tag',
'alpha');
285 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
287 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
289 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
305if (!empty($doactionsthenredirect)) {
308 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
309 print
"<script>window.top.location.href = '".dol_escape_js($ext_urlko).
"';</script>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
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_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 dolibarr global constant string value.
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.