node.js - Paypal 退款服务抛出 TRANSACTION_REFUSED 错误
问题描述
我正在尝试使用paypal的退款服务。我正在使用沙盒环境进行测试。我使用沙盒进行付款(基于订阅),出于某种原因,贝宝需要将近一天的时间来执行付款。我们的系统工作方式如下: 1) 创建基于订阅的计划 2) 为该订阅付费 3) Paypal 返回 billingAgreementId 以及返回 URL,保存该 ID 4) 由于 paypal 需要大量时间,请使用 Webhook Simulator 触发“付款销售完成”事件类型并进行付款。
因此,由于模拟器每次发送相同的虚拟 sale_id(并且会抛出无效 ID 错误),我无法测试退款 API(如下所示),所以我使用了沙盒环境中的 transaction_id(与 sale_id 相同)并将其静态用于退款。但即使那样,它也会引发错误,尽管我使用了有效的 sale_id。错误如下所示:
httpStatusCode: 400
response:
debug_id: "83878fa1bdb27"
httpStatusCode: 400
information_link: "https://developer.paypal.com/docs/api/payments/#errors"
message: "Request was refused.You can not do a partial refund on this transaction"
name: "TRANSACTION_REFUSED"
我的代码:
if (refundServiceResult.refundAmount > 0) {
//CALL PAYPAL REFUND SDK
var data = {
amount: {
currency: "USD",
total: refundServiceResult.refundAmount
}
},
// saleId = body.resource.id;
saleId = "88M48196CV276711X";
let refunded = await new Promise((resolve, reject) => {
paypal.sale.refund(saleId, data, (error, refund) => {
if (error) {
throw new Error(error);
} else {
console.log("Refund Sale Response");
console.log(JSON.stringify(refund));
resolve(refund);
}
});
});
console.log("Refunded Response", refunded);
我做了一些研究,发现如果沙盒设置中没有列出货币,但我在所有地方都使用美元并且“付款审查”选项也被切换到关闭,就会发生这种情况。但我仍然收到此错误。可能是什么原因?
解决方案
所以,我使用的是买家的 transaction_id(sale_id) 而不是卖家。在沙盒环境中,您可以在卖家和买家的账户中找到最新付款的 transaction_id。您应该使用卖家账户的 transaction_id 进行退款。
推荐阅读
- javascript - 如何从数组中打印数字?
- java - Spring 我可以使用 multipart/form-data 发布参数数组吗
- python - 与python中的else块混淆
- postgresql - 如何在 postgres 脚本中声明变量?
- sql - 如何在postgreSQL函数中从字符串变量中修剪双引号
- java - 如何在 for 循环中为 MenuItem 设置文本?
- c# - 我需要关于这个 lerping 问题的帮助。我正在尝试制作平台游戏
- excel - 如何像表单控件一样在循环中使用字符串名称?
- javascript - base64字符串转pdf下载
- c# - 如何在 app.config 中保存带有路径的 Excel 文件