Clean code

This commit is contained in:
Laurent Destailleur 2022-02-18 12:36:05 +01:00
parent aec2579c41
commit 3ab2308124
6 changed files with 17 additions and 35 deletions

View File

@ -19,16 +19,6 @@
* \file htdocs/public/eventorganization/attendee_new.php
* \ingroup project
* \brief Example of form to subscribe to an event
*
* Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
* MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted
* MEMBER_NEWFORM_FORCETYPE Force type of member
* MEMBER_NEWFORM_FORCEMORPHY Force nature of member (mor/phy)
* MEMBER_NEWFORM_FORCECOUNTRYCODE Force country
*/
if (!defined('NOLOGIN')) {

View File

@ -30,6 +30,7 @@
* Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
* MEMBER_MIN_AMOUNT Minimum amount
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
* MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted

View File

@ -481,7 +481,7 @@ if ($action == 'dopayment') {
// Called when choosing Stripe mode.
// When using the Charge API architecture, this code is called after clicking the 'dopayment' with the Charge API architecture.
// When using the old Charge API architecture, this code is called after clicking the 'dopayment' with the Charge API architecture.
// When using the PaymentIntent API architecture, the Stripe customer was already created when creating PaymentIntent when showing payment page, and the payment is already ok when action=charge.
if ($action == 'charge' && !empty($conf->stripe->enabled)) {
$amountstripe = $amount;
@ -728,7 +728,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) {
}
}
// When using the PaymentIntent API architecture
// When using the PaymentIntent API architecture (mode set on by default into conf.class.php)
if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) {
$service = 'StripeTest';
$servicestatus = 0;
@ -793,8 +793,8 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) {
$remoteip = getUserRemoteIP();
$_SESSION["onlinetoken"] = $stripeToken;
$_SESSION["FinalPaymentAmt"] = $amount;
$_SESSION["currencyCodeType"] = $currency;
$_SESSION["FinalPaymentAmt"] = $amount; // amount really paid (coming from Stripe). Will be used for check in paymentok.php.
$_SESSION["currencyCodeType"] = $currency; // currency really used for payment (coming from Stripe). Will be used for check in paymentok.php.
$_SESSION["paymentType"] = '';
$_SESSION['ipaddress'] = ($remoteip ? $remoteip : 'unknown'); // Payer ip
$_SESSION['payerID'] = is_object($customer) ? $customer->id : '';

View File

@ -417,7 +417,7 @@ if ($ispaymentok) {
// 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) {
// Security protection:
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If we didn't allow members to choose their membership amount
if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If we didn't allow members to choose their membership amount (if free amount is allowed, no need to check)
if ($object->status == $object::STATUS_DRAFT) { // If the member is not yet validated, we check that the amount is the same as expected.
$typeid = $object->typeid;
@ -440,6 +440,17 @@ if ($ispaymentok) {
}
}
// Security protection:
if (!empty($conf->global->MEMBER_MIN_AMOUNT)) {
if ($FinalPaymentAmt < $conf->global->MEMBER_MIN_AMOUNT) {
$error++;
$errmsg = 'Value of FinalPayment ('.$FinalPaymentAmt.') is lower than the minimum allowed ('.$conf->global->MEMBER_MIN_AMOUNT.'). May be a hack to try to pay a different amount ?';
$postactionmessages[] = $errmsg;
$ispostactionok = -1;
dol_syslog("Failed to validate member (amount lower than minimum): ".$errmsg, LOG_ERR, 0, '_payment');
}
}
// Security protection:
if ($currencyCodeType && $currencyCodeType != $conf->currency) { // Check that currency is the good one
$error++;

View File

@ -19,16 +19,6 @@
* \file htdocs/public/project/suggestbooth.php
* \ingroup member
* \brief Example of form to suggest a booth
*
* Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
* MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted
* MEMBER_NEWFORM_FORCETYPE Force type of member
* MEMBER_NEWFORM_FORCEMORPHY Force nature of member (mor/phy)
* MEMBER_NEWFORM_FORCECOUNTRYCODE Force country
*/
if (!defined('NOLOGIN')) {

View File

@ -19,16 +19,6 @@
* \file htdocs/public/project/suggestconference.php
* \ingroup member
* \brief Example of form to suggest a conference
*
* Note that you can add following constant to change behaviour of page
* MEMBER_NEWFORM_AMOUNT Default amount for auto-subscribe form
* MEMBER_NEWFORM_EDITAMOUNT 0 or 1 = Amount can be edited
* MEMBER_NEWFORM_PAYONLINE Suggest payment with paypal, paybox or stripe
* MEMBER_NEWFORM_DOLIBARRTURNOVER Show field turnover (specific for dolibarr foundation)
* MEMBER_URL_REDIRECT_SUBSCRIPTION Url to redirect once subscribe submitted
* MEMBER_NEWFORM_FORCETYPE Force type of member
* MEMBER_NEWFORM_FORCEMORPHY Force nature of member (mor/phy)
* MEMBER_NEWFORM_FORCECOUNTRYCODE Force country
*/
if (!defined('NOLOGIN')) {