Paypal退款服务会抛出TRANSACTION_REFUSED错误

问题描述 投票:0回答:1

我正在尝试使用paypal的退款服务。我正在使用沙箱环境进行测试。我使用沙箱进行付款(基于订阅),出于某种原因,paypal需要将近一天的时间来执行付款。我们的系统工作如下:1)创建基于订阅的计划2)支付该订阅3)Paypal返回billingAgreementId以及返回URL,保存Id 4)因为,paypal需要花费大量时间,使用Webhook模拟器来触发“付款销售已完成”活动类型并进行付款。

因此,由于模拟器每次发送相同的虚拟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);

我做了一些研究,发现如果货币没有在沙箱设置中列出但是我在各处使用USD而且“付款评论”选项也切换为关闭,则会发生这种情况。但我仍然遇到这个错误。可能是什么原因?

node.js paypal-sandbox paypal-ipn paypal-rest-sdk paypal-subscriptions
1个回答
0
投票

所以,我使用买方的transaction_id(sale_id)而不是卖方。在沙盒环境中,您可以在卖家和买家的帐户中找到最新付款的transaction_id。您应该使用卖家帐户的transaction_id进行退款。

© www.soinside.com 2019 - 2024. All rights reserved.