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"));
76if (isModEnabled(
'paypal')) {
77 $PAYPALTOKEN =
GETPOST(
'TOKEN');
78 if (empty($PAYPALTOKEN)) {
79 $PAYPALTOKEN =
GETPOST(
'token');
81 $PAYPALPAYERID =
GETPOST(
'PAYERID');
82 if (empty($PAYPALPAYERID)) {
83 $PAYPALPAYERID =
GETPOST(
'PayerID');
86if (isModEnabled(
'paybox')) {
88if (isModEnabled(
'stripe')) {
96$suffix =
GETPOST(
"suffix",
'aZ09');
102if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
103 $paymentmethod = $reg[1];
105if (empty($paymentmethod)) {
106 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
114$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
116 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');
120$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
123if (empty($validpaymentmethod)) {
145 $doactionsthenredirect = 1;
149dol_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');
152foreach ($_POST as $k => $v) {
153 if (is_scalar($k) && is_scalar($v)) {
154 $tracepost .=
"$k - $v\n";
157dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
161$appli = $mysoc->name;
165if (!empty($_SESSION[
'ipaddress'])) {
168 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
169 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
171 $paymentType = $_SESSION[
'PaymentType'];
172 $currencyCodeType = $_SESSION[
'currencyCodeType'];
173 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
175 $ipaddress = $_SESSION[
'ipaddress'];
176 $errormessage = $_SESSION[
'errormessage'];
178 if (is_object($object) && method_exists($object,
'call_trigger')) {
180 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
193 $companylangs->setDefaultLang($mysoc->default_lang);
194 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
197 $sendto = $sendemail;
199 $urlback = $_SERVER[
"REQUEST_URI"];
200 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
202 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
204 $content .=
"<br><br>\n";
205 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
206 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
207 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
208 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
209 $content .=
"<br>\n";
210 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
214 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
215 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0);
217 $result = $mailfile->sendfile();
219 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
221 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
225 unset($_SESSION[
'ipaddress']);
229if (empty($doactionsthenredirect)) {
232 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
235 $conf->dol_hide_topmenu = 1;
236 $conf->dol_hide_leftmenu = 1;
238 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
239 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
243 print
'<span id="dolpaymentspan"></span>'.
"\n";
244 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
248 $logosmall = $mysoc->logo_small;
249 $logo = $mysoc->logo;
250 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
260 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
261 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
262 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
263 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
264 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
265 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
270 print
'<div class="backgreypublicpayment">';
271 print
'<div class="logopublicpayment">';
272 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
276 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>';
281 print
'<div class="backimagepublicpayment">';
282 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
290 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
292 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
294 print
$conf->global->$key;
298 $ref =
GETPOST(
'ref',
'alphanohtml');
299 $tag =
GETPOST(
'tag',
'alpha');
300 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
302 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
304 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
320if (!empty($doactionsthenredirect)) {
323 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
324 print
"<script>window.top.location.href = '".dol_escape_js($ext_urlko).
"';</script>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.