我已在我的网站中集成了 PayPal 智能按钮createOrder
and Capture
在服务器端处理,付款完成后,交易即可在业务沙箱帐户上使用,并且webhook
事件在 Webhooks 事件页面中注册。
The webhook
POST
url 在仪表板中订阅所有事件并在中测试它localhost
i use 网络钩子中继 https://webhookrelay.com/.
问题是我得到了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");