paypal - 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 有效负载。
解决方案
答案似乎是我查看了错误版本的 API。 https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit_request
虽然我无法创建格式良好的元数据对象,但我可以使用reference_id 和custom_id 将数据添加到purchase_units 对象。
我只需要有点创意。
推荐阅读
- python - 优化python代码以快速获得结果
- go - 当主线程循环时,goroutine中的fmt.Print *可能*不输出
- ajax - 如何使用 jquery 回调在烧瓶应用程序中显示加载圈
- angular - Angular 4 的查询生成器插件
- arrays - 如何处理 Angular 7 中数据不均匀的 JSON 对象?
- r - 如何创建应用于一组数据的函数的均值向量?
- javascript - ngif 不适用于 $scope 变量 angular
- java - 无法通过 Spark 1.6 从 Parquet Hive 表中读取数据
- android - 在 Android P 中:由于没有窗口焦点而丢弃事件:KeyEvent
- swift - 扩展中的 Swift 动画约束