我正在尝试使用PaymentIntent API在条带上实现支付。 我的问题是我找不到在哪里/如何为PaymentIntent提供卡详细信息(编号,exp_year,exp_month,cvc)。
这是我的代码https://github.com/rever96/example-stripe-paymentIntent,用于创建PaymentIntent,然后进行确认。确认将状态更改为succeded
。因此,我想到:“哇,它在起作用!”但是卡的详细信息呢?
那是服务器代码感兴趣的:
const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
app.post("/createPayment", (req, res) => {
console.log('i\'m trying to create a paymentIntent');
(async () => {
paymentIntent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'eur',
payment_method_types: ['card'],
}).then(paymentIntentResponse => {
console.log("paymentIntent created");
res.send(paymentIntentResponse)
});
})();
});
app.post("/confirmPayment", (req, res) => {
console.log(req.body);
(async () => {
paymentIntent = await stripe.paymentIntents.confirm(req.body.id, { payment_method: 'pm_card_visa' })
.then(paymentIntentResponse => {
console.log("paymentIntent confirmed");
res.send(paymentIntentResponse)
});
})();
});
这是客户代码感兴趣的:
constructor(
private http: HttpClient) {
}
ngOnInit() {
this.http.post('http://localhost:8080/createPayment', {}).subscribe(res => {
console.log('back from server!');
console.log(res);
this.paymentIntentID = res['id'];
this.paymentIntentClientSecret = res['client_secret'];
});
}
submitPaymentData() {
this.collectCardDetails();
console.log('confirm payment');
this.http.post('http://localhost:8080/confirmPayment', { id: this.paymentIntentID }).subscribe(res => {
console.log('back from server!');
console.log(res);
});
}
答案 0 :(得分:1)
PaymentIntent的流程通常如下:
handleCardPayment
处理付款您已经完成了步骤1,您需要完成其余的步骤: https://stripe.com/docs/payments/payment-intents/quickstart#passing-to-client