我试图将 stripe 支付网关提供的信用卡 token 传递给函数 stripe.handleCardPayment(clientSecret[, data])。 在文档中[https://stripe.com/docs/stripe-js/reference]它说它应该像卡[token]一样集成,并且 token 将自动转换为PaymentMethod。 但是我如何将这部分代码实现到我的代码中呢? 我尝试了这样的方法,但没有成功...
stripe.handleCardPayment(
clientSecret,
{
payment_method_data: {
card[token]: the_card_token
}
}
).then(function(result) {
console.log(result);
});
在尝试时我收到此错误:
A Card token may not be passed in as a PaymentMethod. Instead, use payment_method_data with type=card and card[token]=tok_xxxxxx
最佳答案
不要使用 card[token]: the_card_token
,而是将其传递为 card: { token: 'tok_visa' }
这样的东西应该有效
stripe.handleCardPayment(client_secret, {
payment_method_data: {
card: {
token: 'tok_visa'
},
}
}).then(function(result) {
console.log(result);
});
关于javascript - 如何在 stripe.handleCardPayment(clientSecret[, data]) 上使用卡 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57579576/