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';
73$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
75if (isModEnabled(
'paypal')) {
76 $PAYPALTOKEN =
GETPOST(
'TOKEN');
77 if (empty($PAYPALTOKEN)) {
78 $PAYPALTOKEN =
GETPOST(
'token');
80 $PAYPALPAYERID =
GETPOST(
'PAYERID');
81 if (empty($PAYPALPAYERID)) {
82 $PAYPALPAYERID =
GETPOST(
'PayerID');
85if (isModEnabled(
'paybox')) {
87if (isModEnabled(
'stripe')) {
95$suffix =
GETPOST(
"suffix",
'aZ09');
101if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
102 $paymentmethod = $reg[1];
104if (empty($paymentmethod)) {
105 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
112$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
114 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');
118$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
121if (empty($validpaymentmethod)) {
143 $doactionsthenredirect = 1;
147dol_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');
150foreach ($_POST as $k => $v) {
151 if (is_scalar($k) && is_scalar($v)) {
152 $tracepost .=
"$k - $v\n";
155dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
159$appli = $mysoc->name;
163if (!empty($_SESSION[
'ipaddress'])) {
166 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
167 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
169 $paymentType = $_SESSION[
'PaymentType'];
170 $currencyCodeType = $_SESSION[
'currencyCodeType'];
171 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
173 $ipaddress = $_SESSION[
'ipaddress'];
174 $errormessage = $_SESSION[
'errormessage'];
176 if (is_object($object) && method_exists($object,
'call_trigger')) {
178 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
191 $companylangs->setDefaultLang($mysoc->default_lang);
192 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
195 $sendto = $sendemail;
197 $urlback = $_SERVER[
"REQUEST_URI"];
198 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
200 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
202 $content .=
"<br><br>\n";
203 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
204 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
205 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
206 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
207 $content .=
"<br>\n";
208 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
212 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
213 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0);
215 $result = $mailfile->sendfile();
217 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
219 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
223 unset($_SESSION[
'ipaddress']);
227if (empty($doactionsthenredirect)) {
230 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
233 $conf->dol_hide_topmenu = 1;
234 $conf->dol_hide_leftmenu = 1;
236 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
237 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
241 print
'<span id="dolpaymentspan"></span>'.
"\n";
242 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
246 $logosmall = $mysoc->logo_small;
247 $logo = $mysoc->logo;
248 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
258 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
259 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
260 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
261 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
262 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
263 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
268 print
'<div class="backgreypublicpayment">';
269 print
'<div class="logopublicpayment">';
270 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
274 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>';
279 print
'<div class="backimagepublicpayment">';
280 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
288 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
290 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
292 print
$conf->global->$key;
296 $ref =
GETPOST(
'ref',
'alphanohtml');
297 $tag =
GETPOST(
'tag',
'alpha');
298 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
300 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
302 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
318if (!empty($doactionsthenredirect)) {
321 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
322 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.