com.drastikbydesign.stripe
com.drastikbydesign.stripe copied to clipboard
Wrong form selector in civicrm_stripe.js
The submit event handler relies on the fact that the form has the class stripe-payment-form
. This CSS class is set server-side in most cases, but not all, and I suppose this is why there is this piece of code in the javascript:
if (!($('.stripe-payment-form').length)) {
$('#crm-container > form').addClass('stripe-payment-form');
}
The problem is that this selector is not correct, at least in my install (Civi-4.7 + drupal). In my case, the structure is:
#crm-container
|
#crm-main-content-wrapper
|
form
Because of that, if the CSS class could not be set server-side (not sure why TBH), I get the dreaded "Stripe.js token was not passed". The use case is:
- Contribution page with several payment processors enabled
- Attempt a donation NOT with Stripe, but get an error (e.g. forget to fill a field)
- Second attempt with Stripe
Possible solutions:
- Make sure the CSS class is always set server side
- Change the jQuery selector. What about
#crm-container form
?