最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught ReferenceError: stripeResponseHandler is not defined - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 7
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./docs/tutorials/forms

发布评论

评论列表(0)

  1. 暂无评论