Use the Invoicing API to create, send, and manage invoices. You can also use the API or webhooks to track invoice payments. When you send an invoice to a customer, the invoice moves from draft to payable state. PayPal then emails the customer a link to the invoice on the PayPal website. Customers with a PayPal account can log in and pay the invoice with PayPal. Alternatively, customers can pay as a guest with a debit card or credit card. For more information, see the <a href="/docs/invoicing/">Invoicing Overview and the <a href="/docs/invoicing/basic-integration/">Invoicing Integration Guide.
- Requirements
- Installation
- Getting Started
- Async
- Raw HTTP Response
- Reference
paypalinvoicing.invoices.cancel_sent_invoicepaypalinvoicing.invoices.create_draft_invoicepaypalinvoicing.invoices.delete_draft_or_scheduled_invoicepaypalinvoicing.invoices.delete_external_paymentpaypalinvoicing.invoices.delete_external_refundpaypalinvoicing.invoices.generate_next_invoice_numberpaypalinvoicing.invoices.generate_qr_codepaypalinvoicing.invoices.get_detailspaypalinvoicing.invoices.get_invoicespaypalinvoicing.invoices.record_paymentpaypalinvoicing.invoices.record_refundpaypalinvoicing.invoices.send_invoicepaypalinvoicing.invoices.send_reminderpaypalinvoicing.invoices.update_full_invoicepaypalinvoicing.search_invoices.listpaypalinvoicing.templates.create_templatepaypalinvoicing.templates.delete_by_idpaypalinvoicing.templates.list_detailspaypalinvoicing.templates.show_details_by_idpaypalinvoicing.templates.update_full_template
Python >=3.7
from pprint import pprint
from pay_pal_invoicing_python_sdk import PayPalInvoicing, ApiException
paypalinvoicing = PayPalInvoicing(
client_id = 'YOUR_CLIENT_ID',
client_secret = 'YOUR_CLIENT_SECRET',
)
try:
# Cancel sent invoice
paypalinvoicing.invoices.cancel_sent_invoice(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)
except ApiException as e:
print("Exception when calling InvoicesApi.cancel_sent_invoice: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)async support is available by prepending a to any method.
import asyncio
from pprint import pprint
from pay_pal_invoicing_python_sdk import PayPalInvoicing, ApiException
paypalinvoicing = PayPalInvoicing(
client_id = 'YOUR_CLIENT_ID',
client_secret = 'YOUR_CLIENT_SECRET',
)
async def main():
try:
# Cancel sent invoice
await paypalinvoicing.invoices.acancel_sent_invoice(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)
except ApiException as e:
print("Exception when calling InvoicesApi.cancel_sent_invoice: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)
asyncio.run(main())To access raw HTTP response values, use the .raw namespace.
from pprint import pprint
from pay_pal_invoicing_python_sdk import PayPalInvoicing, ApiException
paypalinvoicing = PayPalInvoicing(
client_id = 'YOUR_CLIENT_ID',
client_secret = 'YOUR_CLIENT_SECRET',
)
try:
# Cancel sent invoice
cancel_sent_invoice_response = paypalinvoicing.invoices.raw.cancel_sent_invoice(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)
pprint(cancel_sent_invoice_response.headers)
pprint(cancel_sent_invoice_response.status)
pprint(cancel_sent_invoice_response.round_trip_time)
except ApiException as e:
print("Exception when calling InvoicesApi.cancel_sent_invoice: %s\n" % e)
pprint(e.body)
pprint(e.headers)
pprint(e.status)
pprint(e.reason)
pprint(e.round_trip_time)Cancels a sent invoice, by ID, and, optionally, sends a notification about the cancellation to the payer, merchant, and CC: emails.
paypalinvoicing.invoices.cancel_sent_invoice(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)The ID of the draft invoice to delete.
The subject of the email that is sent as a notification to the recipient.
A note to the payer.
Indicates whether to send a copy of the email to the merchant.
Indicates whether to send a copy of the email to the recipient.
An array of one or more CC: emails to which notifications are sent. If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
Note: Valid values are email addresses in the additional_recipients value associated with the invoice.
Notification
The email or SMS notification that will be sent to the payer on cancellation.
/v2/invoicing/invoices/{invoice_id}/cancel post
π Back to Table of Contents
Creates a draft invoice. To move the invoice from a draft to payable state, you must send the invoice.
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..
create_draft_invoice_response = paypalinvoicing.invoices.create_draft_invoice(
detail={},
id="string_example",
parent_id="string_example",
items="DRAFT",
invoicer={},
primary_recipients=[
{
}
],
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
items=[
{
"name": "name_example",
"quantity": "quantity_example",
"unit_amount": {
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
"unit_of_measure": "QUANTITY",
}
],
configuration={},
amount={
},
due_amount={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
gratuity={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
payments={
},
refunds={
},
links=[
{
"href": "href_example",
"rel": "rel_example",
"method": "GET",
}
],
)detail: InvoiceDetail
The ID of the invoice.
The parent ID to an invoice that defines the group invoice to which the invoice is related.
items: InvoiceStatus
invoicer: InvoicerInfo
The billing and shipping information. Includes name, email, address, phone and language.
An array of one or more CC: emails to which notifications are sent. If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
Note: Valid values are email addresses in the additional_recipients value associated with the invoice.
An array of invoice line item information.
configuration: Configuration
amount: AmountSummaryDetail
due_amount: Money
gratuity: Money
payments: Payments
refunds: Refunds
An array of request-related HATEOAS links.
Invoice
The invoice details which includes all information of the invoice like items, billing information.
/v2/invoicing/invoices post
π Back to Table of Contents
Deletes a draft or scheduled invoice, by ID. Deletes invoices in the draft or scheduled state only. For invoices that have already been sent, you can cancel the invoice. After you delete a draft or scheduled invoice, you can no longer use it or show its details. However, you can reuse its invoice number.
paypalinvoicing.invoices.delete_draft_or_scheduled_invoice(
invoice_id="invoice_id_example",
)The ID of the draft invoice to delete.
/v2/invoicing/invoices/{invoice_id} delete
π Back to Table of Contents
Deletes an external payment, by invoice ID and transaction ID.
paypalinvoicing.invoices.delete_external_payment(
invoice_id="invoice_id_example",
transaction_id="transaction_id_example",
)The ID of the draft invoice to delete.
The ID of the external refund transaction to delete.
/v2/invoicing/invoices/{invoice_id}/payments/{transaction_id} delete
π Back to Table of Contents
Deletes an external refund, by invoice ID and transaction ID.
paypalinvoicing.invoices.delete_external_refund(
invoice_id="invoice_id_example",
transaction_id="transaction_id_example",
)The ID of the draft invoice to delete.
The ID of the external refund transaction to delete.
/v2/invoicing/invoices/{invoice_id}/refunds/{transaction_id} delete
π Back to Table of Contents
Generates the next invoice number that is available to the merchant. The next invoice number uses the prefix and suffix from the last invoice number and increments the number by one. For example, the next invoice number after INVOICE-1234 is INVOICE-1235.
generate_next_invoice_number_response = paypalinvoicing.invoices.generate_next_invoice_number()/v2/invoicing/generate-next-invoice-number post
π Back to Table of Contents
Generates a QR code for an invoice, by ID. The QR code is a PNG image in Base64-encoded format that corresponds to the invoice ID. You can generate a QR code for an invoice and add it to a paper or PDF invoice. When customers use their mobile devices to scan the QR code, they are redirected to the PayPal mobile payment flow where they can view the invoice and pay online with PayPal or a credit card. Before you get a QR code, you must create an invoice and send an invoice to move the invoice from a draft to payable state. Do not include an email address if you do not want the invoice emailed.
paypalinvoicing.invoices.generate_qr_code(
invoice_id="invoice_id_example",
width=500,
height=500,
action="pay",
)The ID of the draft invoice to delete.
The width, in pixels, of the QR code image. Value is from 150 to 500.
The height, in pixels, of the QR code image. Value is from 150 to 500.
The type of URL for which to generate a QR code. Valid values are pay and details.
QrConfig
Optional configuration parameters to adjust QR code width, height and the encoded URL.
/v2/invoicing/invoices/{invoice_id}/generate-qr-code post
π Back to Table of Contents
Shows details for an invoice, by ID.
get_details_response = paypalinvoicing.invoices.get_details(
invoice_id="invoice_id_example",
)The ID of the draft invoice to delete.
/v2/invoicing/invoices/{invoice_id} get
π Back to Table of Contents
Lists invoices. To filter the invoices that appear in the response, you can specify one or more optional query parameters.
get_invoices_response = paypalinvoicing.invoices.get_invoices(
page=1,
page_size=20,
total_required=False,
fields="all",
)The page number to be retrieved, for the list of templates. So, a combination of page=1 and page_size=20 returns the first 20 templates. A combination of page=2 and page_size=20 returns the next 20 templates.
The maximum number of templates to return in the response.
Indicates whether the to show total_pages and total_items in the response.
The fields to return in the response. Value is all or none. To return only the template name, ID, and default attributes, specify none.
/v2/invoicing/invoices get
π Back to Table of Contents
Records a payment for the invoice. If no payment is due, the invoice is marked as PAID. Otherwise, the invoice is marked as PARTIALLY PAID.
record_payment_response = paypalinvoicing.invoices.record_payment(
method="BANK_TRANSFER",
invoice_id="invoice_id_example",
type="PAYPAL",
payment_id="string_example",
payment_date="0480-08-03",
note="string_example",
amount={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
shipping_info={},
)method: PaymentMethod
The ID of the draft invoice to delete.
type: PaymentType
The ID for a PayPal payment transaction. Required for the PAYPAL payment type.
payment_date: DateNoTime
A note associated with an external cash or check payment.
amount: Money
shipping_info: ContactNameAddress
PaymentDetail
The details of the payment to record against the invoice.
/v2/invoicing/invoices/{invoice_id}/payments post
π Back to Table of Contents
Records a refund for the invoice. If all payments are refunded, the invoice is marked as REFUNDED. Otherwise, the invoice is marked as PARTIALLY REFUNDED.
record_refund_response = paypalinvoicing.invoices.record_refund(
method="BANK_TRANSFER",
invoice_id="invoice_id_example",
type="PAYPAL",
refund_id="string_example",
refund_date="0480-08-03",
amount={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
)method: PaymentMethod
The ID of the draft invoice to delete.
type: PaymentType
The ID for a PayPal payment transaction. Required for the PAYPAL payment type.
refund_date: DateNoTime
amount: Money
RefundDetail
The details of the refund to record against the invoice.
/v2/invoicing/invoices/{invoice_id}/refunds post
π Back to Table of Contents
Sends or schedules an invoice, by ID, to be sent to a customer. The action depends on the invoice issue date:
- If the invoice issue date is current or in the past, sends the invoice immediately.
- If the invoice issue date is in the future, schedules the invoice to be sent on that date.
send_to_invoicer body parameter to false. To send the invoice through a share link and not through PayPal, set the send_to_recipient parameter to false in the notification object. The send_to_recipient parameter does not apply to a future issue date because the invoice is scheduled to be sent through PayPal on that date.Notes:
- After you send an invoice, resending it has no effect.
- To send a notification for updates, update the invoice and set the
send_to_recipientbody parameter totrue.
send_invoice_response = paypalinvoicing.invoices.send_invoice(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)The ID of the draft invoice to delete.
The subject of the email that is sent as a notification to the recipient.
A note to the payer.
Indicates whether to send a copy of the email to the merchant.
Indicates whether to send a copy of the email to the recipient.
An array of one or more CC: emails to which notifications are sent. If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
Note: Valid values are email addresses in the additional_recipients value associated with the invoice.
Notification
The email or SMS notification to send to the payer when they send an invoice..
/v2/invoicing/invoices/{invoice_id}/send post
π Back to Table of Contents
Sends a reminder to the payer about an invoice, by ID. In the JSON request body, include a notification object that defines the subject of the reminder and other details.
paypalinvoicing.invoices.send_reminder(
invoice_id="invoice_id_example",
subject="string_example",
note="string_example",
send_to_invoicer=False,
send_to_recipient=True,
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
)The ID of the draft invoice to delete.
The subject of the email that is sent as a notification to the recipient.
A note to the payer.
Indicates whether to send a copy of the email to the merchant.
Indicates whether to send a copy of the email to the recipient.
An array of one or more CC: emails to which notifications are sent. If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
Note: Valid values are email addresses in the additional_recipients value associated with the invoice.
Notification
The email or SMS notification that will be sent to the payer for reminder.
/v2/invoicing/invoices/{invoice_id}/remind post
π Back to Table of Contents
Fully updates an invoice, by ID. In the JSON request body, include a complete invoice object. This call does not support partial updates.
update_full_invoice_response = paypalinvoicing.invoices.update_full_invoice(
detail={},
invoice_id="invoice_id_example",
id="string_example",
parent_id="string_example",
items="DRAFT",
invoicer={},
primary_recipients=[
{
}
],
additional_recipients=[
"j@Z,rZ#UM/?R,Fp^l6$ARjbhJk C>i H'qT\\{<?'es#)#iK.YM{Rag2/!KB!k@5oXh.:Ts\";mG"
],
items=[
{
"name": "name_example",
"quantity": "quantity_example",
"unit_amount": {
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
"unit_of_measure": "QUANTITY",
}
],
configuration={},
amount={
},
due_amount={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
gratuity={
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
payments={
},
refunds={
},
links=[
{
"href": "href_example",
"rel": "rel_example",
"method": "GET",
}
],
send_to_recipient=True,
send_to_invoicer=True,
)detail: InvoiceDetail
The ID of the draft invoice to delete.
The ID of the invoice.
The parent ID to an invoice that defines the group invoice to which the invoice is related.
items: InvoiceStatus
invoicer: InvoicerInfo
The billing and shipping information. Includes name, email, address, phone and language.
An array of one or more CC: emails to which notifications are sent. If you omit this parameter, a notification is sent to all CC: email addresses that are part of the invoice.
Note: Valid values are email addresses in the additional_recipients value associated with the invoice.
An array of invoice line item information.
configuration: Configuration
amount: AmountSummaryDetail
due_amount: Money
gratuity: Money
payments: Payments
refunds: Refunds
An array of request-related HATEOAS links.
Indicates whether to send the invoice update notification to the recipient.
Indicates whether to send the invoice update notification to the merchant.
Invoice
A representation of changes to make in the invoice.
/v2/invoicing/invoices/{invoice_id} put
π Back to Table of Contents
Searches for and lists invoices that match search criteria. If you pass multiple criteria, the response lists invoices that match all criteria.
list_response = paypalinvoicing.search_invoices.list(
recipient_email="string_example",
recipient_first_name="string_example",
recipient_last_name="string_example",
recipient_business_name="string_example",
invoice_number="string_example",
status=[
"string_example"
],
reference="string_example",
currency_code="aaa",
memo="string_example",
total_amount_range={
"lower_amount": {
"currency_code": "currency_code_example",
"value": "-.2888001528021798096225500850",
},
,
},
invoice_date_range={
"start": "0480-08-03",
"end": "0480-08-03",
},
due_date_range={
"start": "0480-08-03",
"end": "0480-08-03",
},
payment_date_range={
"start": "0480-08-03t01:32:60.79809622550085076206862933933397565068513910269129173272947860148202650912727550417577019298Z",
"end": "0480-08-03t01:32:60.79809622550085076206862933933397565068513910269129173272947860148202650912727550417577019298Z",
},
creation_date_range={
"start": "0480-08-03t01:32:60.79809622550085076206862933933397565068513910269129173272947860148202650912727550417577019298Z",
"end": "0480-08-03t01:32:60.79809622550085076206862933933397565068513910269129173272947860148202650912727550417577019298Z",
},
archived=True,
fields=[
"string_example"
],
page=1,
page_size=20,
total_required=False,
)Filters the search by the email address.
Filters the search by the recipient first name.
Filters the search by the recipient last name.
Filters the search by the recipient business name.
Filters the search by the invoice number.
status: List[InvoiceStatus]
An array of status values.
The reference data, such as a PO number.
currency_code: CurrencyCode
A private bookkeeping memo for the user.
total_amount_range: AmountRange
invoice_date_range: DateRange
due_date_range: DateRange
payment_date_range: DateTimeRange
creation_date_range: DateTimeRange
Indicates whether to list merchant-archived invoices in the response. Value is:
true. Response lists only merchant-archived invoices.false. Response lists only unarchived invoices.null. Response lists all invoices.
fields: SearchDataFields
The page number to be retrieved, for the list of templates. So, a combination of page=1 and page_size=20 returns the first 20 templates. A combination of page=2 and page_size=20 returns the next 20 templates.
The maximum number of templates to return in the response.
Indicates whether the to show total_pages and total_items in the response.
SearchData
The invoice search can be used to retrieve the invoices based on the search parameters.
/v2/invoicing/search-invoices post
π Back to Table of Contents
Creates an invoice template. You can use details from this template to create an invoice. You can create up to 50 templates.
Note: Every merchant starts with three PayPal system templates that are optimized for the unit type billed. The template includesQuantity,Hours, andAmount.
create_template_response = paypalinvoicing.templates.create_template(
id="string_example",
name="a",
default_template=True,
template_info={
},
settings={
},
unit_of_measure="QUANTITY",
standard_template=True,
links=[
{
"href": "href_example",
"rel": "rel_example",
"method": "GET",
}
],
)The ID of the template.
The template name.
Note: The template name must be unique.
Indicates whether this template is the default template. A invoicer can have one default template.
template_info: TemplateInfo
settings: TemplateSettings
unit_of_measure: UnitOfMeasure
Indicates whether this template is a invoicer-created custom template. The system generates non-custom templates.
An array of request-related HATEOAS links.
/v2/invoicing/templates post
π Back to Table of Contents
Deletes a template, by ID.
paypalinvoicing.templates.delete_by_id(
template_id="template_id_example",
)The ID of the template to delete.
/v2/invoicing/templates/{template_id} delete
π Back to Table of Contents
Lists merchant-created templates with associated details. The associated details include the emails, addresses, and phone numbers from the user's PayPal profile.
The user can select which values to show in the business information section of their template.
list_details_response = paypalinvoicing.templates.list_details(
fields="all",
page=1,
page_size=20,
)The fields to return in the response. Value is all or none. To return only the template name, ID, and default attributes, specify none.
The page number to be retrieved, for the list of templates. So, a combination of page=1 and page_size=20 returns the first 20 templates. A combination of page=2 and page_size=20 returns the next 20 templates.
The maximum number of templates to return in the response.
/v2/invoicing/templates get
π Back to Table of Contents
Shows details for a template, by ID.
show_details_by_id_response = paypalinvoicing.templates.show_details_by_id(
template_id="template_id_example",
)The ID of the template to delete.
/v2/invoicing/templates/{template_id} get
π Back to Table of Contents
Fully updates a template, by ID. In the JSON request body, include a complete template object. This call does not support partial updates.
update_full_template_response = paypalinvoicing.templates.update_full_template(
template_id="template_id_example",
id="string_example",
name="a",
default_template=True,
template_info={
},
settings={
},
unit_of_measure="QUANTITY",
standard_template=True,
links=[
{
"href": "href_example",
"rel": "rel_example",
"method": "GET",
}
],
)The ID of the template to delete.
The ID of the template.
The template name.
Note: The template name must be unique.
Indicates whether this template is the default template. A invoicer can have one default template.
template_info: TemplateInfo
settings: TemplateSettings
unit_of_measure: UnitOfMeasure
Indicates whether this template is a invoicer-created custom template. The system generates non-custom templates.
An array of request-related HATEOAS links.
Template
A representation of changes to make in the template.
/v2/invoicing/templates/{template_id} put
π Back to Table of Contents
This Python package is automatically generated by Konfig
