Skip to content
Snippets Groups Projects
Commit f47ad316 authored by Eran's avatar Eran
Browse files

Add stripe-payment-form class when building form, remove JS logic to add class

parent 59eb00b4
No related branches found
No related tags found
No related merge requests found
......@@ -43,18 +43,6 @@
Stripe.setPublishableKey($('#stripe-pub-key').val());
});
/*
* Identify the payment form.
* Don't reference by form#id since it changes between payment pages
* (Contribution / Event / etc).
*/
//Patch - remove direct child selector and account for dialog forms
$('#billing-payment-block').closest('form').addClass('stripe-payment-form');
$('#crm-container form').addClass('stripe-payment-form');
if ($('#crm-ajax-dialog-1 form').length) {
$('#crm-ajax-dialog-1 form').addClass('stripe-payment-form');
}
// Intercept form submission.
$("form.stripe-payment-form").submit(function (event) {
var $form = $(this);
......
......@@ -108,18 +108,18 @@ function stripe_civicrm_buildForm($formName, &$form) {
&& $form->_paymentProcessor['payment_processor_type'] == 'Stripe'
) {
if (!stristr($formName, '_Confirm') && !stristr($formName, '_ThankYou')) {
//if (empty($_GET['type'])) {
if (!isset($form->_elementIndex['stripe_token'])) {
$form->_attributes['class'] .= " stripe-payment-form";
$form->addElement('hidden', 'stripe_token', NULL, array('id' => 'stripe-token'));
stripe_add_stripe_js($form);
}
//}
}
}
// For the 'Record Contribution' backend page.
if (($formName == 'CRM_Contribute_Form_Contribution' || $formName == 'CRM_Event_Form_Participant' || $formName == 'CRM_Member_Form_Membership' && !empty($form->_processors)) || stristr($formName, '_Main')) {
if (!isset($form->_elementIndex['stripe_token'])) {
$form->_attributes['class'] .= " stripe-payment-form";
$form->addElement('hidden', 'stripe_token', NULL, array('id' => 'stripe-token'));
stripe_add_stripe_js($form);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment