Bugzilla – Attachment 91122 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.40 KB, created by
Agustín Moyano
on 2019-06-28 19:19:14 UTC
(
hide
)
Description:
Bug 23213: Enable minimum payment threshold check in OPAC
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2019-06-28 19:19:14 UTC
Size:
8.40 KB
patch
obsolete
>From 367a202c0fc2a8920ff90131067d2660f997ebd8 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 >--- > .../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 837452f9ab..3c48007fce 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 c6f6cc7efc..a5f9d29940 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.17.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