- Authorization
- Orders
- Payments
- Invoices
- Invoices
- Generate invoice numberPOST
- Create draft invoicePOST
- Show invoice detailsGET
- List invoicesGET
- Generate QR codePOST
- Fully update invoicePUT
- Send invoicePOST
- Send invoice reminderPOST
- Cancel sent invoicePOST
- Delete invoiceDELETE
- Search for invoicesPOST
- Record payment for invoicePOST
- Delete external paymentDELETE
- Record refund for invoicePOST
- Delete external refundDELETE
- Templates
- Subscriptions
- Payouts
- Webhooks
- Shipment Tracking
- Transaction Search
- Disputes
- List disputes
- Show dispute details
- Accept claim
- Appeal dispute
- Settle dispute
- Update dispute status
- Make offer to resolve dispute
- Provide evidence
- Acknowledge returned item
- Provide supporting information for dispute
- Escalate dispute to claim
- Accept offer to resolve dispute
- Send message about dispute to other party
- Deny offer to resolve dispute
- Partially update dispute
- Onboarding (Limited Release)
Create draft invoice
POST
/v2/invoicing/invoices
In the JSON request body, include invoice details including merchant information. The
invoice
object must include an items
array.Note: The merchant that you specify in an invoice must have a PayPal account in good standing..
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Basic 之后拼接空格,以及经过 Base64 编码的 username:password
示例:
Authorization: Basic *****************
Header 参数
Content-Type
string
必需
示例值:
application/json
PayPal-Request-Id
string
必需
示例值:
{{$guid}}
Prefer
string
必需
return=minimal
. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes theid
,status
and HATEOAS links.return=representation
. The server returns a complete resource representation, including the current state of the resource.
示例值:
{{prefer_representation_detailed}}
Body 参数application/json
detail
object
必需
invoice_number
string
必需
invoice_date
string
必需
payment_term
object
必需
currency_code
string
必需
reference
string
必需
note
string
必需
terms_and_conditions
string
必需
memo
string
必需
invoicer
object
必需
name
object
必需
address
object
必需
phones
array [object {3}]
必需
website
string
必需
tax_id
string
必需
logo_url
string
必需
additional_notes
string
必需
primary_recipients
array [object {2}]
必需
billing_info
object
可选
shipping_info
object
可选
items
array [object {7}]
必需
name
string
必需
description
string
可选
quantity
string
必需
unit_amount
object
必需
tax
object
必需
discount
object
必需
unit_of_measure
string
必需
configuration
object
必需
partial_payment
object
必需
allow_tip
boolean
必需
tax_calculated_after_discount
boolean
必需
tax_inclusive
boolean
必需
amount
object
必需
breakdown
object
必需
示例
{
"detail": {
"invoice_number": "{{draft_invoice_number}}",
"invoice_date": "2022-02-04",
"payment_term": {
"term_type": "NET_10",
"due_date": "2022-02-14"
},
"currency_code": "USD",
"reference": "<The reference data. Includes a post office (PO) number.>",
"note": "<A note to the invoice recipient. Also appears on the invoice notification email.>",
"terms_and_conditions": "<The general terms of the invoice. Can include return or cancellation policy and other terms and conditions.>",
"memo": "<A private bookkeeping note for merchant.>"
},
"invoicer": {
"name": {
"given_name": "David",
"surname": "Larusso"
},
"address": {
"address_line_1": "123 Townsend St",
"address_line_2": "Floor 6",
"admin_area_2": "San Francisco",
"admin_area_1": "CA",
"postal_code": "94107",
"country_code": "US"
},
"phones": [
{
"country_code": "001",
"national_number": "4085551234",
"phone_type": "MOBILE"
}
],
"website": "www.example.com",
"tax_id": "XX-XXXXXXX",
"logo_url": "https://example.com/logo.png",
"additional_notes": "<Any additional information. Includes business hours.>"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
},
"email_address": "foobuyer@example.com",
"phones": [
{
"country_code": "001",
"national_number": "4884551234",
"phone_type": "HOME"
}
],
"additional_info_value": "add-info"
},
"shipping_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
}
}
}
],
"items": [
{
"name": "Yoga Mat",
"description": "Elastic mat to practice yoga.",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "50.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
},
"discount": {
"percent": "5"
},
"unit_of_measure": "QUANTITY"
},
{
"name": "Yoga t-shirt",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
},
"discount": {
"amount": {
"currency_code": "USD",
"value": "5.00"
}
},
"unit_of_measure": "QUANTITY"
}
],
"configuration": {
"partial_payment": {
"allow_partial_payment": true,
"minimum_amount_due": {
"currency_code": "USD",
"value": "20.00"
}
},
"allow_tip": true,
"tax_calculated_after_discount": true,
"tax_inclusive": false
},
"amount": {
"breakdown": {
"custom": {
"label": "Packing Charges",
"amount": {
"currency_code": "USD",
"value": "10.00"
}
},
"shipping": {
"amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
}
},
"discount": {
"invoice_discount": {
"percent": "5"
}
}
}
}
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api-m.sandbox.paypal.com/v2/invoicing/invoices' \
--header 'PayPal-Request-Id: ' \
--header 'Prefer: ' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Og==' \
--data-raw '{
"detail": {
"invoice_number": "{{draft_invoice_number}}",
"invoice_date": "2022-02-04",
"payment_term": {
"term_type": "NET_10",
"due_date": "2022-02-14"
},
"currency_code": "USD",
"reference": "<The reference data. Includes a post office (PO) number.>",
"note": "<A note to the invoice recipient. Also appears on the invoice notification email.>",
"terms_and_conditions": "<The general terms of the invoice. Can include return or cancellation policy and other terms and conditions.>",
"memo": "<A private bookkeeping note for merchant.>"
},
"invoicer": {
"name": {
"given_name": "David",
"surname": "Larusso"
},
"address": {
"address_line_1": "123 Townsend St",
"address_line_2": "Floor 6",
"admin_area_2": "San Francisco",
"admin_area_1": "CA",
"postal_code": "94107",
"country_code": "US"
},
"phones": [
{
"country_code": "001",
"national_number": "4085551234",
"phone_type": "MOBILE"
}
],
"website": "www.example.com",
"tax_id": "XX-XXXXXXX",
"logo_url": "https://example.com/logo.png",
"additional_notes": "<Any additional information. Includes business hours.>"
},
"primary_recipients": [
{
"billing_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
},
"email_address": "foobuyer@example.com",
"phones": [
{
"country_code": "001",
"national_number": "4884551234",
"phone_type": "HOME"
}
],
"additional_info_value": "add-info"
},
"shipping_info": {
"name": {
"given_name": "Stephanie",
"surname": "Meyers"
},
"address": {
"address_line_1": "1234 Main Street",
"admin_area_2": "Anytown",
"admin_area_1": "CA",
"postal_code": "98765",
"country_code": "US"
}
}
}
],
"items": [
{
"name": "Yoga Mat",
"description": "Elastic mat to practice yoga.",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "50.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
},
"discount": {
"percent": "5"
},
"unit_of_measure": "QUANTITY"
},
{
"name": "Yoga t-shirt",
"quantity": "1",
"unit_amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
},
"discount": {
"amount": {
"currency_code": "USD",
"value": "5.00"
}
},
"unit_of_measure": "QUANTITY"
}
],
"configuration": {
"partial_payment": {
"allow_partial_payment": true,
"minimum_amount_due": {
"currency_code": "USD",
"value": "20.00"
}
},
"allow_tip": true,
"tax_calculated_after_discount": true,
"tax_inclusive": false
},
"amount": {
"breakdown": {
"custom": {
"label": "Packing Charges",
"amount": {
"currency_code": "USD",
"value": "10.00"
}
},
"shipping": {
"amount": {
"currency_code": "USD",
"value": "10.00"
},
"tax": {
"name": "Sales Tax",
"percent": "7.25"
}
},
"discount": {
"invoice_discount": {
"percent": "5"
}
}
}
}
}'
返回响应
🟢201201 - Create Draft Invoice With Minimal Request
application/json
Body
id
string
必需
status
string
必需
detail
object
必需
currency_code
string
必需
category_code
string
必需
invoice_number
string
必需
invoice_date
string
必需
payment_term
object
必需
viewed_by_recipient
boolean
必需
group_draft
boolean
必需
metadata
object
必需
archived
boolean
必需
invoicer
object
必需
configuration
object
必需
tax_calculated_after_discount
boolean
必需
tax_inclusive
boolean
必需
allow_tip
boolean
必需
template_id
string
必需
amount
object
必需
breakdown
object
必需
currency_code
string
必需
value
string
必需
due_amount
object
必需
currency_code
string
必需
value
string
必需
links
array [object {3}]
必需
href
string
必需
rel
string
必需
method
string
必需
示例
{
"id": "INV2-TKNW-LEZX-7NEF-Q4V2",
"status": "DRAFT",
"detail": {
"currency_code": "USD",
"category_code": "SHIPPABLE",
"invoice_number": "1643942295",
"invoice_date": "2018-11-12",
"payment_term": {
"term_type": "NO_DUE_DATE"
},
"viewed_by_recipient": false,
"group_draft": false,
"metadata": {
"create_time": "2022-02-04T02:40:06Z",
"last_update_time": "2022-02-04T02:40:06Z",
"created_by_flow": "REGULAR_SINGLE",
"recipient_view_url": "https://www.sandbox.paypal.com/invoice/p/#TKNWLEZX7NEFQ4V2",
"invoicer_view_url": "https://www.sandbox.paypal.com/invoice/details/INV2-TKNW-LEZX-7NEF-Q4V2",
"caller_type": "API_V2_INVOICE"
},
"archived": false
},
"invoicer": {},
"configuration": {
"tax_calculated_after_discount": false,
"tax_inclusive": false,
"allow_tip": false,
"template_id": "TEMP-8LK05440PT816351U"
},
"amount": {
"breakdown": {
"discount": {
"invoice_discount": {
"amount": {
"currency_code": "USD",
"value": "0.00"
}
},
"item_discount": {
"currency_code": "USD",
"value": "0.00"
}
},
"tax_total": {
"currency_code": "USD",
"value": "0.00"
}
},
"currency_code": "USD",
"value": "0.00"
},
"due_amount": {
"currency_code": "USD",
"value": "0.00"
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-TKNW-LEZX-7NEF-Q4V2",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-TKNW-LEZX-7NEF-Q4V2/send",
"rel": "send",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-TKNW-LEZX-7NEF-Q4V2",
"rel": "replace",
"method": "PUT"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-TKNW-LEZX-7NEF-Q4V2",
"rel": "delete",
"method": "DELETE"
},
{
"href": "https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-TKNW-LEZX-7NEF-Q4V2/payments",
"rel": "record-payment",
"method": "POST"
}
]
}
🟢201201 - Create Draft Invoice With Detailed Request
🟢201201 - Create Draft Invoice With Invoice Template
🟠400400 Bad Request - Invalid Invoice Template
🟠401401 Unauthorized - Invalid Token