Skip to content
Snippets Groups Projects
Commit 1137a756 authored by mattwire's avatar mattwire Committed by mattwire
Browse files

Always load civicrm_stripe.js if we have a payment processor on the page. This...

Always load civicrm_stripe.js if we have a payment processor on the page. This makes sure we always generate a token if the selected processor was stripe
parent f7ba23b3
Branches
Tags
No related merge requests found
......@@ -41,7 +41,14 @@
// Prepare the form.
$(document).ready(function() {
Stripe.setPublishableKey($('#stripe-pub-key').val());
loadStripeBillingBlock();
});
CRM.$('input[name="payment_processor_id"]').change(function() {
loadStripeBillingBlock();
});
function loadStripeBillingBlock() {
// Check for form marked as a stripe-payment-form by the server.
if (!($('form.stripe-payment-form').length)) {
// If there isn't one look for it.
......@@ -49,8 +56,11 @@
isWebform = true;
$('form.webform-client-form').addClass('stripe-payment-form');
}
else if ($('#crm-container form').length) {
$('#crm-container form').addClass('stripe-payment-form');
}
else {
$('#crm-container > form').addClass('stripe-payment-form');
return;
}
}
......@@ -223,7 +233,7 @@
debugging('debug: ywkvh (Getting Stripe token)');
return false;
});
});
}
}(cj, CRM));
function debugging (errorCode) {
......
......@@ -195,10 +195,8 @@ function stripe_civicrm_managed(&$entities) {
*/
function stripe_civicrm_alterContent( &$content, $context, $tplName, &$object ) {
if($context == 'form' && !empty($object->_paymentProcessor['class_name'])) {
if($object->_paymentProcessor['class_name'] == 'Payment_Stripe') {
$stripeJSURL = CRM_Core_Resources::singleton()->getUrl('com.drastikbydesign.stripe', 'js/civicrm_stripe.js');
$content .= "<script src='{$stripeJSURL}'></script>";
}
$stripeJSURL = CRM_Core_Resources::singleton()->getUrl('com.drastikbydesign.stripe', 'js/civicrm_stripe.js');
$content .= "<script src='{$stripeJSURL}'></script>";
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment