I am trying to integrate Stripe into a credit card form.
The js and html can be viewed at (for reference, jquery is included in the head of the document)
For some reason, I am getting the following error:
Uncaught ReferenceError: stripeResponseHandler is not defined
The error is triggered on line 11:
Stripe.createToken($form, stripeResponseHandler);
Based on this, it appears that the Stripe.js is not being loaded correctly? However, the line Stripe.setPublishableKey('something');
works fine.
What am I missing here?
I am trying to integrate Stripe into a credit card form.
The js and html can be viewed at http://pastie/private/f4flb1hktzdahl9snr4jma (for reference, jquery is included in the head of the document)
For some reason, I am getting the following error:
Uncaught ReferenceError: stripeResponseHandler is not defined
The error is triggered on line 11:
Stripe.createToken($form, stripeResponseHandler);
Based on this, it appears that the Stripe.js is not being loaded correctly? However, the line Stripe.setPublishableKey('something');
works fine.
What am I missing here?
Share Improve this question asked Mar 15, 2013 at 19:34 JonoBJonoB 5,90717 gold badges59 silver badges77 bronze badges 2-
What is the variable
stripeResponseHandler
? – Brad M Commented Mar 15, 2013 at 19:35 - The code is gone at pastie (as of 3Nov2022). This is why you should include a minimum example in your original question. – Sablefoste Commented Nov 4, 2022 at 1:35
1 Answer
Reset to default 7var stripeResponseHandler = function(status, response) {
var $form = $('#payment-form');
if (response.error) {
// Show the errors on the form
$form.find('.payment-errors').text(response.error.message);
$form.find('button').prop('disabled', false);
} else {
// token contains id, last4, and card type
var token = response.id;
// Insert the token into the form so it gets submitted to the server
$form.append($('<input type="hidden" name="stripeToken" />').val(token));
// and submit
$form.get(0).submit();
}
};
You are missing parts of the code, see here: https://stripe./docs/tutorials/forms