From 39c9eb87088a307cca35ab5728b961d887d4a5d1 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 11 Jul 2022 11:44:00 +0200 Subject: [PATCH] Fix: fetch the right amount for membership payment It was defaulting to 9.99 --- htdocs/adherents/card.php | 9 +++++++-- htdocs/core/lib/payments.lib.php | 12 +++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 007ed517d2f..cb206449a97 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2029,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($useonlinepayment) { print '
'; - + if(empty($amount)) { // Take the maximum amount among what the member is supposed to pay / has paid in the past + $amount = price(max($adht->amount, $object->first_subscription_amount, $object->last_subscription_amount)); + } + if(empty($amount)) { + $amount = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - print showOnlinePaymentUrl('membersubscription', $object->ref); + print showOnlinePaymentUrl('membersubscription', $object->ref, $amount); } print '
'; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 01fdc57db51..794c9d5da7e 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -173,9 +173,10 @@ function getValidOnlinePaymentMethods($paymentmethod = '') * * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $ref Ref of object + * @param int $amount Amount of money to request for * @return string Url string */ -function showOnlinePaymentUrl($type, $ref) +function showOnlinePaymentUrl($type, $ref, $amount='9.99') { global $langs; @@ -185,7 +186,7 @@ function showOnlinePaymentUrl($type, $ref) $servicename = ''; // Link is a generic link for all payments services (paypal, stripe, ...) $out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; - $url = getOnlinePaymentUrl(0, $type, $ref); + $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $out .= ''; @@ -199,11 +200,12 @@ function showOnlinePaymentUrl($type, $ref) * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member' ...) * @param string $ref Ref of object * @param string $label Text or HTML tag to display, if empty it display the URL + * @param int $amount Amount of money to request for * @return string Url string */ -function getHtmlOnlinePaymentLink($type, $ref, $label = '') +function getHtmlOnlinePaymentLink($type, $ref, $label = '', $amount='9.99') { - $url = getOnlinePaymentUrl(0, $type, $ref); + $url = getOnlinePaymentUrl(0, $type, $ref, $amount); $label = $label ? $label : $url; return ''.$label.''; } @@ -215,7 +217,7 @@ function getHtmlOnlinePaymentLink($type, $ref, $label = '') * @param int $mode 0=True url, 1=Url formated with colors * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'member', 'boothlocation', ...) * @param string $ref Ref of object - * @param int $amount Amount (required and used for $type='free' only) + * @param int $amount Amount of money to request for * @param string $freetag Free tag (required and used for $type='free' only) * @param string $localorexternal 0=Url for browser, 1=Url for external access * @return string Url string