Reputation: 185
I'm searching a way to obtain the items list into the invoice from Paypal API.
I'm using V2 endpoint: https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100
and I also tried to append the fields list in the query string without success: https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100&fields=items
This is the documentation about the invoice: https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice
and the items array should be present but this is what I get:
{
"items": [
{
"id": "INV2-2RY8-ENR4-CNQU-JXPW",
"status": "DRAFT",
"detail": {
"reference": "deal-ref",
"currency_code": "USD",
"note": "Thank you for your business.",
"memo": "This is a long contract",
"invoice_number": "#1234",
"invoice_date": "2018-11-12",
"payment_term": {
"due_date": "2018-11-22"
},
"viewed_by_recipient": false,
"group_draft": false,
"metadata": {
"create_time": "2021-01-28T11:27:22Z"
}
},
"invoicer": {
"email_address": "[email protected]"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "[email protected]"
},
"shipping_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
}
}
}
],
"amount": {
"currency_code": "USD",
"value": "74.21"
},
"due_amount": {
"currency_code": "USD",
"value": "74.21"
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW/send",
"rel": "send",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "replace",
"method": "PUT"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "delete",
"method": "DELETE"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW/payments",
"rel": "record-payment",
"method": "POST"
}
]
},
{
"id": "INV2-RE4A-3KKC-C6Y6-96HG",
"status": "MARKED_AS_PAID",
"detail": {
"reference": "deal-ref",
"currency_code": "USD",
"note": "Thank you for your business.",
"memo": "This is a long contract",
"invoice_number": "#123",
"invoice_date": "2018-11-12",
"payment_term": {
"due_date": "2018-11-22"
},
"viewed_by_recipient": false,
"group_draft": false,
"metadata": {
"create_time": "2021-01-26T13:41:31Z"
}
},
"invoicer": {
"email_address": "[email protected]"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "[email protected]"
},
"shipping_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
}
}
}
],
"amount": {
"currency_code": "USD",
"value": "74.21"
},
"due_amount": {
"currency_code": "USD",
"value": "0.00"
},
"payments": {
"paid_amount": {
"currency_code": "USD",
"value": "74.21"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-RE4A-3KKC-C6Y6-96HG",
"rel": "self",
"method": "GET"
}
]
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100&total_required=false",
"rel": "self",
"method": "GET"
}
]
}
By using the endpoit to get only one invoice I get the items:
{
"id": "INV2-2RY8-ENR4-CNQU-JXPW",
"status": "DRAFT",
"detail": {
"reference": "deal-ref",
"currency_code": "USD",
"note": "Thank you for your business.",
"memo": "This is a long contract",
"additional_data": "2-4",
"category_code": "SHIPPABLE",
"invoice_number": "#1234",
"invoice_date": "2018-11-12",
"payment_term": {
"term_type": "NET_10",
"due_date": "2018-11-22"
},
"viewed_by_recipient": false,
"group_draft": false,
"metadata": {
"create_time": "2021-01-28T11:27:22Z",
"last_update_time": "2021-01-28T11:27:22Z",
"created_by_flow": "REGULAR_SINGLE",
"recipient_view_url": "https://www.sandbox.paypal.com/invoice/p/#2RY8ENR4CNQUJXPW",
"invoicer_view_url": "https://www.sandbox.paypal.com/invoice/details/INV2-2RY8-ENR4-CNQU-JXPW",
"caller_type": "API_V2_INVOICE"
},
"archived": false
},
"invoicer": {
"name": {
"given_name": "David",
"surname": "Larusso",
"full_name": "David Larusso"
},
"address": {
"address_line_1": "1234 First Street",
"address_line_2": "337673 Hillside Court",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
},
"email_address": "[email protected]",
"phones": [
{
"country_code": "001",
"national_number": "4085551234",
"phone_type": "MOBILE"
}
],
"website": "www.test.com",
"tax_id": "ABcNkWSfb5ICTt73nD3QON1fnnpgNKBy- Jb5SeuGj185MNNw6g",
"additional_notes": "2-4",
"logo_url": "https://example.com/logo.PNG"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
},
"email_address": "[email protected]"
},
"shipping_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
}
}
}
],
"items": [
{
"id": "ITEM-9D199841WF5879731",
"name": "Yoga Mat",
"description": "Elastic mat to practice yoga.",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "50.00"
},
"tax": {
"id": "TAX-7JU53623DY541294B",
"name": "Sales Tax",
"percent": "7.25",
"amount": {
"currency_code": "USD",
"value": "3.27"
}
},
"discount": {
"percent": "5",
"amount": {
"currency_code": "USD",
"value": "-2.50"
}
},
"unit_of_measure": "QUANTITY"
},
{
"id": "ITEM-4TV13589DH284484Y",
"name": "Yoga t-shirt",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"id": "TAX-7JU53623DY541294B",
"name": "Sales Tax",
"percent": "7.25",
"amount": {
"currency_code": "USD",
"value": "0.34"
}
},
"discount": {
"amount": {
"currency_code": "USD",
"value": "-5.00"
}
},
"unit_of_measure": "QUANTITY"
}
],
"configuration": {
"tax_calculated_after_discount": true,
"tax_inclusive": false,
"allow_tip": true,
"partial_payment": {
"allow_partial_payment": true,
"minimum_amount_due": {
"currency_code": "USD",
"value": "20.00"
}
},
"template_id": "TEMP-4JC7006465773450S"
},
"amount": {
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "60.00"
},
"discount": {
"invoice_discount": {
"percent": "5",
"amount": {
"currency_code": "USD",
"value": "-2.63"
}
},
"item_discount": {
"currency_code": "USD",
"value": "-7.50"
}
},
"tax_total": {
"currency_code": "USD",
"value": "4.34"
},
"shipping": {
"amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"id": "TAX-4CC09681KH001992P",
"name": "Sales Tax",
"percent": "7.25",
"amount": {
"currency_code": "USD",
"value": "0.73"
}
}
},
"custom": {
"label": "Packing Charges",
"amount": {
"currency_code": "USD",
"value": "10.00"
}
}
},
"currency_code": "USD",
"value": "74.21"
},
"due_amount": {
"currency_code": "USD",
"value": "74.21"
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW/send",
"rel": "send",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "replace",
"method": "PUT"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW",
"rel": "delete",
"method": "DELETE"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-2RY8-ENR4-CNQU-JXPW/payments",
"rel": "record-payment",
"method": "POST"
}
]
}
Is there a way to retrieve the items list without to process the invoices one by one?
Thank you in advance for your help.
Upvotes: 1
Views: 599
Reputation: 30377
&fields=items
Items, in this context, means the invoices themselves as part of the list of results.
Is there a way to retrieve the items list without to process the invoices one by one?
There isn't. You have to request an invoice individually.
Upvotes: 2