我遇到Stripe 502(错误网关)错误。付款成功为卡充值并显示在Stripe仪表板中,但未在前端显示成功,而是出现502错误。
我想在下面添加一些内容以使前端显示付款成功吗?在这里使用文档: https://stripe.com/docs/stripe-js/elements/payment-request-button
longest
服务器端代码
// Send the token to your server to charge it!
fetch('/apple-pay', {
method: 'POST',
body: JSON.stringify({token: ev.token.id}),
headers: {'content-type': 'application/json'},
})
.then(function(response) {
console.log(response)
if (response.ok) {
// Report to the browser that the payment was successful, prompting
// it to close the browser payment interface.
ev.complete('success');
} else {
// Report to the browser that the payment failed, prompting it to
// re-show the payment interface, or show an error message and close
// the payment interface.
ev.complete('fail');
}
});
});
答案 0 :(得分:1)
正如评论中所讨论的,问题在于请求服务器端不返回任何状态代码,因此客户端代码不知道它成功!