【发布时间】:2020-10-27 19:42:51
【问题描述】:
我在我的网站中集成了 PayPal 智能按钮,createOrder 和 Capture 在服务器端进行处理,当支付完成后,交易可以在企业沙盒账户上使用,webhook 事件是在 Webhooks 事件页面中注册。
webhookPOST url 在仪表板中订阅了所有事件,并在localhost 中对其进行测试,我使用webhookrelay。
问题是我只在事件来自 Webhook 模拟器而不是来自智能按钮的实际付款时才调用 webhook。
因此,我的服务器仅接收来自模拟器的 webhook 调用,并且不会从智能按钮支付中触发。
我处于沙盒模式,所有付款和智能按钮都处于沙盒模式。
这是我的智能按钮代码:
paypal
.Buttons({
style: {
shape: "rect",
color: "gold",
layout: "horizontal",
label: "paypal",
tagline: false,
height: 52,
},
createOrder: async function () {
const res = await fetch(
"https://www.example.it/payment/paypal/order/create/" + orderID,
{
method: "post",
headers: {
"content-type": "application/json",
},
credentials: "include",
}
);
const data = await res.json();
return data.id;
},
onApprove: async function (data) {
const res = await fetch(
"https://www.example.it/payment/paypal/" +
data.orderID +
"/capture/",
{
method: "post",
headers: {
"content-type": "application/json",
},
credentials: "include",
}
);
const details = await res.json();
if (localStorage.STBOrder) {
localStorage.removeItem("STBOrder");
}
$("#modalPayments").modal("hide");
$("#modalSuccess").modal("show");
},
onCancel: function (data) {},
})
.render("#paypal-button-container");
【问题讨论】:
标签: paypal paypal-sandbox webhooks