2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
11 <script type="text/javascript">
13 * Show or hide payment options.
16 * Should the block be hidden.
18 function showHidePayment(isHide) {
19 var payment_options = cj(".payment_options-group");
20 var payment_processor = cj("div.payment_processor-section");
21 var payment_information = cj("div#payment_information");
22 // I've added a hide for billing block. But, actually the issue
23 // might be that the unselecting of the processor should cause it
24 // to be hidden (or removed) in which case it can go from this function.
25 var billing_block = cj("div#billing-payment-block");
27 payment_options.hide();
28 payment_processor.hide();
29 payment_information.hide();
31 // also unset selected payment methods
32 cj('input[name="payment_processor_id"]').removeProp('checked');
35 payment_options.show();
36 payment_processor.show();
37 payment_information.show();
39 // also set selected payment methods
40 cj('input[name="payment_processor_id"][checked=checked]').prop('checked', true);
45 * Hides or shows billing and payment options block depending on whether payment is required.
47 * In general incomplete orders or $0 orders do not require a payment block.
49 function skipPaymentMethod() {
51 var isMultiple = {/literal}{$event.is_multiple_registrations|@json_encode}{literal};
52 var alwaysShowFlag = (isMultiple && cj("#additional_participants").val());
53 var alwaysHideFlag = (cj("#bypass_payment").val() == 1);
54 var total_amount_tmp = cj('#pricevalue').data('raw-total');
55 // Hide billing questions if this is free
56 if (!alwaysShowFlag && total_amount_tmp == 0){
65 showHidePayment(isHide);
70 function buildPaymentBlock(type) {
71 var $form = $('#billing-payment-block').closest('form');
73 {if $contributionPageID}
74 {capture assign='contributionPageID'}id={$contributionPageID}&{/capture}
76 {capture assign='pageID'}{/capture}
79 {capture assign='preProfileID'}pre_profile_id={$custom_pre_id}&{/capture}
81 {capture assign='preProfileID'}{/capture}
84 {capture assign='urlPathVar'}{$urlPathVar}&{/capture}
86 {capture assign='urlPathVar'}{/capture}
88 {if $billing_profile_id}
89 {capture assign='profilePathVar'}billing_profile_id={$billing_profile_id}&{/capture}
91 {capture assign='profilePathVar'}{/capture}
94 {capture assign='isBackOfficePathVar'}&is_back_office={$isBackOffice}&{/capture}
96 var payment_instrument_id = $('#payment_instrument_id').val();
98 var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="formName=`$form.formName`¤cy=`$currency`&`$urlPathVar``$isBackOfficePathVar``$profilePathVar``$contributionPageID``$preProfileID`processor_id="}" + type;
100 if (typeof(CRM.vars) != "undefined") {
101 if (typeof(CRM.vars.coreForm) != "undefined") {
102 if (typeof(CRM.vars.coreForm.contact_id) != "undefined") {
103 dataUrl = dataUrl + "&cid=" + CRM.vars.coreForm.contact_id;
106 if (typeof(CRM.vars.coreForm.checksum) != "undefined" ) {
107 dataUrl = dataUrl + "&cs=" + CRM.vars.coreForm.checksum;
111 dataUrl = dataUrl + "&payment_instrument_id=" + payment_instrument_id;
113 // Processors like pp-express will hide the form submit buttons, so re-show them when switching
114 $('.crm-submit-buttons', $form).show().find('input').prop('disabled', true);
115 CRM.loadPage(dataUrl, {target: '#billing-payment-block'});
118 $('[name=payment_processor_id]').on('change.paymentBlock', function() {
119 buildPaymentBlock($(this).val());
122 $('#payment_instrument_id').on('change.paymentBlock', function() {
123 buildPaymentBlock(0);
126 $('#billing-payment-block').on('crmLoad', function() {
127 $('.crm-submit-buttons input').prop('disabled', false);