首页 > 解决方案 > Paypal 智能按钮元数据 - Webhook

问题描述

我正在使用 Paypal Javascript SDK 来呈现智能按钮并捕获和授权所有客户端。除了偶尔的客户不在我们这边等待处理完成之外,一切都运行良好。

我已经设置了 webhook 并订阅了所有事件,但无法/或不确定如何定义和接收我的任何自定义数据 ID 等。

我尝试了几种不同的配置来将我的数据从创建订单传递给订单 - 主要遵循本指南https://developer.paypal.com/docs/commerce-platform/v1/reference/orders-integration-guide/#create -命令

它将自定义数据添加到 purchase_units 作为自定义以及带有supplementary_data 和 postback_data 的元数据json对象

paypal.Buttons({
     createOrder: function(data, actions) {
         return actions.order.create({
             intent: 'CAPTURE',
             purchase_units : [{
                 items : ....,
                 description : ...,
                 amount : ...,
                 custom : 'purchase_units_data'
             }],
             metadata : {
                 supplementary_data : [{
                     data : 'supplementary_data'
                 }],
                 postback_data : [{
                     data : 'postback_data'
                 }]
             }
         });
     },
     onApprove: function(data, actions) {
         return actions.order.capture().then(function(details) {
             ....
         });
     }
 }).render('#paypal-button-container');

希望找到一种方法将一些自定义数据传递给 webhook 有效负载。

标签: paypalmetadatapaypal-webhooks

解决方案


答案似乎是我查看了错误版本的 API。 https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request

虽然我无法创建格式良好的元数据对象,但我可以使用reference_id 和custom_id 将数据添加到purchase_units 对象。

我只需要有点创意。


推荐阅读