diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 157fc1c8a99..9e2df362467 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -97,6 +97,11 @@ EvntOrgCancelled = Cancelled # Public page # RegisterPage = Page for conferences or booth +EvntOrgRegistrationWelcomeMessage = Welcome on the conference or booth suggestion page. +EvntOrgRegistrationHelpMessage = Here, you can suggest a new conference or a new booth for the project +SuggestConference = Suggest a new conference +SuggestBooth = Suggest a booth +ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index e69de29bb2d..9b04890084e 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -0,0 +1,829 @@ + + * 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 = dol_decode(GETPOST('id'), $dolibarr_main_instance_unique_id); + +// 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. + + +/* + * 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 ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print ''; +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 ''."\n"; + +// Output introduction text +$text = ''; +if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) { + $langs->load("members"); + if (preg_match('/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) { + $text .= $langs->trans($reg[1])."
\n"; + } else { + $text .= $conf->global->PAYMENT_NEWFORM_TEXT."
\n"; + } + $text = ''."\n"; +} +if (empty($text)) { + $text .= ''."\n"; + $text .= ''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; +} + +print "\n"; + + +// Show all payment mode buttons (Stripe, Paypal, ...) +print '
'; +print ''; +print '

'; +print ''; +print '

'; +print ''; + + +print ''."\n"; + +print '

'.$text.'

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'; + +$found = false; +$error = 0; +$var = false; + +$object = null; + + +// Free payment +if (!$source) { + $found = true; + $tag = GETPOST("tag", 'alpha'); + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = "TAG=".$tag; + } + +} + + +// Payment on customer order +if ($source == 'order') { + $found = true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order = new Commande($db); + $result = $order->fetch('', $ref); + if ($result <= 0) { + $mesg = $order->error; + $error++; + } else { + $result = $order->fetch_thirdparty($order->socid); + } + $object = $order; + + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = 'ORD='.$order->id.'.CUS='.$order->thirdparty->id; + if (!empty($TAG)) { + $tag = $TAG; $fulltag .= '.TAG='.$TAG; + } + } + $fulltag = dol_string_unaccent($fulltag); +} + + +// Payment on customer invoice +if ($source == 'invoice') { + $found = true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice = new Facture($db); + $result = $invoice->fetch('', $ref); + if ($result <= 0) { + $mesg = $invoice->error; + $error++; + } else { + $result = $invoice->fetch_thirdparty($invoice->socid); + } + $object = $invoice; + + if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment + $amount = price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed())); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); + } + $amount = price2num($amount); + } + + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = 'INV='.$invoice->id.'.CUS='.$invoice->thirdparty->id; + if (!empty($TAG)) { + $tag = $TAG; $fulltag .= '.TAG='.$TAG; + } + } + $fulltag = dol_string_unaccent($fulltag); + + $labeldesc = $langs->trans("Invoice").' '.$invoice->ref; + if (GETPOST('desc', 'alpha')) { + $labeldesc = GETPOST('desc', 'alpha'); + } + print ''."\n"; +} + +if (!$found && !$mesg) { + $mesg = $langs->trans("ErrorBadParameters"); +} + +if ($mesg) { + print '

'.dol_escape_htmltag($mesg).'
'."\n"; + +print '
'."\n"; +print '
'."\n"; +print '
'; + + + +// Add more content on page for some services +if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payment mode + // Stripe + if (GETPOST('dopayment_stripe', 'alpha')) { + // Personalized checkout + print ''; + + print '
'; + + print ''."\n"; + print '
'."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + + $service = 'StripeLive'; + $servicestatus = 1; + if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeTest'; + $servicestatus = 0; + } + + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + $stripecu = null; + if (is_object($object) && is_object($object->thirdparty)) { + $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); + } + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. + $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object) ? ' ref='.$object->ref : ''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); + // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already paid) + //var_dump($paymentintent); + if ($stripe->error) { + setEventMessages($stripe->error, null, 'errors'); + } + } + } + + //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) + //{ + print ' + + '; + print '
'; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + print '
'; + } + + print '
'; + print ''; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + print '
'; + } + + print '
+ +
'; + + print ' + +
'; + + print '
'; + print ''; + print ''; + + print '
'; + //} + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + if (empty($paymentintent)) { + print '
'.$langs->trans("Error").'
'; + } else { + print ''; + //$_SESSION["paymentintent_id"] = $paymentintent->id; + } + } + + print '
'."\n"; + + + // JS Code for Stripe + if (empty($stripearrayofkeys['publishable_key'])) { + $langs->load("errors"); + print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); + } else { + print ''; + print ''."\n"; + print ''."\n"; + + // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. + print ''; + } + } + // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) + $parameters = [ + 'paymentmethod' => $paymentmethod, + 'amount' => price2num(GETPOST("newamount"), 'MT'), + 'tag' => GETPOST("tag", 'alpha'), + 'dopayment' => GETPOST('dopayment', 'alpha') + ]; + $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); +} + + +htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); + +llxFooter('', 'public'); + +$db->close();