我使用 Advanced In-Context Checkout integration .
我使用 AJAX 并利用这些功能,正如他们的文档所解释的那样:
paypal.checkout.setup()
paypal.checkout.initXO()
paypal.checkout.startFlow()
paypal.checkout.closeFlow()
而且我在 Execute the payment step 之后经常遇到这个恼人的错误.他们懒得在任何地方解释它是他们的 API 文档。它只是丢失了。
new Error("No response handler found for post message response "+t.name+" in "+window.location.href);
错误是什么意思?期望什么样的响应处理程序用于发布消息响应?如何提供?
我的客户端代码很简单,如下所示:
onCheckoutBtnClick(ev) {
paypal.checkout.initXO();
$.post('/checkout', {
user: JSON.stringify(this.props.user),
data: JSON.stringify(this.props.WCs),
})
.done(res => {
paypal.checkout.startFlow(res.approval_url);
})
.fail(err => {
paypal.checkout.closeFlow();
});
},
服务器端如下:
router.post('/checkout', (req, res, next) => {
var payment_json = {
// huge config to create a payment
// the pivotal value is "return_url"
redirect_urls: {
"return_url": "http://example.com:3000/complete_payment",
"cancel_url": "http://example.com:3000/cancel_payment"
},
}
});
和return_url
代码
router.get('/complete_payment', (req, res, next) => {
paypal.payment.execute(req.query.paymentId, execute_payment_json, function (err, payment) {
// After this step the error in thrown on the client
res.redirect('http://example.com:3000/show_complete_page_to_buyer');
})
})
最佳答案
这似乎只是一个沙盒问题。在 Sandbox 中一直看到这个错误,最近在生产模式中看到它。 我已向 Paypal 开发人员发送邮件,提示沙盒和生产环境之间的许多差异。
关于paypal-sandbox - 上下文结帐 : No response handler found for post message response error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39371310/