30if (!defined(
'NOLOGIN')) {
33if (!defined(
'NOCSRFCHECK')) {
34 define(
"NOCSRFCHECK", 1);
36if (!defined(
'NOIPCHECK')) {
37 define(
'NOIPCHECK',
'1');
39if (!defined(
'NOBROWSERNOTIF')) {
40 define(
'NOBROWSERNOTIF',
'1');
43if (!defined(
'XFRAMEOPTIONS_ALLOWALL')) {
44 define(
'XFRAMEOPTIONS_ALLOWALL',
'1');
50$entity = (!empty($_GET[
'e']) ? (int) $_GET[
'e'] : (!empty($_POST[
'e']) ? (int) $_POST[
'e'] : 1));
51if (is_numeric($entity)) {
52 define(
"DOLENTITY", $entity);
55'@phan-var-force CommonObject $object';
58require
'../../main.inc.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
62if (isModEnabled(
'paypal')) {
63 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
64 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
80$hookmanager->initHooks(array(
'newpayment'));
82$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paybox",
"paypal",
"stripe"));
86if (isModEnabled(
'paypal')) {
87 $PAYPALTOKEN =
GETPOST(
'TOKEN');
88 if (empty($PAYPALTOKEN)) {
89 $PAYPALTOKEN =
GETPOST(
'token');
91 $PAYPALPAYERID =
GETPOST(
'PAYERID');
92 if (empty($PAYPALPAYERID)) {
93 $PAYPALPAYERID =
GETPOST(
'PayerID');
96if (isModEnabled(
'paybox')) {
98if (isModEnabled(
'stripe')) {
102if (empty($FULLTAG)) {
106$suffix =
GETPOST(
"suffix",
'aZ09');
112if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
113 $paymentmethod = $reg[1];
115if (empty($paymentmethod)) {
116 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
119 dol_syslog(
"paymentko.php: paymentmethod=".$paymentmethod, LOG_DEBUG, 0,
'_payment');
124$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
126 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');
130$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
133if (empty($validpaymentmethod)) {
144$ws_virtuelhost =
null;
146$doactionsthenredirect = 0;
148 $doactionsthenredirect = 1;
149 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
151 $result = $website->fetch(0, $ws);
153 $ws_virtuelhost = $website->virtualhost;
154 $ws_id = $website->id;
170dol_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');
173foreach ($_POST as $k => $v) {
174 if (is_scalar($k) && is_scalar($v)) {
175 $tracepost .=
"$k - $v\n";
178dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
180dol_syslog(
"paymentkosessioncode=".
GETPOST(
'paymentkosessioncode').
" SESSION['paymentkosessioncode']=".$_SESSION[
'paymentkosessioncode'], LOG_DEBUG, 0,
'_payment');
183$appli = $mysoc->name;
187if (!empty($_SESSION[
'ipaddress'])) {
190 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
191 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
193 $paymentType = $_SESSION[
'PaymentType'];
194 $currencyCodeType = $_SESSION[
'currencyCodeType'];
195 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
197 $ipaddress = $_SESSION[
'ipaddress'];
198 $errormessage = $_SESSION[
'errormessage'];
200 if (is_object($object) && method_exists($object,
'call_trigger')) {
202 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
215 $myCompanyDefaultLang = $mysoc->default_lang;
216 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
223 $companylangs->setDefaultLang($myCompanyDefaultLang);
224 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'paybox',
'stripe'));
227 $sendto = $sendemail;
229 $urlback = $_SERVER[
"REQUEST_URI"];
230 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
232 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
234 $content .=
"<br><br>\n";
235 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
236 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
237 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
238 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
239 $content .=
"<br>\n";
240 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
244 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
245 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0);
247 $result = $mailfile->sendfile();
249 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
251 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
255 unset($_SESSION[
'ipaddress']);
259if (empty($doactionsthenredirect)) {
262 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
265 $conf->dol_hide_topmenu = 1;
266 $conf->dol_hide_leftmenu = 1;
268 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
269 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
273 print
'<span id="dolpaymentspan"></span>'.
"\n";
274 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
278 $logosmall = $mysoc->logo_small;
279 $logo = $mysoc->logo;
280 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
290 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
291 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
292 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
293 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
294 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
295 $urllogofull = $dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
300 print
'<div class="backgreypublicpayment">';
301 print
'<div class="logopublicpayment">';
302 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
306 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>';
311 print
'<div class="backimagepublicpayment">';
312 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
320 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
322 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
324 print
$conf->global->$key;
328 $ref =
GETPOST(
'ref',
'alphanohtml');
329 $tag =
GETPOST(
'tag',
'alpha');
330 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
332 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
334 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
350if (!empty($doactionsthenredirect)) {
353 $_SESSION[
'paymentkosessionkey'] = $randomseckey;
356 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
357 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
359 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
362 dol_syslog(
"Now do a redirect using Location : ".$ext_urlko, LOG_DEBUG, 0,
'_payment');
363 header(
"Location: ".$ext_urlko);
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 public pages.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
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...
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.