贝宝发票 API - VALIDATION_ERROR

PayPal Invoicing API - VALIDATION_ERROR

我正在开发一个与 PayPal API 通信以创建发票的应用程序。

这是我的请求正文:

{
  "detail": {
    "currency_code": "USD",
    "note": "Thank you for using my services!"
  },
  "invoicer": {
    "name": {
      "given_name": "Shreyas",
      "surname": "Ayyengar"
    },
    "email_address": "{email}",
    "website": "{website}"
  },
  "primary_recipients": [
    {
      "billing_info": {
        "email_address": "{client_email}"
      }
    }
  ],
  "items": [
    {
      "name": "{invoice_name}",
      "description": "{invoice_description}",
      "quantity": "1",
      "unit_amount": {
        "currency_code": "USD",
        "value": "{invoice_amount}"
      },
      "tax": {
        "name": "PayPal Service Tax",
        "percent": "7.25"
      }
    }
  ],
  "configuration": {
    "partial_payment": {
      "allow_partial_payment": false
    },
    "allow_tip": true
  }
}

虽然有像 {client_email} 这样的占位符,但我可以保证它们会按预期正确替换。

但是我得到了一个我无法理解的 VALIDATION_ERROR{"name":"VALIDATION_ERROR","message":"Invalid request - see details.","information_link":"https://developer.paypal.com/docs/api/invoicing/#errors","details":[{"field":"merchant_info","issue":"cannot be null."},{"field":"items[0].unit_price","issue":"null"}]}

据我所知,这个错误表明我缺少 Items[].unit_pricemerchant_info 等信息,但是我不知道这应该在我的请求正文中的什么位置。我正在关注直接文档here,但我看不到任何提及 unit_pricemerchant_info.

的内容

将您的请求提交到正确的 API 端点,https://api-m.sandbox.paypal.com/v2/invoicing/invoices

记下主要版本号。详情见Invoicing API reference