我正在使用Stripe和Laravel 5.1,除了当我输入一个应该被拒绝的测试卡号码时我没有任何错误; 也就是说,即使它应该存在,也不会存在共振.
我收到一个令牌,好像一切都很顺利(例如:tok_16Y3wFAMxhd2ngVpHnky8VWX)
无论我使用什么测试卡,stripeResponseHandler()函数都不会在响应中返回错误.这是有问题的代码:
var PublishableKey = 'pk_test_Ed0bCarBWsgCXGBtjEnFeBVJ'; // Replace with your API publishable key
Stripe.setPublishableKey(PublishableKey);
/* Create token */
var expiry = $form.find('[name=cardExpiry]').payment('cardExpiryVal');
var ccData = {
number: $form.find('[name=cardNumber]').val().replace(/\s/g, ''),
cvc: $form.find('[name=cardCVC]').val(),
exp_month: expiry.month,
exp_year: expiry.year
};
Stripe.card.createToken(ccData, function stripeResponseHandler(status, response) {
console.log(status);
if (response.error) {
/* Visual feedback */
$form.find('[type=submit]').html('Please Try Again');
/* Show Stripe errors on the form */
$form.find('.payment-errors').text(response.error.message);
$form.find('.payment-errors').closest('.row').show();
} else {
/* Visual feedback */
$form.find('[type=submit]').html('Processing <i class="fa fa-spinner fa-pulse"></i>');
/* Hide Stripe …Run Code Online (Sandbox Code Playgroud)