'.$langs->trans("Company");
if (!empty(floatval($project->price_registration))) {
diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php
new file mode 100644
index 00000000000..02fb456f7d2
--- /dev/null
+++ b/htdocs/public/eventorganization/subscriptionok.php
@@ -0,0 +1,167 @@
+
+ * Copyright (C) 2006-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2021 Waël Almoman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/payment/paymentok.php
+ * \ingroup core
+ * \brief File to show page after a successful payment
+ * This page is called by payment system with url provided to it completed with parameter TOKEN=xxx
+ * This token can be used to get more informations.
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
+$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1));
+if (is_numeric($entity)) {
+ define("DOLENTITY", $entity);
+}
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+
+if (!empty($conf->paypal->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
+}
+
+global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root, $mysoc;
+
+$langs->loadLangs(array("main", "companies", "install", "other", "eventorganization"));
+
+$object = new stdClass(); // For triggers
+
+$error = 0;
+
+// Security check
+$id = GETPOST("id");
+$securekeyreceived = GETPOST("securekey");
+$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
+
+if ($securekeyreceived != $securekeytocompare) {
+ print $langs->trans('MissingOrBadSecureKey');
+ exit;
+}
+
+/*
+ * Actions
+ */
+
+
+
+/*
+ * View
+ */
+
+$now = dol_now();
+
+dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"]) ?dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"]) ?dol_escape_htmltag($_SERVER["SCRIPT_URI"]) : ''), LOG_DEBUG, 0, '_payment');
+
+$tracepost = "";
+foreach ($_POST as $k => $v) {
+ $tracepost .= "{$k} - {$v}\n";
+}
+dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment');
+
+$head = '';
+if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
+ $head = ''."\n";
+}
+
+$conf->dol_hide_topmenu = 1;
+$conf->dol_hide_leftmenu = 1;
+
+$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '' : '').' ';
+llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
+
+
+// Show message
+print ' '."\n";
+print ' '."\n";
+
+
+// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo)
+// Define logo and logosmall
+$logosmall = $mysoc->logo_small;
+$logo = $mysoc->logo;
+$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix;
+if (!empty($conf->global->$paramlogo)) {
+ $logosmall = $conf->global->$paramlogo;
+} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) {
+ $logosmall = $conf->global->ONLINE_PAYMENT_LOGO;
+}
+//print ''."\n";
+// Define urllogo
+$urllogo = '';
+$urllogofull = '';
+if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
+ $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall);
+} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
+ $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo);
+}
+
+// Output html code for logo
+if ($urllogo) {
+ print ' ';
+ print ' ';
+ print '  ';
+ print ' ';
+ if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
+ print ' ';
+ }
+ print ' ';
+}
+
+
+print ' ';
+
+print $langs->trans("SubscriptionOk");
+
+print "\n \n";
+
+
+htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix);
+
+
+// Clean session variables to avoid duplicate actions if post is resent
+unset($_SESSION["FinalPaymentAmt"]);
+unset($_SESSION["TRANSACTIONID"]);
+
+
+llxFooter('', 'public');
+
+$db->close();
diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index 7007455791a..38b5f1b4a00 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -59,13 +59,19 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Hook to be used by external payment modules (ie Payzen, ...)
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('newpayment'));
+// For encryption
+global $dolibarr_main_instance_unique_id;
+
// Load translation files
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
@@ -106,6 +112,38 @@ if (!$action) {
}
}
+if ($source == 'conferencesubscription') {
+ // Finding the Attendee
+ $invoiceid = GETPOST('ref');
+ $invoice = new Facture($db);
+ $resultinvoice = $invoice->fetch($invoiceid);
+ if ($resultinvoice <= 0) {
+ setEventMessages(null, $invoice->errors, "errors");
+ } else {
+ $invoice->fetchObjectLinked();
+ $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee'];
+
+ if (is_array($linkedAttendees)) {
+ $linkedAttendees = array_values($linkedAttendees);
+
+ $attendee = new ConferenceOrBoothAttendee($db);
+ $resultattendee = $attendee->fetch($linkedAttendees[0]);
+ if ($resultattendee <= 0) {
+ setEventMessages(null, $attendee->errors, "errors");
+ } else {
+ $amount = price2num($invoice->total_ttc);
+ // Finding the associated thirdparty
+ $thirdparty = new Societe($db);
+ $resultthirdparty = $thirdparty->fetch($invoice->socid);
+ if ($resultthirdparty <= 0) {
+ setEventMessages(null, $thirdparty->errors, "errors");
+ }
+ $object = $thirdparty;
+ }
+ }
+ }
+}
+
$paymentmethod = GETPOST('paymentmethod', 'alphanohtml') ?GETPOST('paymentmethod', 'alphanohtml') : ''; // Empty in most cases. Defined when a payment mode is forced
$validpaymentmethod = array();
@@ -132,6 +170,7 @@ $ref = $REF = GETPOST('ref', 'alpha');
$TAG = GETPOST("tag", 'alpha');
$FULLTAG = GETPOST("fulltag", 'alpha'); // fulltag is tag with more informations
$SECUREKEY = GETPOST("securekey"); // Secure key
+
if ($paymentmethod && !preg_match('/'.preg_quote('PM='.$paymentmethod, '/').'/', $FULLTAG)) {
$FULLTAG .= ($FULLTAG ? '.' : '').'PM='.$paymentmethod;
}
@@ -1723,6 +1762,94 @@ if ($source == 'donation') {
print ' '."\n";
}
+if ($source == 'conferencesubscription') {
+ $found = true;
+ $langs->load("members");
+
+ if (GETPOST('fulltag', 'alpha')) {
+ $fulltag = GETPOST('fulltag', 'alpha');
+ } else {
+ $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S');
+ if (!empty($TAG)) {
+ $tag = $TAG; $fulltag .= '.TAG='.$TAG;
+ }
+ }
+ $fulltag = dol_string_unaccent($fulltag);
+
+ // Creditor
+ print ' | '.$langs->trans("Creditor");
+ print ' | '.$creditor.'';
+ print '';
+ print ' | '."\n";
+
+ // Debitor
+ print ' | '.$langs->trans("Attendee");
+ print ' | ';
+ print $thirdparty->name;
+ print '';
+ print ' | '."\n";
+
+ // Object
+ $text = ' '.$langs->trans("PaymentConferenceAttendee").'';
+ if (GETPOST('desc', 'alpha')) {
+ $text = ' '.$langs->trans(GETPOST('desc', 'alpha')).'';
+ }
+ print ' | '.$langs->trans("Designation");
+ print ' | '.$text;
+ print '';
+ print '';
+ print ' | '."\n";
+
+ // Amount
+ print ' | '.$langs->trans("Amount");
+ print ' | ';
+ $valtoshow = $amount;
+ print ''.price($valtoshow).'';
+ print '';
+ print '';
+
+ // Currency
+ print ' '.$langs->trans("Currency".$currency).'';
+ print '';
+ print ' | '."\n";
+
+ // Tag
+ print ' | '.$langs->trans("PaymentCode");
+ print ' | '.$fulltag.'';
+ print '';
+ print '';
+ print ' | '."\n";
+
+ // Shipping address
+ $shipToName = $thirdparty->getFullName($langs);
+ $shipToStreet = $thirdparty->address;
+ $shipToCity = $thirdparty->town;
+ $shipToState = $thirdparty->state_code;
+ $shipToCountryCode = $thirdparty->country_code;
+ $shipToZip = $thirdparty->zip;
+ $shipToStreet2 = '';
+ $phoneNum = $thirdparty->phone;
+ if ($shipToName && $shipToStreet && $shipToCity && $shipToCountryCode && $shipToZip) {
+ print '';
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ print ' '."\n";
+ } else {
+ print ''."\n";
+ }
+ print ' '."\n";
+ print ' '."\n";
+ $labeldesc = $langs->trans("PaymentSubscription");
+ if (GETPOST('desc', 'alpha')) {
+ $labeldesc = GETPOST('desc', 'alpha');
+ }
+ print ' '."\n";
+}
if (!$found && !$mesg) {
$mesg = $langs->trans("ErrorBadParameters");
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index ffc30467fd1..de9deb7d249 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -51,12 +51,15 @@ if (is_numeric($entity)) {
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
if (!empty($conf->paypal->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php';
}
+global $dolibarr_main_instance_unique_id;
+
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal"));
// Clean parameters
@@ -912,6 +915,177 @@ if ($ispaymentok) {
// TODO send email with acknowledgment for the donation
// (need that the donation module can gen a pdf document for the cerfa with pre filled content)
+ } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) {
+ // Record payment
+ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ $object = new Facture($db);
+ $result = $object->fetch($ref);
+ if ($result) {
+ $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"];
+
+ $paymentTypeId = 0;
+ if ($paymentmethod == 'paybox') {
+ $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS;
+ }
+ if ($paymentmethod == 'paypal') {
+ $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS;
+ }
+ if ($paymentmethod == 'stripe') {
+ $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS;
+ }
+ if (empty($paymentTypeId)) {
+ $paymentType = $_SESSION["paymentType"];
+ if (empty($paymentType)) {
+ $paymentType = 'CB';
+ }
+ $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1);
+ }
+
+ $currencyCodeType = $_SESSION['currencyCodeType'];
+
+ // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time)
+ if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) {
+ $resultvalidate = $object->validate($user);
+ if ($resultvalidate < 0) {
+ $postactionmessages[] = 'Cannot validate invoice';
+ $ispostactionok = -1;
+ $error++; // Not yet supported
+ } else {
+ $db->begin();
+
+ // Creation of payment line
+ include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
+ $paiement = new Paiement($db);
+ $paiement->datepaye = $now;
+ if ($currencyCodeType == $conf->currency) {
+ $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id
+ } else {
+ $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching
+
+ $postactionmessages[] = 'Payment was done in a different currency that currency expected of company';
+ $ispostactionok = -1;
+ $error++; // Not yet supported
+ }
+ $paiement->paiementid = $paymentTypeId;
+ $paiement->num_payment = '';
+ $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
+ $paiement->ext_payment_id = $TRANSACTIONID;
+ $paiement->ext_payment_site = $service;
+
+ if (!$error) {
+ $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents
+ if ($paiement_id < 0) {
+ $postactionmessages[] = $paiement->error.' '.join(" \n", $paiement->errors);
+ $ispostactionok = -1;
+ $error++;
+ } else {
+ $postactionmessages[] = 'Payment created';
+ $ispostactionok = 1;
+ }
+ }
+
+ if (!$error && !empty($conf->banque->enabled)) {
+ $bankaccountid = 0;
+ if ($paymentmethod == 'paybox') {
+ $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
+ } elseif ($paymentmethod == 'paypal') {
+ $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
+ } elseif ($paymentmethod == 'stripe') {
+ $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
+ }
+
+ if ($bankaccountid > 0) {
+ $label = '(CustomerInvoicePayment)';
+ if ($object->type == Facture::TYPE_CREDIT_NOTE) {
+ $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
+ }
+ $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', '');
+ if ($result < 0) {
+ $postactionmessages[] = $paiement->error.' '.join(" \n", $paiement->errors);
+ $ispostactionok = -1;
+ $error++;
+ } else {
+ $postactionmessages[] = 'Bank transaction of payment created';
+ $ispostactionok = 1;
+ }
+ } else {
+ $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';
+ $ispostactionok = -1;
+ $error++;
+ }
+ }
+
+ if (!$error) {
+ $db->commit();
+
+ // Validating the attendee
+ $attendeetovalidate = new ConferenceOrBoothAttendee($db);
+ $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']);
+ if ($resultattendee < 0) {
+ setEventMessages(null, $attendeetovalidate->errors, "errors");
+ } else {
+ $attendeetovalidate->setStatut(1);
+
+ // Sending mail
+ $thirdparty = new Societe($db);
+ $thirdparty->fetch($attendeetovalidate->fk_soc);
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+ // Set output language
+ $outputlangs = new Translate('', $conf);
+ $outputlangs->setDefaultLang(empty($thirdparty->default_lang) ? $mysoc->default_lang : $thirdparty->default_lang);
+ // Load traductions files required by page
+ $outputlangs->loadLangs(array("main", "members"));
+ // Get email content from template
+ $arraydefaultmessage = null;
+
+ $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT;
+ if (!empty($labeltouse)) {
+ $arraydefaultmessage = $formmail->getEMailTemplate($db, 'eventorganization_send', $user, $outputlangs, $labeltouse, 1, '');
+ }
+
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
+ $subject = $arraydefaultmessage->topic;
+ $msg = $arraydefaultmessage->content;
+ }
+
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+
+ $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
+ $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
+
+ $sendto = $thirdparty->email;
+ $from = $conf->global->MAILING_EMAIL_FROM;
+ $urlback = $_SERVER["REQUEST_URI"];
+
+ $ishtml = dol_textishtml($texttosend); // May contain urls
+
+ $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml);
+
+ $result = $mailfile->sendfile();
+ if ($result) {
+ dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
+ } else {
+ dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
+ }
+ }
+ } else {
+ $db->rollback();
+ }
+ }
+ } else {
+ $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.';
+ $ispostactionok = -1;
+ }
+ } else {
+ $postactionmessages[] = 'Invoice paid '.$tmptag['ATT'].' was not found';
+ $ispostactionok = -1;
+ }
+ } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) {
+ // @todo BOOTH CASE (to copy and adapt from above)
} else {
// Nothing done
}
diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php
new file mode 100644
index 00000000000..ce48db9e729
--- /dev/null
+++ b/htdocs/public/project/index.php
@@ -0,0 +1,228 @@
+
+ * Copyright (C) 2006-2017 Laurent Destailleur
+ * Copyright (C) 2009-2012 Regis Houssin
+ * Copyright (C) 2018 Juanjo Menent
+ * Copyright (C) 2018-2019 Thibault FOUCART
+ * Copyright (C) 2021 Waël Almoman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * For Paypal test: https://developer.paypal.com/
+ * For Paybox test: ???
+ * For Stripe test: Use credit card 4242424242424242 .More example on https://stripe.com/docs/testing
+ *
+ * Variants:
+ * - When option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on, we use the new PaymentIntent API
+ * - When option STRIPE_USE_NEW_CHECKOUT is on, we use the new checkout API
+ * - If no option set, we use old APIS (charge)
+ */
+
+/**
+ * \file htdocs/public/payment/newpayment.php
+ * \ingroup core
+ * \brief File to offer a way to make a payment for a particular Dolibarr object
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php
+$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1))));
+if (is_numeric($entity)) {
+ define("DOLENTITY", $entity);
+}
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+// Hook to be used by external payment modules (ie Payzen, ...)
+include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+$hookmanager = new HookManager($db);
+$hookmanager->initHooks(array('newpayment'));
+
+// For encryption
+global $dolibarr_main_instance_unique_id;
+
+// Load translation files
+$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data
+
+// Security check
+// No check on module enabled. Done later according to $validpaymentmethod
+
+$action = GETPOST('action', 'aZ09');
+$id = GETPOST('id');
+$securekeyreceived = GETPOST("securekey");
+$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
+
+if ($securekeytocompare != $securekeyreceived) {
+ print $langs->trans('MissingOrBadSecureKey');
+ exit;
+}
+
+// Define $urlwithroot
+//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
+
+$project = new Project($db);
+$resultproject = $project->fetch($id);
+if ($resultproject < 0) {
+ $error++;
+ $errmsg .= $project->error;
+}
+
+/*
+ * Actions
+ */
+
+
+/*
+ * View
+ */
+
+$head = '';
+if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) {
+ $head = ''."\n";
+}
+
+$conf->dol_hide_topmenu = 1;
+$conf->dol_hide_leftmenu = 1;
+
+$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '' : '').' ';
+llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
+
+
+// Show sandbox warning
+if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox'
+ dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Paypal'), '', 'warning');
+}
+if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) {
+ dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
+}
+
+
+print ' '."\n";
+print ' '."\n";
+print ' '."\n";
+print ' '."\n";
+print ' ';
+
+
+htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
+
+llxFooter('', 'public');
+
+$db->close();
|