From 54e335937f4568aa9a40766588319ed5894251f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 18:05:41 +0100 Subject: [PATCH] FIX Bad redirect url for payment of members after public registration --- htdocs/public/members/new.php | 22 ++++++---------------- htdocs/public/payment/newpayment.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 39b905acc8e..6589f2a17d0 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -386,35 +386,25 @@ if (empty($reshook) && $action == 'add') { } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { - $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT // It is not so important because a test is done on return of payment validation. - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } elseif (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); } + $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0); + if (GETPOST('email')) { $urlback .= '&email='.urlencode(GETPOST('email')); } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); } + } else { + if (!empty($entity)) { + $urlback .= '&entity='.((int) $entity); + } } - if (!empty($entity)) { - $urlback .= '&entity='.((int) $entity); - } dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); } else { $error++; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c63cf3b6624..bb58936d78d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1461,9 +1461,12 @@ if ($source == 'member' || $source == 'membersubscription') { $langs->load("members"); require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $member = new Adherent($db); + $adht = new AdherentType($db); + $result = $member->fetch('', $ref); if ($result <= 0) { $mesg = $member->error; @@ -1471,6 +1474,8 @@ if ($source == 'member' || $source == 'membersubscription') { } else { $member->fetch_thirdparty(); $subscription = new Subscription($db); + + $adht->fetch($member->typeid); } $object = $member; @@ -1479,6 +1484,11 @@ if ($source == 'member' || $source == 'membersubscription') { if (GETPOST("amount", 'alpha')) { $amount = GETPOST("amount", 'alpha'); } + // If amount still not defined, we take amount of the type of member + if (empty($amount)) { + $amount = $adht->amount; + } + $amount = price2num($amount, 'MT'); }