Bugzilla – Attachment 93140 Details for
Bug 23213
Add hook to OPAC payments to allow plugins to set minimum payment threshold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23213: Enable minimum payment threshold check in OPAC
Bug-23213-Enable-minimum-payment-threshold-check-i.patch (text/plain), 8.46 KB, created by
Martin Renvoize (ashimema)
on 2019-09-24 13:37:08 UTC
(
hide
)
Description:
Bug 23213: Enable minimum payment threshold check in OPAC
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-09-24 13:37:08 UTC
Size:
8.46 KB
patch
obsolete
>From ac071f6f61eb83f22e1c483718808f2770431b73 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Wed, 26 Jun 2019 02:02:39 -0300 >Subject: [PATCH] Bug 23213: Enable minimum payment threshold check in OPAC > >This patch enables OPAC to check for the miminum payment threshold per payment method. > >If the total amount to pay is less than the threshold, payment for that method is disabled. > >To test: >1) apply dependencies >2) get 2 payment plugins, one with threshold as https://gitlab.com/thekesolutions/plugins/koha-plugin-pay-via-paypal/uploads/4c66444ff697586dff3d8759c1e5746c/koha-plugin-pay-via-paypal-v1.0.0.kpz and one without threshold as https://github.com/bywatersolutions/koha-plugin-pay-via-paygov/releases/download/v1.0.5/koha-plugin-pay-via-paygov-v1.0.5.kpz >3) install both plugins >4) Configure both plugins to work correctly (can be invented data.. we are not interested in the actual payment page, but to test if payment method is allowed) >5) In plugin with threshold, set minimum threshold to 10 >6) Fetch any user, and create 2 manual invoices, both for the amount of 5 >7) Enter OPAC as user, and go to "my fines" tab >CHECK => both plugins appear as payment method >8) Check the checkbox of one of the fines >SUCCESS => plugin with threshold is now disabled, and has a warning message that says "Minimum amount needed by this service is 10.00" > => plugin without threshold is enabled > => if plugin with threshold was selected, "Make payment" button is disabled until an enabled payment method is selected >9) Check the second checkbox >SUCCESS => both payment methods are now enabled >10) Sign off > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../bootstrap/en/includes/account-table.inc | 60 ++++++++++--------- > .../bootstrap/en/modules/opac-account.tt | 29 ++++++++- > 2 files changed, 58 insertions(+), 31 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >index cf25163aa2..cdc23e46da 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >@@ -132,38 +132,40 @@ > </tr> > </tfoot> > </table> >- [% IF ENABLE_OPAC_PAYMENTS && DISPLAY_PAYMENT_BLOCK %] >- <fieldset class="pay-online hidden"> >- <legend>Pay selected fines and charges</legend> >- <span class="help-block"><h3>Payment method</h3></span> >- >- [% IF Koha.Preference('EnablePayPalOpacPayments') %] >- <div class="control-group"> >- <label class="radio"> >- <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked"> >- <!-- PayPal Logo --><a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" class="paypal"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/AM_SbyPP_mc_vs_dc_ae.jpg" border="0" alt="PayPal Acceptance Mark"></a><!-- PayPal Logo --> >- </label> >- </div> >- [% END %] >- >- [% FOREACH p IN plugins %] >- <div class="control-group"> >- <label class="radio"> >- <input type="radio" name="payment_method" id="payment_method-[% p.class | html %]" value="[% p.class | html %]" checked="checked"> >- [% p.get_metadata.name | html %] >- </label> >- </div> >- [% END %] >+[% END %] >+ >+[% IF ENABLE_OPAC_PAYMENTS && DISPLAY_PAYMENT_BLOCK %] >+ <fieldset class="pay-online hidden"> >+ <legend>Pay selected fines and charges</legend> >+ <span class="help-block"><h3>Payment method</h3></span> >+ >+ [% IF Koha.Preference('EnablePayPalOpacPayments') %] >+ <div class="control-group"> >+ <label class="radio"> >+ <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked"> >+ <!-- PayPal Logo --><a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" class="paypal"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/AM_SbyPP_mc_vs_dc_ae.jpg" border="0" alt="PayPal Acceptance Mark"></a><!-- PayPal Logo --> >+ </label> >+ </div> >+ [% END %] > >+ [% FOREACH p IN plugins %] > <div class="control-group"> >- <input type="hidden" id="payment-amount" name="payment_amount" value="0" /> >- <button id="submit-pay" type="submit" class="btn" disabled="disabled">Make payment</button> >- <span id="amount-to-pay-label"> >- Amount to pay: <span id="amount-to-pay">0.00</span> >- </span> >+ <label class="radio"> >+ <input type="radio" data-threshold="[% p.opac_online_payment_threshold | html %]" name="payment_method" id="payment_method-[% p.class | html %]" value="[% p.class | html %]" checked="checked"> >+ [% p.get_metadata.name | html %] >+ </label> >+ <small class="help-block text-muted"></small> > </div> >- </fieldset> >- [% END %] >+ [% END %] >+ >+ <div class="control-group"> >+ <input type="hidden" id="payment-amount" name="payment_amount" value="0" /> >+ <button id="submit-pay" type="submit" class="btn" disabled="disabled">Make payment</button> >+ <span id="amount-to-pay-label"> >+ Amount to pay: <span id="amount-to-pay">0.00</span> >+ </span> >+ </div> >+ </fieldset> > [% END %] > </form> > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >index 70da8a22fe..baeced48c6 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >@@ -81,6 +81,8 @@ > <script> > $( document ).ready(function() { > >+ var MSG_MIN_THRESHOLD = _("Minimum amount needed by this service is %s"); >+ > $("#finestable").dataTable($.extend(true, {}, dataTablesDefaults, { > "columnDefs": [ > { "type": "title-string", "targets" : [ "title-string" ] } >@@ -97,9 +99,9 @@ $( document ).ready(function() { > > $("#amount-to-pay-label").hide(); > >- $(".checkbox-pay").change( function() { >+ $(".checkbox-pay, input[name='payment_method']").change( function() { > // Disable the pay button if no fees are selected >- $("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length ); >+ //$("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length ); > > // Calculate the total amount to be paid based on selected fees > var total = 0; >@@ -110,12 +112,35 @@ $( document ).ready(function() { > } > }); > >+ var p = Promise.resolve(); > if ( total ) { >+ p = Promise.all( >+ $('input[name="payment_method"]').map(function() { >+ var self = this; >+ return new Promise(function(resolve, reject) { >+ var threshold = $(self).data('threshold'); >+ var help = $(self).parent().siblings('.help-block'); >+ if(threshold == '' || threshold <= total) { >+ $(self).prop('disabled', false); >+ help.addClass('hide'); >+ } else { >+ $(self).prop('disabled', true); >+ help.html(MSG_MIN_THRESHOLD.format(parseInt(threshold,10).toFixed(2))).removeClass('hide'); >+ } >+ resolve(); >+ }) >+ }).toArray() >+ ); >+ > $("#amount-to-pay").html( total.toFixed(2) ); > $("#amount-to-pay-label").show(); > } else { >+ $('input[name="payment_method"]').prop('disabled', false).parent().siblings('.help-block').addClass('hide'); > $("#amount-to-pay-label").hide(); > } >+ p.then(function() { >+ $("#submit-pay").prop("disabled", ! $(".checkbox-pay:checked").length || ! $('input[name="payment_method"]:checked:not(:disabled)').length); >+ }) > }); > }); > </script> >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23213
:
91122
|
93140
|
93144