使用条带支付网关开发eCommerce,每次都会遇到这个错误。
正如在here中提到的,我必须提供客户的name、billing address、description和shipping address,否则,付款将失败,这是印度政府规定的法律。
这是我在条带API日志中得到的错误
invalid_request_error - description
As per Indian regulations, export transactions require a description. More info here: https://stripe.com/docs/india-exports这是我将数据发送到后端的代码:
const handleSubmit = async (event) => {
// do all the fancy stripe stuff...
event.preventDefault();
setProcessing(true);
const payload = await stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: elements.getElement(CardElement),
}
}}
).then(({ error, paymentIntent }) => {
// paymentIntent = payment confirmation
db
.collection('users')
.doc(user?.uid)
.collection('orders')
.doc(paymentIntent.uid)
.set({
basket: basket,
amount: paymentIntent.amount,
created: paymentIntent.created,
})
setSucceeded(true);
setError(null)
setProcessing(false)
dispatch({
type: 'EMPTY_BASKET'
})
history.replace('/orders')
},
)
}如何将其设置为发送name、billing address、description和shipping address来修复错误?
发布于 2021-09-11 01:46:27
在印度,您必须收集相关信息才能进行交易出口,条带文档如下:https://stripe.com/docs/india-exports
这需要大量额外的细节,如清晰的费用描述,但在PaymentIntent确认期间还需要发货和计费细节。
我写了一个类似的答案here,但在较高级别上,您将自己收集地址/相关信息,并将相关信息传递给confirmCardPayment()
Stripe没有直接收集账单详细信息的元素,但它是您可以在表单中构建的东西。假设您收集了相关字段,您将在调用confirmCardPayment时通过传递billing_details参数将信息作为文档记录的here进行传递:
const payload = await stripe
.confirmCardPayment(clientSecret, {
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
name: 'Jenny Rosen',
address: {
line1: '1 Main street',
city: 'San Francisco',
postal_code: '90210',
state: 'CA',
country: 'US',
},
},
},
shipping: {
name: 'Jenny Shipping',
address: {
line1: '1 Main street',
city: 'San Francisco',
postal_code: '90210',
state: 'CA',
country: 'US',
},
},
});https://stackoverflow.com/questions/69132950
复制相似问题