如何向用户引用paypal webhook?
我正试图找出将webhook与webapp用户关联的最佳方法。 在paypal交易中,我从paypal收到webhook如何向用户引用paypal webhook?,paypal,webhooks,Paypal,Webhooks,我正试图找出将webhook与webapp用户关联的最佳方法。 在paypal交易中,我从paypal收到webhook 但是它没有我可以使用的可靠参考资料 与应用程序中的用户关联 我的解决办法是: 在onApprove函数上,使用javascript代码提交带有subscriptionID的表单 隐藏在输入上并将其发送到服务器 在服务器上收到subscriptionID后,使用进行事务的用户的subscriptionID字段创建webhook数据库条目 当我从paypal收到webhook时
但是它没有我可以使用的可靠参考资料
与应用程序中的用户关联
我的解决办法是:
周围的人都有更好的选择吗?
我在想是否有办法在paypal webhook中插入webapp的用户ID。
会更干净。
我还没找到什么东西 以下是paypal webhook客户端呼叫:
<script>
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: '************************'
});
},
onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
}).render('#paypal-button-container-******************'); // Renders the PayPal button
</script>
<script>
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: '************************',
custom_id: 'appUserID'
});
},
onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
}).render('#paypal-button-container-******************'); // Renders the PayPal button
</script>
贝宝,按钮({
风格:{
形状:'药丸',
颜色:“金色”,
布局:“垂直”,
标签:“订阅”
},
createSubscription:函数(数据、操作){
return actions.subscription.create({
/*创建订阅*/
计划编号:“******************************”
});
},
onApprove:功能(数据、操作){
警报(data.subscriptionID);//您可以在此处为订阅服务器添加可选的成功消息
}
}).render(“#paypal按钮容器-*****************”);//渲染PayPal按钮
谢谢创建订阅时,请传递唯一的
自定义id
谢谢Preston。这无疑是最好的选择。我遇到了麻烦,因为我添加了一个随机名称的新字段来关联应用程序的用户ID。事实证明,您确实需要使用custom\u id
键才能在webhook调用中接收它
最终解决方案如下:
<script>
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: '************************'
});
},
onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
}).render('#paypal-button-container-******************'); // Renders the PayPal button
</script>
<script>
paypal.Buttons({
style: {
shape: 'pill',
color: 'gold',
layout: 'vertical',
label: 'subscribe'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
/* Creates the subscription */
plan_id: '************************',
custom_id: 'appUserID'
});
},
onApprove: function(data, actions) {
alert(data.subscriptionID); // You can add optional success message for the subscriber here
}
}).render('#paypal-button-container-******************'); // Renders the PayPal button
</script>
贝宝,按钮({
风格:{
形状:'药丸',
颜色:“金色”,
布局:“垂直”,
标签:“订阅”
},
createSubscription:函数(数据、操作){
return actions.subscription.create({
/*创建订阅*/
计划编号:“****************************”,
自定义用户id:“appUserID”
});
},
onApprove:功能(数据、操作){
警报(data.subscriptionID);//您可以在此处为订阅服务器添加可选的成功消息
}
}).render(“#paypal按钮容器-*****************”);//渲染PayPal按钮
然后,custom\u id
字段将在所有webhook调用中可用。太好了