restcurlpaypalinvoice

PayPal REST API Create Invoice with Template


Has anybody ever successfully created a PayPal invoice with a specific chosen template? I can't seem to get it to work.

Have tried specifying the template_id in the call, and have also tried setting the desired template as the default. In both cases, the API response contains the chosen template ID, but when the invoice is sent, it does not use the chosen template (can tell because there's no logo).

This the the API call:

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
}'

This is the response:

"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

If anybody has any ideas, would be happy to hear them.


Solution

  • I ended up getting in touch with someone at PayPal. They said that the merchant_info has to be passed in the request in order for the template to work. That basically defeated the purpose of using the templates for us, so I never bothered testing that.

    In the end, I just decided to not use a template.