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';
63 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypal.lib.php';
64 require_once DOL_DOCUMENT_ROOT.
'/paypal/lib/paypalfunctions.lib.php';
81$hookmanager->initHooks(array(
'newpayment'));
83$langs->loadLangs(array(
"main",
"other",
"dict",
"bills",
"companies",
"paypal",
"stripe"));
88 $PAYPALTOKEN =
GETPOST(
'TOKEN');
89 if (empty($PAYPALTOKEN)) {
90 $PAYPALTOKEN =
GETPOST(
'token');
92 $PAYPALPAYERID =
GETPOST(
'PAYERID');
93 if (empty($PAYPALPAYERID)) {
94 $PAYPALPAYERID =
GETPOST(
'PayerID');
103$suffix =
GETPOST(
"suffix",
'aZ09');
109if (preg_match(
'/PM=([^\.]+)/', $FULLTAG, $reg)) {
110 $paymentmethod = $reg[1];
112if (empty($paymentmethod)) {
113 dol_print_error(
null,
'The back url does not contain a parameter fulltag that should help us to find the payment method used');
116 dol_syslog(
"paymentko.php: paymentmethod=".$paymentmethod, LOG_DEBUG, 0,
'_payment');
121$ws = preg_match(
'/WS=([^\.]+)/', $FULLTAG, $reg_ws) ? $reg_ws[1] : 0;
123 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');
127$validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod);
130if (empty($validpaymentmethod)) {
141$ws_virtuelhost =
null;
143$doactionsthenredirect = 0;
145 $doactionsthenredirect = 1;
146 include_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
148 $result = $website->fetch(0, $ws);
150 $ws_virtuelhost = $website->virtualhost;
151 $ws_id = $website->id;
167dol_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');
170foreach ($_POST as $k => $v) {
171 if (is_scalar($k) && is_scalar($v)) {
172 $tracepost .=
"$k - $v\n";
175dol_syslog(
"POST=".$tracepost, LOG_DEBUG, 0,
'_payment');
177dol_syslog(
"paymentkosessioncode=".
GETPOST(
'paymentkosessioncode').
" SESSION['paymentkosessioncode']=".$_SESSION[
'paymentkosessioncode'], LOG_DEBUG, 0,
'_payment');
185if (!empty($_SESSION[
'ipaddress'])) {
188 $onlinetoken = empty($PAYPALTOKEN) ? $_SESSION[
'onlinetoken'] : $PAYPALTOKEN;
189 $payerID = empty($PAYPALPAYERID) ? $_SESSION[
'payerID'] : $PAYPALPAYERID;
191 $paymentType = $_SESSION[
'PaymentType'] ??
'';
192 $currencyCodeType = $_SESSION[
'currencyCodeType'];
193 $FinalPaymentAmt = $_SESSION[
'FinalPaymentAmt'];
195 $ipaddress = $_SESSION[
'ipaddress'];
196 $errormessage = $_SESSION[
'errormessage'];
199 if (is_object($object) && method_exists($object,
'call_trigger')) {
201 $result =
$object->call_trigger(
'PAYMENTONLINE_PAYMENT_KO', $user);
215 if (empty($myCompanyDefaultLang) || $myCompanyDefaultLang ===
'auto') {
222 $companylangs->setDefaultLang($myCompanyDefaultLang);
223 $companylangs->loadLangs(array(
'main',
'members',
'bills',
'paypal',
'stripe'));
226 $sendto = $sendemail;
228 $urlback = $_SERVER[
"REQUEST_URI"];
229 $topic =
'['.$appli.
'] '.$companylangs->transnoentitiesnoconv(
"NewOnlinePaymentFailed");
231 $content .=
'<span style="color: orange">'.$companylangs->transnoentitiesnoconv(
"ValidationOfOnlinePaymentFailed").
"</span>\n";
233 $content .=
"<br><br>\n";
234 $content .=
'<u>'.$companylangs->transnoentitiesnoconv(
"TechnicalInformation").
":</u><br>\n";
235 $content .= $companylangs->transnoentitiesnoconv(
"OnlinePaymentSystem").
': <strong>'.$paymentmethod.
"</strong><br>\n";
236 $content .= $companylangs->transnoentitiesnoconv(
"ReturnURLAfterPayment").
': '.$urlback.
"<br>\n";
237 $content .= $companylangs->transnoentitiesnoconv(
"Error").
': '.$errormessage.
"<br>\n";
238 $content .=
"<br>\n";
239 $content .=
"tag=".$fulltag.
" token=".$onlinetoken.
" paymentType=".$paymentType.
" currencycodeType=".$currencyCodeType.
" payerId=".$payerID.
" ipaddress=".$ipaddress.
" FinalPaymentAmt=".$FinalPaymentAmt;
243 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
244 $mailfile =
new CMailFile($topic, $sendto, $from, $content, array(), array(), array(),
'',
'', 0, $ishtml ? 1 : 0);
246 $result = $mailfile->sendfile();
248 dol_syslog(
"EMail sent to ".$sendto, LOG_DEBUG, 0,
'_payment');
250 dol_syslog(
"Failed to send EMail to ".$sendto, LOG_ERR, 0,
'_payment');
254 unset($_SESSION[
'ipaddress']);
258if (empty($doactionsthenredirect)) {
261 $head =
'<link rel="stylesheet" type="text/css" href="' .
getDolGlobalString(
'ONLINE_PAYMENT_CSS_URL').
'?lang='.$langs->defaultlang.
'">'.
"\n";
264 $conf->dol_hide_topmenu = 1;
265 $conf->dol_hide_leftmenu = 1;
267 $replacemainarea = (empty(
$conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
268 llxHeader($head, $langs->trans(
"PaymentForm"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
272 print
'<span id="dolpaymentspan"></span>'.
"\n";
273 print
'<div id="dolpaymentdiv" align="center">'.
"\n";
277 $logosmall =
$mysoc->logo_small;
279 $paramlogo =
'ONLINE_PAYMENT_LOGO_'.$suffix;
289 if (!empty($logosmall) && is_readable(
$conf->mycompany->dir_output.
'/logos/thumbs/'.$logosmall)) {
290 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
291 $urllogofull =
$dolibarr_main_url_root.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/thumbs/'.$logosmall);
292 } elseif (!empty($logo) && is_readable(
$conf->mycompany->dir_output.
'/logos/'.$logo)) {
293 $urllogo = DOL_URL_ROOT.
'/viewimage.php?modulepart=mycompany&entity='.
$conf->entity.
'&file='.urlencode(
'logos/'.$logo);
299 print
'<div class="backgreypublicpayment">';
300 print
'<div class="logopublicpayment">';
301 print
'<img id="dolpaymentlogo" src="'.$urllogo.
'"';
305 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>';
310 print
'<div class="backimagepublicpayment">';
311 print
'<img id="idMAIN_IMAGE_PUBLIC_PAYMENT" src="' .
getDolGlobalString(
'MAIN_IMAGE_PUBLIC_PAYMENT').
'">';
319 print $langs->trans(
"YourPaymentHasNotBeenRecorded").
"<br><br>";
321 $key =
'ONLINE_PAYMENT_MESSAGE_KO';
323 print
$conf->global->$key;
327 $ref =
GETPOST(
'ref',
'alphanohtml');
328 $tag =
GETPOST(
'tag',
'alpha');
329 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
331 $urlsubscription = getOnlinePaymentUrl(0, ($type ? $type :
'free'), $ref, $FinalPaymentAmt, $tag);
333 print $langs->trans(
"ClickHereToTryAgain", $urlsubscription);
349if (!empty($doactionsthenredirect)) {
352 $_SESSION[
'paymentkosessionkey'] = $randomseckey;
355 if (!defined(
'USEDOLIBARRSERVER') && !empty($ws_virtuelhost)) {
356 $ext_urlko = $ws_virtuelhost .
'/paymentko.php?paymentkosessioncode='.urlencode($randomseckey).
'&fulltag='.$FULLTAG;
358 $ext_urlko = DOL_URL_ROOT.
'/public/website/index.php?paymentkosessioncode='.urlencode($randomseckey).
'&website='.urlencode($ws).
'&pageref=paymentko&fulltag='.$FULLTAG;
361 dol_syslog(
"Now do a redirect using Location : ".$ext_urlko, LOG_DEBUG, 0,
'_payment');
362 header(
"Location: ".$ext_urlko);
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.