Я пытаюсь осуществлять платежи с помощью API PaymentIntent.Моя проблема в том, что я не могу найти, где / как передать данные карты (номер, exp_year, exp_month, cvc) для PaymentIntent.
Вот мой код 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);
});
}