PayPal REST API使用模板创建发票

问题描述 投票:2回答:3

有没有人用特定的模板成功创建了PayPal发票?我似乎无法让它发挥作用。

尝试在调用中指定template_id,并尝试将所需模板设置为默认模板。在这两种情况下,API响应都包含所选的模板ID,但是在发送发票时,它不会使用所选模板(可以判断,因为没有徽标)。

这是API调用:

curl -v -X POST https://api.paypal.com/v1/invoicing/invoices/ \
-H "Content-Type:application/json" \
-H "Authorization: Bearer <Access-Token>" \
-d '{
  "template_id": "TEMP-66B140465N059453G",
  "items": [
  {
    "name": "Part E",
    "quantity": 2,
    "unit_price": {
    "currency": "USD",
    "value": "10.15"
    }
  }
  ],
  "shipping_info": {
  "first_name": "John",
  "last_name": "Doe",
  "business_name": "Not applicable",
  "phone": {
    "country_code": "001",
    "national_number": "5039871234"
  },
  "address": {
    "line1": "1234 Broad St.",
    "city": "Portland",
    "state": "OR",
    "postal_code": "97216",
    "country_code": "US"
  }
  },
  "shipping_cost": {
  "amount": {
    "currency": "USD",
    "value": "15.01"
    }
  },
  "allow_tip": false
}'

这是回应:

"id":<Invoice ID>,
"number":"0004",
"template_id":"TEMP-66B140465N059453G",
"status":"DRAFT",
"merchant_info":{},
"shipping_info":{"first_name":"John","last_name":"Doe","business_name":"Not applicable","phone":{"country_code":"001","national_number":"5039871234"},"address":{"line1":"1234 Broad St.","city":"Portland","state":"OR","postal_code":"97216","country_code":"US"}},
"items":[{"name":"Part E","quantity":2.0,"unit_price":{"currency":"USD","value":"10.15"}}],
"invoice_date":"2017-05-30 PDT",
"shipping_cost":{"amount":{"currency":"USD","value":"15.01"}},
"tax_calculated_after_discount":false,
"tax_inclusive":false,
"total_amount":{"currency":"USD","value":"35.31"},
"metadata":{"created_date":"2017-05-30 13:35:39 PDT"},
"allow_tip":false

如果有人有任何想法,会很高兴听到他们。

谢谢。

rest api paypal invoice
3个回答
2
投票

我们正在纠正您使用模板ID的说明。对困惑感到抱歉。

当您进行基本集成以创建和发送发票时,您根本不需要使用模板。

如果要创建完整的发票应用程序,模板非常有用,您希望最终用户(发票人)能够在创建发票时创建模板并访问它们。有关如何使用模板的信息,请访问PayPal.com网站。

问候,克里斯汀


0
投票

我最终与PayPal的某个人联系。他们说必须在请求中传递merchant_info才能使模板正常工作。这基本上打败了我们使用模板的目的,所以我从不打扰测试。

最后,我决定不使用模板。


0
投票

如果您只想将徽标添加到API创建的发票中,请在发布草稿之前将此行放在JSON的末尾:

},
   "note": "Thank you for your business!",
  "terms": "no refunds after 30 days",
  "logo_url": "https://link_to_your_log.PNG"
}
© www.soinside.com 2019 - 2024. All rights reserved.