创建发票无法通过Paypal REST API工作

时间:2018-06-14 07:24:05

标签: php paypal

我正面临通过REST API创建PayPal发票的问题。我使用https://api.sandbox.paypal.com/v1/oauth2/token的auth API获取了访问令牌。我在HEADER中传递令牌以在https://api.sandbox.paypal.com/v1/invoicing/invoices/的创建发票API中创建发票。

标题Paypal Header

以下是我的JSON正文。

{
  "merchant_info": {
    "email": "krpdas-facilitator@gmail.com",
    "first_name": "prabhu",
    "last_name": "kr",
    "business_name": "prabhu kr",
    "phone": {
      "country_code": "91",
      "national_number": "2222233333"
    },
    "address": {
        "line1": "xxxxxxxxxxx,xxxxxxx",
        "city": "xxxxxxx",
        "state": "xxxxxx",
        "postal_code": "888888",
        "country_code": "IN"
    }
  },
  "billing_info": [
    {
      "email": "lalith-facilitator@abacies.com",
        "business_name": "test facilitator",
        "additional_info": "test facilitator's Test Store",
        "address": {
            "line1": "1 Main St",
            "city": "San Jose",
            "state": "CA",
            "postal_code": "95131",
            "country_code": "US"
        }
    }
  ],
  "shipping_info": {
    "first_name": "Lalith",
    "last_name": "Kumar",
    "address": {
      "line1": "1234 Main Street",
      "city": "Anytown",
      "state": "CA",
      "postal_code": "98765",
      "country_code": "US"
    }
  },
  "items": [
    {
      "name": "Zoom System wireless headphones",
      "quantity": 2,
      "unit_price": {
        "currency": "USD",
        "value": "120"
      },
      "tax": {
        "name": "Tax",
        "percent": 8
      }
    },
    {
      "name": "Bluetooth speaker",
      "quantity": 1,
      "unit_price": {
        "currency": "USD",
        "value": "145"
      },
      "tax": {
        "name": "Tax",
        "percent": 8
      }
    }
  ],
  "discount": {
    "percent": 1
  },
  "shipping_cost": {
    "amount": {
      "currency": "USD",
      "value": "10"
    }
  },
  "note": "Thank you for your business.",
  "terms": "No refunds after 30 days."
}

我尝试更改访问令牌和商家电子邮件ID。但总是得到与401未经授权相同的错误。我正在关注https://developer.paypal.com/docs/api/invoicing/的文档。

错误:

{
    "name": "AUTHORIZATION_ERROR",
    "message": "Authorization error occurred.",
    "information_link": "https://developer.paypal.com/docs/api/invoicing/#errors",
    "debug_id": "f89a30f937ced"
}

范围:

"scope": "https://api.paypal.com/v1/payments/.* 
https://uri.paypal.com/services/payments/refund 
https://uri.paypal.com/services/applications/webhooks
https://uri.paypal.com/services/payments/payment/authcapture 
https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.* 
https://uri.paypal.com/services/disputes/read-seller 
https://uri.paypal.com/services/subscriptions 
https://uri.paypal.com/services/disputes/read-buyer 
https://api.paypal.com/v1/vault/credit-card openid 
https://uri.paypal.com/services/disputes/update-seller 
https://uri.paypal.com/services/payments/realtimepayment",

0 个答案:

没有答案