paypal - 完成付款后,PayPal SDK 导致“无法捕获订单”错误
问题描述
天哪,这个 PayPal 系统让我大吃一惊!我有以下代码:
<script src="https://www.paypal.com/sdk/js?client-id=MY_CODE_HERE&vault=true"></script>
然后这个脚本:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: parseFloat( window.my_config.amount ),
currency: 'USD',
},
description: window.my_config.description,
invoice_id: invoice_id
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
console.log({ details: details });
// do something here
});
$('#AJAXloadingWrapper').show();
},
onError: function (err) {
// Show an error page here, when an error occurs
console.log("ERROR")
console.dir(err);
}
}).render('#paypalWrapper');
它进入这一点很好:
onApprove: function(data, actions) {
但是当它运行时:
return actions.order.capture().then(function(details) {
我收到一个错误,但它失败了:(不拿钱)
Error
code: undefined
columnNumber: 55441
fileName: "https://www.paypal.com/sdk/js?client-id=xxxx&vault=true"
lineNumber: 2
message: "Order could not be captured"
那有什么意思?这是我要传递的一个示例purchase_units
:
我差一点就叫它退出并说“我们正在删除贝宝”。
更新:在我的搜索中,我不断有人告诉我,问题可能来自 PayPal,我正在使用重复的 invoice_id。我知道事实并非如此,但也许我传递错了?
return actions.order.create({
purchase_units: [{
amount: {
value: parseFloat( window.my_config.amount ),
currency: 'USD',
},
description: window.my_config.description,
invoice_id: invoice_id
}]
});
},
解决方案
好的,所以我真的希望我的痛苦将来能帮助其他人。我自己花了几个小时研究这个问题,然后用 PayPal 支持技术研究了更多时间。最终的解决方案是清除我的浏览器缓存。有点极端,但它似乎已经排序了。我希望我之前就想到了!
推荐阅读
- .net - 获取一个用户所属的所有租户的所有订阅
- angular - 更优化的方式,而不是 import * as firebase from 'firebase'
- sql-server - SQL Server 连接中间件?
- visual-studio-code - 如何将文本文件打包成 vscode 扩展
- java - Java 11 不可变地图:创建 Map.Entry
- html - 对齐框 (CSS/HTML)
- linux - 将数据从 STDIN 插入到字符串的特定位置
- php - 在不修改原始集合的情况下返回新集合
- javascript - 这些类型的解构有什么区别
- c# - 在 C# 中创建 PowerShell Cmdlet - 管道链接