Paypal API 获取包含项目的发票列表
Posted
技术标签:
【中文标题】Paypal API 获取包含项目的发票列表【英文标题】:Paypal API get invoices list with items 【发布时间】:2021-05-02 10:04:30 【问题描述】:我正在寻找一种从 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 数组应该存在,但这是我得到的:
"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"
]
有没有办法在不逐一处理发票的情况下检索项目列表?
提前感谢您的帮助。
【问题讨论】:
【参考方案1】:&fields=项目
在此上下文中,项目是指作为结果列表一部分的发票本身。
有没有办法在不逐一处理发票的情况下检索项目列表?
没有。您必须单独申请发票。
【讨论】:
感谢您的帮助。是否有关于如何传递字段列表的文档?可能是 items.items?以上是关于Paypal API 获取包含项目的发票列表的主要内容,如果未能解决你的问题,请参考以下文章