我正在使用 ASP.NET、HTML、AngularJS 和 Stripe.NET 开发卡片处理 API。我对他们都很陌生。我按照 Stripe 网站上的文档将 Stripe 令牌发送到服务器(此处):https ://stripe.com/docs/stripe.js#card-validateCardNumber
有效!但是,我想使用 AngularJS 而不是 JQuery。我想将这部分 JQuery 代码从 JQuery 转换为 AngularJS:
Stripe.card.createToken({
number: $('.card-number').val(),
cvc: $('.card-cvc').val(),
exp_month: $('.card-expiry-month').val(),
exp_year: $('.card-expiry-year').val(),
address_zip: $('.address_zip').val()
}, stripeResponseHandler);
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
if (response.error) { // Problem!
// Show the errors on the form
$form.find('.payment-errors').text(response.error.message);
$form.find('button').prop('disabled', false); // Re-enable submission
} else { // Token was created!
// Get the token ID:
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));
// Submit the form:
$form.get(0).submit();
}
}
如果有人可以提供帮助,我将不胜感激。谢谢。:)