Fix: fetch the right amount for membership payment

It was defaulting to 9.99
This commit is contained in:
Yoan Mollard 2022-07-11 11:44:00 +02:00
parent 2699159dea
commit 39c9eb8708
2 changed files with 14 additions and 7 deletions

View File

@ -2029,9 +2029,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($useonlinepayment) {
print '<br>';
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 '</div><div class="fichehalfright">';

View File

@ -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').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'</span><br>';
$url = getOnlinePaymentUrl(0, $type, $ref);
$url = getOnlinePaymentUrl(0, $type, $ref, $amount);
$out .= '<div class="urllink"><input type="text" id="onlinepaymenturl" class="quatrevingtpercentminusx" value="'.$url.'">';
$out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
$out .= '</div>';
@ -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 '<a href="'.$url.'" target="_blank" rel="noopener noreferrer">'.$label.'</a>';
}
@ -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