Paypal REST API:Payouts API在沙箱中提供错误INSUFFICIENT_FUNDS

时间:2017-05-28 08:33:59

标签: paypal paypal-rest-sdk

我正在尝试使用针对paypal的Node.js SDK以及他们在Github上提供的示例来测试payouts API。以下是相同的代码:

"use strict";
let paypal = require('paypal-rest-sdk');
const bluebird = require('bluebird');

paypal.configure({
  mode: process.env.PAYPAL_MODE, //sandbox or live
  client_id: process.env.PAYPAL_CLIENT_ID,
  client_secret: process.env.PAYPAL_CLIENT_SECRET
});

bluebird.promisifyAll(paypal.payment);
bluebird.promisifyAll(paypal.payout);


function sendMoneyToParticipant () {
  const sender_batch_id = Math.random().toString(36).substring(9);
  let create_payout_json = {
    "sender_batch_header": {
      "sender_batch_id": sender_batch_id,
      "email_subject": "You have a payment"
    },
    "items": [
      {
        "recipient_type": "EMAIL",
        "amount": {
          "value": 0.90,
          "currency": "USD"
        },
        "receiver": "redacted-email-address",
        "note": "Thank you.",
        "sender_item_id": "item_3"
      }
    ]
  };
  const sync_mode = 'true';
  return paypal.payout.createAsync(create_payout_json, sync_mode)
}


PaypalAPI.sendMoneyToParticipant().then(result => {
  console.log(JSON.stringify(result, null, 2))
}).catch(console.error)

我自己创建了沙箱帐户,并在帐户创建步骤中添加了1000美元。但是,我仍然在回复

{
  "batch_header": {
    "payout_batch_id": "78AMS3QCSQTBE",
    "batch_status": "DENIED",
    "time_created": "2017-05-28T07:38:51Z",
    "time_completed": "2017-05-28T07:38:52Z",
    "sender_batch_header": {
      "email_subject": "You have a payment",
      "sender_batch_id": "618ak0vozjwwhilik9"
    },
    "amount": {
      "currency": "USD",
      "value": "0.9"
    },
    "fees": {
      "currency": "USD",
      "value": "0.25"
    }
  },
  "items": [
    {
      "payout_item_id": "F2XACBBTKRXK2",
      "transaction_status": "FAILED",
      "payout_item_fee": {
        "currency": "USD",
        "value": "0.25"
      },
      "payout_batch_id": "78AMS3QCSQTBE",
      "payout_item": {
        "amount": {
          "currency": "USD",
          "value": "0.9"
        },
        "note": "Thank you.",
        "receiver": "mandeep.s.gulati@gmail.com",
        "recipient_type": "EMAIL",
        "sender_item_id": "item_3"
      },
      "errors": {
        "name": "INSUFFICIENT_FUNDS",
        "message": "Sender has insufficient funds",
        "information_link": "https://developer.paypal.com/docs/api/payments.payouts-batch/#errors"
      },
      "links": [
        {
          "href": "https://api.sandbox.paypal.com/v1/payments/payouts-item/F2XACBBTKRXK2",
          "rel": "item",
          "method": "GET"
        }
      ]
    }
  ],
  "links": [
    {
      "href": "https://api.sandbox.paypal.com/v1/payments/payouts/78AMS3QCSQTBE",
      "rel": "self",
      "method": "GET"
    }
  ],
  "httpStatusCode": 201
}

0 个答案:

没有答案