我目前正在将Stripe支付网关集成到Meteor应用程序中。应用程序需要保存客户卡以供以后使用。我能够创建客户对象,然后支付意图。我第一次创造了电荷。现在我想重新加载保存的卡,我已经将客户Id传递给paymentIntent,但得到一个错误。下面是我的客户端和服务器代码。
客户端
// code to retrieve customerObj
customerId = getCustomerDetails() //
// Generate Paymentintent with this customer id.
let paymentIntent = generatePaymentIntent(cusomterId) ; // calls server functions and generates payment intent
try {
const someAsync = await new Promise((resolve, reject) =>
Meteor.call(
"v1/handleGetPaymentIntent",
{ customerId },
(err, res) => {
if (err) return reject(err);
resolve(res);
}
)
);
clientSecret = someAsync.result.client_secret;
const rs = await stripe.confirmCardPayment(clientSecret);
// OPTION 1: I have tried this without payment_method option(Since I am trying to load a saved card) but I am getting an error.
// OPTION 2 : I have even tried the below
const rs = await stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
billing_details: {
name: "Jenny Rosen",
},
},
});
if (rs.error) {
// Show error to your customer (e.g., insufficient funds)
console.log("final message from ", rs.error.message);
} else {
// The payment has been processed!
if (rs.paymentIntent.status === "succeeded") {
console.log("success");
}
}
//
误差
**OPTION1 ERROR:** a final message from A payment method of type card was expected to be present, but this PaymentIntent does not have a payment method and none was provided. Try again providing either the payment_method or payment_method_data parameters.
**OPTION2 ERROR**
IntegrationError: Invalid value for confirmCardPayment: payment_method.card should be object or element. You specified: null.
at new o (https://js.stripe.com/v3:1:2923)
at y (https://js.stripe.com/v3:1:25332)
at https://js.stripe.com/v3:1:146495
at Y (https://js.stripe.com/v3:1:29214)
at https://js.stripe.com/v3:1:149075
at Y (https://js.stripe.com/v3:1:29214)
at Z (https://js.stripe.com/v3:1:30560)
at ui (https://js.stripe.com/v3:1:153621)
at https://js.stripe.com/v3:1:167556
at https://js.stripe.com/v3:1:15358
不确定如何继续。帮助需要。
客户端秘密来自支付意图,您必须首先在服务器端使用客户ID及其附加的支付方法ID创建支付意图。
https://stripe.com/docs/payments/save-and-reuse web-create-payment-intent-off-session