30if (!defined(
'NOLOGIN')) {
33if (!defined(
'NOCSRFCHECK')) {
34 define(
"NOCSRFCHECK", 1);
36if (!defined(
'NOIPCHECK')) {
37 define(
'NOIPCHECK',
'1');
39if (!defined(
'NOBROWSERNOTIF')) {
40 define(
'NOBROWSERNOTIF',
'1');
46$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
47if (is_numeric($entity)) {
48 define(
"DOLENTITY", $entity);
51'@phan-var-force CommonObject $object';
54require
'../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
58if (isModEnabled(
'paypal')) {
59 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
60 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
63$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
65if (isModEnabled(
'paypal')) {
66 $PAYPALTOKEN =
GETPOST(
'TOKEN');
67 if (empty($PAYPALTOKEN)) {
68 $PAYPALTOKEN =
GETPOST(
'token');
70 $PAYPALPAYERID =
GETPOST(
'PAYERID');
71 if (empty($PAYPALPAYERID)) {
72 $PAYPALPAYERID =
GETPOST(
'PayerID');
75if (isModEnabled(
'paybox')) {
77if (isModEnabled(
'stripe')) {
85$suffix =
GETPOST(
"suffix",
'aZ09');
91if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
92 $paymentmethod = $reg[1];
94if (empty($paymentmethod)) {
95 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
102$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
104 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');
108$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
111if (empty($validpaymentmethod)) {
133 $doactionsthenredirect = 1;
137dol_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');
140foreach ($_POST as $k => $v) {
141 if (is_scalar($k) && is_scalar($v)) {
142 $tracepost .=
"$k - $v\n";
145dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
149$appli = $mysoc->name;
152if (!empty($_SESSION[
'ipaddress'])) {
155 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
156 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
158 $paymentType = $_SESSION[
'PaymentType'];
159 $currencyCodeType = $_SESSION[
'currencyCodeType'];
160 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
162 $ipaddress = $_SESSION[
'ipaddress'];
163 $errormessage = $_SESSION[
'errormessage'];
165 if (is_object($object) && method_exists($object,
'call_trigger')) {
167 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
179 $companylangs =
new Translate(
'', $conf);
180 $companylangs->setDefaultLang($mysoc->default_lang);
181 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
184 $sendto = $sendemail;
186 $urlback = $_SERVER[
"REQUEST_URI"];
187 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
189 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
191 $content .=
"<br><br>\n";
192 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
193 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
194 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
195 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
196 $content .=
"<br>\n";
197 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
201 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
202 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0);
204 $result = $mailfile->sendfile();
206 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
208 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
212 unset($_SESSION[
'ipaddress']);
216if (empty($doactionsthenredirect)) {
219 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
222 $conf->dol_hide_topmenu = 1;
223 $conf->dol_hide_leftmenu = 1;
225 $replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
226 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
230 print
'<span id="dolpaymentspan"></span>'.
"\n";
231 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
235 $logosmall = $mysoc->logo_small;
236 $logo = $mysoc->logo;
237 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
247 if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
248 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
249 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
250 } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.
'/logos/'.$logo)) {
251 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
252 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
257 print
'<div class="backgreypublicpayment">';
258 print
'<div class="logopublicpayment">';
259 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
263 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>';
268 print
'<div class="backimagepublicpayment">';
269 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
277 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
279 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
281 print $conf->global->$key;
285 $ref =
GETPOST(
'ref',
'alphanohtml');
286 $tag =
GETPOST(
'tag',
'alpha');
287 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
289 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
291 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
307if (!empty($doactionsthenredirect)) {
310 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
311 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 a 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.