Update for mark paid using square
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Jul 2019 13:32:32 +0000 (09:32 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Jul 2019 13:32:32 +0000 (09:32 -0400)
Destroy the Square payment object and remove the onclick event for the
form.

views/admin/billing/makePayment.html
views/common/billing/paymentForm.html

index 1be2aeb..05ec2ee 100644 (file)
@@ -55,7 +55,7 @@
 {* Only if payments types are setup *}
 {include file='common/billing/paymentForm.html'}
 
-                <input class="button button-primary" type="submit" value="Make Payment" {if $billing_settings.proc_methods == 4} onclick="onGetCardNonce(event)"{/if}>
+                <input id="billing-payment-button" class="button button-primary" type="submit" value="Make Payment" {if $billing_settings.proc_methods == 4} onclick="onGetCardNonce(event)"{/if}>
 
             {else}
             You don't have any unpaid invoices!
index a330b08..9b85df5 100644 (file)
@@ -214,24 +214,33 @@ jQuery(document).ready(function($){
 
     $('.payment_option').change(function(){
         var payment_option = $('.payment_option:checked').val();
-        console.log( 'payment_option: ', payment_option );
+        // console.log( 'payment_option: ', payment_option );
         if ( payment_option == 'pay_by_check' ) {
             {if $billing_settings.proc_methods == 4}
                 $('.sq-payment-form').hide();
+                paymentForm.destroy();
             {else}
                 $('.glm-billing-credit').hide();
                 $('.ccard').prop('disabled', true);
+                $('#billing-payment-button').prop( 'onclick', null );
             {/if}
         } else if ( payment_option == 'mark_paid' ) {
             {if $billing_settings.proc_methods == 4}
                 $('.sq-payment-form').hide();
+                paymentForm.destroy();
+                $('#billing-payment-button').prop( 'onclick', null );
             {else}
                 $('.glm-billing-credit').hide();
                 $('.ccard').prop('disabled', true);
             {/if}
         } else {
             {if $billing_settings.proc_methods == 4}
-                $('.sq-payment-form').show();
+                if ( confirm( 'This will reload the page' ) ) {
+                    $('.sq-payment-form').show();
+                    window.location.reload();
+                } else {
+                    $('.payment_option[value=mark_paid]').prop( 'checked', true );
+                }
             {else}
                 $('.glm-billing-credit').show();
                 $('.ccard').prop('disabled', false);