PayPal订阅按钮并存储到DB流
我正在尝试以节点中的PayPal订阅流量为单位,现在所有的所有SDK似乎都被弃用了,我正在努力寻找实现订阅按钮的当前示例,然后验证订阅并在本地更新用户的状态DB。
我认为2022年的预期流量是实现标准按钮,并使用网络钩聆听该事件,此时您会验证有效负载,并更新本地DB以反映新的订阅状态。
我想这意味着在按钮的Onapprove客户端方法中,我们可以对本地数据库进行某种民意调查,以检查订阅状态是否已更改?
I'm attempting a Paypal subscription flow in Node, bug all of the various SDKs seem to be deprecated now, and I'm struggling to find a current example of implementing a subscription button and then validating the subscription and updating the user's status in local db.
I think the expected flow in 2022 is to implement a standard button and use a webhook to listen out for the event, at which point you verify the payload, and update a local DB to reflect the new subscription status.
I guess this means that in the OnApprove clientside method of the button, we could run some sort of polling against the local DB to check that the subscription status has changed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Onapprove回调已经接收到表明订阅已批准的数据。这足以满足客户端的结果(不适用于数据库操作,因为它是客户端)。
要将结果存储在数据库中,请收听webhook付款。sale.com。此Webhook将触发首次付款以及订阅中的每笔付款。这是您唯一需要关注的Webhook,所有订阅逻辑都可以完全由付款驱动。
为了帮助对帐,在创建订阅时添加
custom_id
参数。其值将在订阅的Webhooks事件中返回。The onApprove callback already receives data indicating the subscription has been approved. This is sufficient for client-side presentment of the result (not to be used for database operations, as it is client-side).
For storing the result in a database, listen for the webhook PAYMENT.SALE.COMPLETED. This webhook will trigger for the first payment, as well as every future payment on the subscription. It is the only webhook you need to be concerned about, all subscription logic can be driven solely by PAYMENT.SALE.COMPLETED.
To aid in reconciliation, add a
custom_id
parameter when creating the subscription. Its value will be returned in webhooks events for the subscription.