为什么我收不到错误信息?现在,当我点击提交按钮服务器重定向我到帖子并显示我独特的令牌,但它不是如何工作..
(function() {
var StripeBilling = {
init: function() {
this.form = $('#billing-form');
this.submitButton = this.form.find('input[type=submit]');
this.submitButtonValue = this.submitButton.val();
var stripeKey = $('meta[name="publishable-key"]').attr('content');
Stripe.setPublishableKey(stripeKey);
this.bindEvents();
},
bindEvents: function() {
this.form.on('submit', $.proxy(this.sendToken, this));
},
sendToken: function(event) {
this.submitButton.val('One Moment...').prop('disabled', true);
Stripe.card.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val()
}, stripeResponseHandler);
event.preventDefault();
},
stripeResponseHandler: function(status, response) {
if(response.error) {
this.form.find('.payment-errors').show().text(response.error.message);
return this.submitButton.prop('disabled', false).val(this.submitButtonValue);
}
else{
$('<input>', {
type: 'hidden',
name: 'stripeToken',
value: response.id
}).appendTo(this.form);
}
//this.form[0].submit();
}
};
StripeBilling.init();
})();
它正在创建一个令牌,但只有在右键输入数据时才能创建令牌!谢谢!