Uncaught ReferenceError: stripeResponseHandler is not defined

javascript, jquery, stripe-payments

Solution

var 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.com/docs/tutorials/forms

Problem

I am trying to integrate Stripe into a credit card form. The js and html can be viewed at http://pastie.org/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?

Original source