Stripe payments 如何使用已保存的信用卡支付?
我正在使用Stripe payments 如何使用已保存的信用卡支付?,stripe-payments,Stripe Payments,我正在使用Intent API(仅限货币、金额)和confirmCardPayment和Stripe呈现HTML输入进行签出 现在我想实现已保存的信用卡,我可以保存它,但我不知道如何使用它传递到确认卡支付 我目前工作的confirmCardPayment代码如下 Stripe.confirmCardPayment(intent.client\u secret{ 付款方式:{ /** *我在这里使用Vue *如果我使用的是已保存的卡,我应该在这里传递什么? **/ 卡片:此。$refs.strip
Intent API(仅限货币、金额)
和confirmCardPayment
和Stripe呈现HTML输入进行签出
现在我想实现已保存的信用卡,我可以保存它,但我不知道如何使用它传递到确认卡支付
我目前工作的confirmCardPayment
代码如下
Stripe.confirmCardPayment(intent.client\u secret{
付款方式:{
/**
*我在这里使用Vue
*如果我使用的是已保存的卡,我应该在这里传递什么?
**/
卡片:此。$refs.stripeCardRef.cardnumberrelation,
},
设置未来用法:“关闭会话”,
});
如果我使用的是已保存的卡,我应该传递什么到confirmCardPayment,以及Intent API(我现在使用的是货币、金额)
因此,我可以使用stripe.paymentMethods.list
获取客户保存的所有信用卡,并将其返回前端,如下所示:
stripe.confirmCardPayment(
intent.client_secret,
{
payment_method: intent.last_payment_error.payment_method.id
}
).then(function(result) {
if (result.error) {
// Show error to your customer
console.log(result.error.message);
} else {
if (result.paymentIntent.status === 'succeeded') {
// The payment is complete!
}
}
});
//服务器
导出异步函数listPaymentMethods(userId:string){
const customer=wait getOrCreateCustomer(userId);
return stripe.paymentMethods.list({
客户:customer.id,
输入:“卡片”,
});
}
然后,我的前端得到这样的响应
{
"object": "list",
"data": [
{
"id": "pm_1GuBTiICxYQTNr22LwKB6rfy",
"object": "payment_method",
"billing_details": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": null,
"name": null,
"phone": null
},
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 1,
"exp_year": 2023,
"fingerprint": "riI755UKjfafxa3C",
"funding": "credit",
"generated_from": null,
"last4": "4242",
"networks": {
"available": ["visa"],
"preferred": null
},
"three_d_secure_usage": {
"supported": true
},
"wallet": null
},
"created": 1592201250,
"customer": "cus_HPOXLjeqF24rBn",
"livemode": false,
"metadata": [],
"type": "card"
}
],
"has_more": false,
"url": "/v1/payment_methods"
}
如何使用此响应数据来确认CardPayment
?
我的intent API是否也需要更改?此流程包含在Stripe的文档中: 这样做的目的是,在确认PaymentIntent时,将现有PaymentMethod id
pm_12345
传递到客户端,如下所示:
stripe.confirmCardPayment(
intent.client_secret,
{
payment_method: intent.last_payment_error.payment_method.id
}
).then(function(result) {
if (result.error) {
// Show error to your customer
console.log(result.error.message);
} else {
if (result.paymentIntent.status === 'succeeded') {
// The payment is complete!
}
}
});
此流程包含在Stripe的文档中: 这样做的目的是,在确认PaymentIntent时,将现有PaymentMethod id
pm_12345
传递到客户端,如下所示:
stripe.confirmCardPayment(
intent.client_secret,
{
payment_method: intent.last_payment_error.payment_method.id
}
).then(function(result) {
if (result.error) {
// Show error to your customer
console.log(result.error.message);
} else {
if (result.paymentIntent.status === 'succeeded') {
// The payment is complete!
}
}
});
如果您已保存该卡以备将来使用:并且您正在确认从现有卡付款,则您将传递付款方式id。希望有帮助!如果您已保存该卡以备将来使用:并且您正在确认从现有卡付款,则您将传递付款方式id。希望有帮助!