// Set title
if ($this->_mode) {
+ CRM_Financial_Form_Payment::addCreditCardJs();
$this->setPageTitle($this->_ppID ? ts('Credit Card Pledge Payment') : ts('Credit Card Contribution'));
}
else {
break;
}
}
- if (!$form->_snippet) {
- // Add JS to show icons for the accepted credit cards
- $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames();
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)
- // workaround for CRM-13634
- // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes)));
- ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
- }
+ CRM_Financial_Form_Payment::addCreditCardJs();
}
$form->assign('paymentProcessorID', $form->_paymentProcessorID);
}
//$payPalExpressId = ($values['payment_processor_type'] == 'PayPal_Express') ? $values['id'] : 0;
// $this->assign('payPalExpressId', $payPalExpressId);
- // Add JS to show icons for the accepted credit cards
+ self::addCreditCardJs();
+ $this->assign('paymentProcessorID', $this->_paymentProcessorID);
+ }
+
+ public function buildQuickForm() {
+ CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
+ }
+
+ /**
+ * Add JS to show icons for the accepted credit cards
+ */
+ public static function addCreditCardJs() {
$creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames();
CRM_Core_Resources::singleton()
->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)
// workaround for CRM-13634
// ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes)));
->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
-
- $this->assign('paymentProcessorID', $this->_paymentProcessorID);
- }
-
- public function buildQuickForm() {
- CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
}
}
civicrm_billingblock_creditcard_helper();
- $(function() {
- $('#billing-payment-block').on('crmFormLoad', civicrm_billingblock_creditcard_helper);
- });
})(CRM.$);
{literal}
<script type="text/javascript">
-function buildPaymentBlock(type) {
- {/literal}{if !$isBillingAddressRequiredForPayLater}{literal}
- if (type == 0) {
- if (cj("#billing-payment-block").length) {
- cj("#billing-payment-block").html('');
+ CRM.$(function($) {
+ function buildPaymentBlock(type) {
+ {/literal}{if !$isBillingAddressRequiredForPayLater}{literal}
+ if (type == 0) {
+ $("#billing-payment-block").html('');
+ return;
+ }
+ {/literal}{/if}
+
+ {if $contributionPageID}
+ {capture assign='contributionPageID'}id={$contributionPageID}&{/capture}
+ {else}
+ {capture assign='contributionPageID'}{/capture}
+ {/if}
+ {if $urlPathVar}
+ {capture assign='urlPathVar'}{$urlPathVar}&{/capture}
+ {else}
+ {capture assign='urlPathVar'}{/capture}
+ {/if}
+
+ var dataUrl = "{crmURL p='civicrm/payment/form' h=0 q="`$urlPathVar``$contributionPageID`processor_id="}" + type;
+
+ {literal}
+ CRM.loadPage(dataUrl, {target: '#billing-payment-block'});
}
- return;
- }
- {/literal}{/if}{literal}
-
- var dataUrl = {/literal}"{crmURL p='civicrm/payment/form' h=0 q='snippet=4&processor_id='}"{literal} + type;
-
- {/literal}
- {if $urlPathVar}
- dataUrl = dataUrl + '&' + '{$urlPathVar}'
- {/if}
-
- {if $contributionPageID}
- dataUrl = dataUrl + '&id=' + '{$contributionPageID}'
- {/if}
-
- {literal}
-
- var response = cj.ajax({
- url: dataUrl,
- async: false
- }).responseText;
-
- cj('#billing-payment-block').html(response).trigger('crmLoad').trigger('crmFormLoad');
-}
-
-CRM.$(function($) {
+
$('.crm-group.payment_options-group').show();
- // FIXME: This code is getting re-loaded and re-run every time, using .off() as a temporary fix
- $('[name=payment_processor_id]').off('.paymentBlock').on('change.paymentBlock', function() {
- buildPaymentBlock( $(this).val() );
+ $('[name=payment_processor_id]').on('change.paymentBlock', function() {
+ buildPaymentBlock($(this).val());
});
-});
+ });
</script>
{/literal}