Paypal API 获取包含项目的发票列表
Paypal API get invoices list with items
我正在寻找一种从 Paypal API 获取商品清单到发票中的方法。
我正在使用 V2 端点:https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100
而且我还尝试在查询字符串中附加字段列表但没有成功:
https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100&fields=items
这是关于发票的文件:
https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice
并且项目数组应该存在,但这是我得到的:
{
"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": "sb-fle2y4542126@business.example.com"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "bill-me@example.com"
},
"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": "sb-fle2y4542126@business.example.com"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "bill-me@example.com"
},
"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"
}
]
}
通过使用端点只获得一张发票,我得到了物品:
{
"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": "sb-fle2y4542126@business.example.com",
"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": "bill-me@example.com"
},
"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"
}
]
}
有没有一种方法可以检索项目列表而不用一张一张地处理发票?
预先感谢您的帮助。
&fields=items
在此上下文中,项目是指作为结果列表一部分的发票本身。
Is there a way to retrieve the items list without to process the invoices one by one?
没有。您必须单独申请发票。
我正在寻找一种从 Paypal API 获取商品清单到发票中的方法。
我正在使用 V2 端点:https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100
而且我还尝试在查询字符串中附加字段列表但没有成功: https://api-m.sandbox.paypal.com/v2/invoicing/invoices?page=1&page_size=100&fields=items
这是关于发票的文件: https://developer.paypal.com/docs/api/invoicing/v2/#definition-invoice
并且项目数组应该存在,但这是我得到的:
{
"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": "sb-fle2y4542126@business.example.com"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "bill-me@example.com"
},
"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": "sb-fle2y4542126@business.example.com"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers",
"full_name": "Stephanie Meyers"
},
"email_address": "bill-me@example.com"
},
"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"
}
]
}
通过使用端点只获得一张发票,我得到了物品:
{
"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": "sb-fle2y4542126@business.example.com",
"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": "bill-me@example.com"
},
"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"
}
]
}
有没有一种方法可以检索项目列表而不用一张一张地处理发票?
预先感谢您的帮助。
&fields=items
在此上下文中,项目是指作为结果列表一部分的发票本身。
Is there a way to retrieve the items list without to process the invoices one by one?
没有。您必须单独申请发票。