Manage Invoices Using the Invoices API
The Square invoices platform enables sellers to request or automatically collect payments from their customers. Sellers can use the Square Seller Dashboard, Square Point of Sale (POS) application, and Square Invoices application to create and manage invoices. In addition to these first-party Square products, developers can use the Invoices API to integrate Square invoices into third-party applications.
On this page
Overview
You can use the Invoices API to create an invoice that requests payment for an order. Integrating the Invoices API into your application flow can help simplify the invoice management process and reduce your application development costs:
Square follows up with customers for the invoices you create, so you do not need to collect payments or send invoices, reminders, and receipts. By default, Square also emails invoice status and payment notifications to sellers.
Depending on the invoice settings you specify, Square can send the invoice or initiate an automatic payment, even when invoices are split into multiple payment requests. For more information, see Configuring how Square processes an invoice.
Square generates and hosts a web page where customers can easily pay the invoice. After each payment, Square sends a receipt to the customer and updates the invoice and associated order. For more information, see Pay an invoice.
All invoices require an order ID and a customer ID, which enables built-in integration with the Orders API and Customers API. For example, the Invoices API updates the order after a payment and retrieves the customer's contact information from the customer profile.
You can subscribe to receive webhook notifications about invoice events.
All invoices can be managed using the Invoices API or first-party Square products. However, note the following considerations:
To create an invoice with the Invoices API, the associated order must be created with the Orders API. You cannot use orders created from first-party Square products because they do not include an order ID, which is required by the
CreateInvoice
endpoint.Invoices created from first-party Square products do not include an
order_id
field unless a payment has been made on the invoice.The Invoices API does not support all invoice features that are available from first-party Square products. For example, you cannot set an
SMS
delivery method orBANK_ON_FILE
automatic payment method.
For additional considerations, see Requirements and Limitations.
How it works
The following high-level steps represent a typical workflow for using Square APIs to create an invoice:
Create an order by calling CreateOrder in the Orders API. Only orders created with the Orders API can be used to create an invoice with the Invoices API.
Get the customer ID of the invoice recipient. If the order includes a
customer_id
, you can use that customer ID or specify a different one. If needed, call SearchCustomers in the Customers API to search for a customer by phone number, email address, or other supported attribute.Create a draft invoice by calling
CreateInvoice
in the Invoices API. The invoice must contain one or more payment requests that define the payment schedule. For automatic payments from a card on file, you must specify thecard_id
for each payment request. For more information, including additional requirements, see Configuring payment requests and Create and publish an invoice.Publish the invoice by calling
PublishInvoice
in the Invoices API. The response includes thepublic_url
of the Square-hosted invoice page where customers can view and pay the invoice.After you publish the invoice, Square processes it based on the invoice settings and handles the remaining workflow. For example, Square can email the invoice, charge a card on file, or take no action if you or the seller want to follow up with the customer directly. For more information, see Configuring how Square processes an invoice.
Developers cannot use Square APIs to pay invoices or manage payment status. Therefore, no action is required from you after the invoice is published, unless you need to update the invoice, cancel the invoice, or refund the invoice.
Square manages automatic payments and payments that customers make from the invoice page. Square also updates the invoice payment status and sends reminders and receipts. For more information, see Pay an invoice.
Note
If sellers accept payment directly from customers, they can record the payment in the Seller Dashboard, POS application, or Square Invoices application.
Common Invoices API workflow
The following diagram shows the order of Invoices API requests that you use to manage an invoice and the webhook events invoked by each request:
After the invoice is published, Square processes it based on the invoice settings, generates the invoice payment page, adds the public_url
field to the invoice object, and manages payments and status. For more information, see Configuring how Square processes an invoice.
Note
The diagram does not include calls to Square APIs used to obtain required information (such as order_id
and customer_id
) or to the GetInvoice
, ListInvoices
, or SearchInvoices
endpoints used to access invoices.
Invoice object
The Invoice object is the core component of the Invoices API. Consider the following draft invoice that requests a single payment of $12 by the due date:
The following table describes key invoice settings. For information about all available invoices settings, see Invoice.
Field | Description |
---|---|
order_id | The ID of the corresponding order that was created using the Orders API. You can create one invoice for each order. The total computed_amount_money amounts of all invoice payment requests equals the total_money of the order.To view itemization and other order information associated with the invoice, call RetrieveOrder using the order ID. For more information about orders integration, see Requirements and limitations. |
payment_requests | The payment schedule for the invoice. The example invoice contains one payment request for the full order amount, due by the specified date. Square calculates the following amounts and adds them to the invoice: • computed_amount_money is the amount due for the payment request.• total_completed_amount_money is the amount the customer has paid for the payment request. For more information, see Payment requests. |
delivery_method | The method Square uses to send invoices, reminders, or receipts to the customer. If set to SHARE_MANUALLY , Square does not send the invoice or receipt. |
scheduled_at | The date to process the invoice. If not specified, Square processes the invoice immediately after it is published. |
primary_recipient | The customer responsible for the invoice. You specify the customer ID for the invoice and Square retrieves additional information from the customer profile in the seller's Customer Directory. Note that the customer who receives the invoice can be different from the customer who placed the order. |
status | The invoice status. When an invoice is created, the status is set to DRAFT . You must publish the draft invoice for the customer to receive the invoice. You must also publish invoices that are scheduled to be processed at a later date. |
invoice_number | A user-friendly string that displays on the invoice. You might use the invoice number for client-side operations. If you do not provide a value, Square assigns one. Do not confuse this field with the Square-assigned invoice id used for requests to the Invoices API. |
version | The invoice version. When an invoice is created, the version is set to 0. Square increments this value each time the invoice changes. You must provide the current version of the invoice for PublishInvoice , UpdateInvoice , and CancelInvoice requests. You cannot perform actions on previous versions of the invoice. |
accepted_payment_methods | The payment methods that customers can use to pay the invoice on the Square-hosted invoice page. This setting is independent of any automatic payment requests for the invoice. It is also independent of the default Payment method setting that applies to invoices created in the Seller Dashboard. |
custom_fields | Up to two customer-facing, seller-defined custom fields. Custom fields require an Invoices Plus subscription. |
public_url | The URL of the Square-hosted invoice payment page. This field is added after the invoice is published. |
sale_or_service_date | The date of the sale or the date of the service. This display field appears on the invoice but does not drive any business logic. |
For more information, including additional requirements, see Create and publish an invoice.
Payment requests
The payment_requests
field defines the payment schedule for an invoice, which includes payment amounts, due dates, and other related settings. The example invoice in the previous section contains one payment request for the full order amount, but you can optionally split the invoice into multiple payment requests. A payment request is represented by the InvoicePaymentRequest object.
The following table shows possible payment scenarios and the corresponding request_type
combinations for the invoice payment requests.
Payment scenario | request_type combination |
---|---|
One payment in full | 1 BALANCE |
A deposit with the balance due later | 1 DEPOSIT and 1 BALANCE |
A deposit with remaining payments in installments (requires subscription) | 1 DEPOSIT and 2–12 INSTALLMENT |
All payments in installments (requires subscription) | 2–12 INSTALLMENT |
Note
Installment payments are supported only with an Invoices Plus subscription.
Deposit or installment payments can be specified by percentage or as a fixed amount.
Example payment requests
The following examples show how you can define payment scenarios in the payment_requests
field when you create an invoice:
One payment in full. The following
payment_requests
example shows how to request one payment in full:The single
BALANCE
payment request represents the total amount of the order.Deposit with balance due later. The following
payment_requests
example shows how to request a 50% deposit and the remaining 50% balance at a later date:The first
DEPOSIT
payment request indicates 50% of the total amount on the order. Therefore, the balance is for the remaining amount and is not explicitly specified.
Deposit with two installments. The following
payment_requests
example shows how to request a 50% deposit and the balance paid in two equal installments:The percentage requested for the installments applies to the amount remaining after the deposit is paid. Suppose the order is for $100. This invoice then requests a $50 deposit, followed by two installments of $25 each. Instead of percentages, you can specify exact (fixed) amounts for deposits and installments, as shown in the following
payment_requests
example:
Configuring payment requests
The following requirements and considerations apply when configuring payment requests:
The
due_date
andrequest_type
fields must be specified for all payment requests.For
DEPOSIT
orINSTALLMENT
payment requests, you can specify a percentage-based amount or a fixed amount.To specify a percentage-based amount, set the
percentage_requested
field.For a
DEPOSIT
request, base the percentage on the total order amount.For
INSTALLMENT
requests, base the percentage on the total order amount minus any deposit amount. The percentages of all installment payment requests must add up to 100%, as shown in the preceding example.Installment payments are supported only with an Invoices Plus subscription.
To specify a fixed amount, set the
fixed_amount_requested_money
field.The total payment amounts in
payment_requests
must equal thetotal_money
amount of the associated order.
The
automatic_payment_source
field of the payment request indicates whether the request is configured for automatic payments. The following are valid values:ValueDescription NONE
No automatic payment is configured. This is the default value. CARD_ON_FILE
Directs Square to charge the credit or debit card on file specified by the card_id
field of the payment request. To get a card ID, call ListCards and include thecustomer_id
.
To set up automatic payments from a card on file, you must set thedelivery_method
of the invoice toEMAIL
.BANK_ON_FILE
Directs Square to initiate a transfer from the bank account on file, which is provided by the customer during the payment flow.
This value cannot be set from the Invoices API. It applies only to recurring invoices that sellers create in first-party Square products. Invoices with a bank account payment can have only one payment request of typeBALANCE
.If an automatic payment fails, Square sends an invoice to the customer.
The minimum amount of a single payment request is 100 base units. For more information, see Minimum invoice amounts by currency.
Reminders are scheduled relative to the
due_date
of the payment request. For more information, see InvoicePaymentReminder. Square sends reminders at 11:00 AM in the timezone specified for the invoice.
Custom fields
You can use the Invoices API to add up to two custom fields to an invoice, each of which can be placed above or below the line items on the invoice. This enables sellers to customize their invoices by adding information such as their terms of service or refund policy. Custom fields are visible to sellers and buyers on the invoice Square-hosted invoice page and in emailed or PDF copies of invoices. They also display in the details pane of the invoice in the Seller Dashboard.
Note
Custom fields are supported only with an Invoices Plus subscription.
For example, this invoice includes a Special Offer custom field above the invoice line items and an Arrival instructions field below the invoice line items:
The following CreateInvoice
request creates an invoice similar to the preceding example:
The following considerations apply to custom fields:
If two custom fields use the same placement above or below line items, the custom fields are rendered in the order that they are specified.
In the
text
field, you can use\n
to render a new line. No other formatting characters are supported.You cannot use the Invoices API to store custom fields for an account. If you want to enable sellers to reuse custom fields for their invoices, you must define your own storage mechanism.
The Invoices API does not support sparse updates for custom fields. To update a custom field, you must provide the complete
custom_fields
list in the update request. For more information, see Update custom fields.Custom fields are supported only with an Invoices Plus subscription.
Manage invoices
This section describes how you can use the Invoices API to create and manage invoices for orders created using the Orders API.
Create and publish an invoice
Creating an invoice is a two-step process: first create a draft invoice and then publish it. Only after you publish the invoice does Square process it. For example, Square can email an invoice to the customer or charge the customer's card on file. You must also publish an invoice that you want to schedule for processing.
To create and publish an invoice, you must provide the following information:
The
order_id
of the associated order. An invoice can be associated with one order only.The order must be created using the Orders API.
The order status must be
OPEN
.The order cannot be associated with another invoice.
The order cannot include rewards.
The order cannot use rule-based pricing options. Therefore, the
pricing_options.auto_apply_discounts
andpricing_options.auto_apply_taxes
fields cannot be set totrue
.The order can include a service charge only if the
country
of the order location isCA
orUS
.Note
After an invoice is created, updates to the associated order are subject to restrictions. For more information, see Limitations with the Orders API integration.
The
customer_id
of the invoice recipient.This customer can be different than the customer who created the order. The customer ID is not required until you publish the invoice.
The customer profile must exist in the seller's Customer Directory and include either
email_address
orphone_number
. You can callListCustomers
orSearchCustomers
if you do not use the customer ID from the order.The customer profile must have a valid email address if the invoice is delivered by email, which includes invoices configured for automatic payments. Square uses this email address to send invoices, reminders, and receipts to the customer.
Note
After an invoice is created, the Invoices API does not update the contact information of the recipient if the name, phone number, or email address changes in the associated customer profile. For more information, see Limitations with the Customers API integration.
The
payment_requests
for the invoice, with one or more payment requests that equal thetotal_money
of the order. The Invoices API computes percentage-based payment amounts for the payment schedule based on thetotal_money
of the order. For more information, see Payment requests.The
accepted_payment_methods
that customers can use to pay the invoice on the Square-hosted invoice page. At least one payment method must be enabled. This setting is independent of any automatic payment requests for the invoice. Customers can choose to make a payment from the invoice page even when the invoice is configured for automatic payments. For supported payment methods, see InvoiceAcceptedPaymentMethods.
Step 1: Create a draft invoice
Call CreateInvoice to create a draft invoice, as shown in the following example request:
The request body provides the invoice details. In this example, the payment_requests
field specifies one payment request (of type BALANCE
) for the total order amount, due by the specified due date. In response, the Invoices API returns an invoice with status
set to DRAFT
.
You can also set reminders on a payment request. The following CreateInvoice
request directs Square to send a reminder to the customer one day before the due date. If the payment is made before the due date, Square does not send the reminder.
For more CreateInvoice
request examples, see Example Walkthrough: Create and Publish Invoices.
After an invoice is created, Square invokes an invoice.created
webhook event. The order.updated
event is also invoked after Square associates the order with the invoice.
Step 2: Publish the invoice
Call PublishInvoice to publish the draft invoice. In the request, you provide the invoice ID and current version.
You can get the ID and version from the invoice returned in the CreateInvoice
response. You can also call ListInvoices
to retrieve the ID and version or call GetInvoice
if you have the ID but need to retrieve the version.
The following is an example response:
When you publish an invoice, Square generates an invoice payment page and returns the page URL in the public_url
field. Then, Square uses the invoice settings to determine how to process the invoice. Square takes no action on draft invoices.
After an invoice is published, Square invokes invoice.published
and invoice.updated
webhook events, along with additional events if the invoice is configured to immediately charge the customer. For more information, see Pay an invoice.
Configuring how Square processes an invoice
After you publish an invoice, Square performs activities to manage the payment schedule, such as sending an invoice, reminder, or receipt to the customer, or initiating an automatic payment.
You can configure invoice settings to control how Square processes the invoice:
Option 1: Send an invoice to request payment. Square sends the customer an invoice requesting payment by the due date. Square also sends a receipt after a payment is made.
scheduled_at
. To send an invoice immediately after publishing, omit this field. Otherwise, specify the date to send the invoice.delivery_method
. SpecifyEMAIL
.accepted_payment_methods
. Specifytrue
for one or more payment methods that customers can use to pay the invoice on the Square-hosted invoice page.For each payment request, configure the following fields:
due_date
. Specify the date that the payment is due.automatic_payment_source
. Keep the default value ofNONE
.request_type
,reminders
, and other payment fields, as needed. For more information, see Payment requests. For invoices with multiple payment requests, Square sends invoices and reminders according to the payment schedule.
Option 2: Automatically charge a credit or debit card on file. If the invoice is published on the due date, Square charges the card on file and sends a receipt. If the payment is due later, Square sends an invoice notifying the customer about the upcoming automatic payment. On the due date, Square charges the card on file and sends a receipt.
scheduled_at
. To send the invoice or receipt immediately after publishing, omit this field. Otherwise, specify the date to send the invoice.delivery_method
. SpecifyEMAIL
.accepted_payment_methods
. Specifytrue
for one or more payment methods that customers can use to pay the invoice on the Square-hosted invoice page. This field is required even when the invoice is configured for automatic payments because customers can optionally make a payment from the invoice page.For each payment request, configure the following fields:
due_date
. Specify the date that the payment is due.automatic_payment_source
. SpecifyCARD_ON_FILE
.card_id
. Specify the ID of the card on file to charge. To get a card ID, call ListCards and provide thecustomer_id
.request_type
,reminders
, and other payment fields, as needed. For more information, see Payment requests. For invoices with multiple payment requests, Square sends invoices and reminders according to the payment schedule.
Option 3: Square takes no action. In this case, the seller or the application developer follows up with the customer. Square does not send the invoice or receipt to the customer.
delivery_method
. SpecifySHARE_MANUALLY
.accepted_payment_methods
. Specifytrue
for one or more payment methods that customers can use to pay the invoice on the Square-hosted invoice page.For each payment request, configure the following fields:
due_date
. Specify the date that the payment is due.automatic_payment_source
. Keep the default value ofNONE
.request_type
,reminders
, and other payment fields, as needed. For more information, see Payment requests.
Note
The following settings can be configured only from first-party Square products:
SMS
(text message) delivery method. See additional SMS considerations.BANK_ON_FILE
automatic payment method, which applies only to recurring invoices.
You cannot use the Invoices API to set these values, but you can use the Invoices API to change them. For example, you can change an SMS
invoice delivery method to EMAIL
or SHARE_MANUALLY
.
Automatic communication from Square to customers
The following table lists the events and conditions that determine when and how Square sends automated communications to customers. One important factor is the delivery method
of the invoice.
For
EMAIL
, Square sends emails to customers using the email address in theprimary_recipient
field of the invoice.For
SMS
, Square sends text messages to customers using the phone number in theprimary_recipient
field of the invoice.For
SHARE_MANUALLY
, Square does not send invoices or receipts to customers. It is the responsibility of the developer or seller to communicate with the customer regarding invoices and receipts. However, Square does send scheduled reminders to customers using the email address in theprimary_recipient
field of the invoice.
Event | Communication |
---|---|
Invoice published | Square sends an invoice after a successful PublishInvoice request. Invoices are sent on the scheduled_at date if one is specified; otherwise, they are sent immediately after the invoice is published.• For EMAIL , Square sends a copy of the invoice.• For SMS , Square sends a link to the Square-hosted invoice page.• For SHARE_MANUALLY , Square does not send invoices or receipts to the customer.Square also resends the invoice after PublishInvoice is called for an invoice that is already published. |
Scheduled reminder date reached | On the scheduled date, Square sends the reminder at 11:00 AM in the invoice's timezone. Note the following considerations: • For SMS , Square does not send reminders.• For SHARE_MANUALLY , Square emails scheduled reminders. The SHARE_MANUALLY delivery method does not apply to reminders.• An invoice can have multiple reminders scheduled for both before and after the payment due_date . If the payment is made before the scheduled reminder date, Square does not send the reminder. |
Payment made | Square sends the receipt after one of the following payment events: • A customer makes a payment on the Square-hosted invoice page. • An automatic payment was completed. For bank transfer payments (which cannot be configured through the API), Square also notifies the customer when a payment is initiated and when a payment fails after it is initiated. • A seller records a payment in the Seller Dashboard, POS application, or Square Invoices application and selects the Send receipt checkbox. • If delivery method is set to SHARE_MANUALLY , Square does not send invoices or receipts to the customer.Note: These are the only supported methods of payment. Square APIs cannot be used to pay invoices or set invoice status. For more information, see Pay an invoice. |
Automatic payment unsuccessful | Square sends the invoice by email and changes the automatic_payment_source field of the payment request to NONE . |
Invoice updated | Square notifies the customer that the invoice is updated after a successful UpdateInvoice request.• For EMAIL , Square sends the updated invoice.• For SMS , Square notifies the customer that the invoice is updated and includes a link to the Square-hosted invoice page.• For SHARE_MANUALLY , Square does not notify the customer. |
Invoice canceled | Square notifies the customer that the invoice is canceled after a successful CancelInvoice request.• For EMAIL , Square sends an invoice marked as canceled.• For SMS , Square notifies the customer that the invoice is canceled and includes a link to the Square-hosted invoice page, which is marked as canceled.• For SHARE_MANUALLY , Square does not notify the customer. |
Note
In the preceding table, communications sent in response to Square API requests also apply to corresponding actions that sellers make from the Seller Dashboard, POS application, or Square Invoices application.
Except for payments that are remitted directly to sellers, Square manages all payment flows and updates the status
, total_completed_amount_money
, and next_payment_amount_money
fields of the invoice as needed. Square APIs cannot be used to pay an invoice or the associated order.
Automatic communication from Square to sellers
Square notifies sellers about the following invoice-related events using email, unless noted otherwise.
A customer views the Square-hosted invoice page. This push notification is sent only to the Square Invoices mobile application.
An invoice or reminder is sent to the customer.
An invoice is updated or canceled.
A payment is made on the Square-hosted invoice page, or an automatic payment is completed.
These events include all invoice-related communications sent to customers. Sellers can manage their notification settings in the Seller Dashboard. For more information, see Edit Your Notification Settings in Manage Your Square Invoices.
Square also emails sellers after the following events:
Square encounters problems when attempting to communicate with customers using the email address or phone number recorded in the
primary_recipient
field of the invoice.The invoice is canceled due to suspicious activity.
A scheduled automatic invoice payment fails.
Sellers cannot unsubscribe from receiving these emails.
Update an invoice
You call UpdateInvoice to update an invoice. You can modify invoice fields, clear invoice fields, or do both.
In the request body, you provide one or both of the following:
A sparse
Invoice
object that contains only the fields you want to add or change, along with the new values.A
fields_to_clear
array with a comma-separated list of fields to remove.
Note
Updating a custom field is an exception. You must provide the complete custom_fields
list to add or change a custom field. For more information, see Update custom fields.
The following restrictions apply to updating an invoice in a DRAFT
state:
You cannot update the
order_id
orlocation_id
field.
The following restrictions apply to updating a published invoice:
You cannot update the
primary_recipient
,order_id
, orlocation_id
field.You cannot update an invoice in the
PAID
,REFUNDED
,CANCELED
, orFAILED
terminal states.You cannot update an invoice in the
PAYMENT_PENDING
state. You must wait for the payment to complete before you can update it. In addition, the seller or customer cannot initiate another payment for an invoice in this state.
When you update a published invoice, Square notifies the seller that the invoice was updated. Square might also notify the customer, depending on the invoice delivery method:
EMAIL
. Square sends an email to the customer.SMS
. Square sends a text message to the customer unless the customer has opted out of text message updates from Square invoices.SHARE_MANUALLY
. Square does not notify the customer.
You must provide the invoice ID and current version for all UpdateInvoice
requests. You can call ListInvoices
to retrieve the ID and version, or you can call GetInvoice
if you have the ID but need to retrieve the version.
After an invoice is updated, Square invokes an invoice.updated
webhook event.
Example 1: Update an invoice number and title
The following UpdateInvoice
request updates the title
and invoice_number
:
If these fields are not previously set, the update operation adds them to the invoice. The invoice version increments each time the invoice is updated.
Example 2: Update payment requests by removing the deposit request
Consider the following draft invoice that requests a deposit payment and a balance payment due at a later date. The invoice is configured to automatically charge a card on file and to accept credit and debit card payments on the Square-hosted invoice page.
The following UpdateInvoice
request removes the deposit payment request from the preceding invoice and allows customers to use a Square gift card to make a payment on the invoice page. Note the fields_to_clear
field, which specifies payment_requests[a17ee758-fb36-4226-a535-95916example]
as the field to remove. The uid
index value for payment_requests
identifies the specific payment request to remove.
The following is the updated draft invoice. It now requests only one automatic payment in full (no deposit) and accepts credit card, debit card, and Square gift card payments on the invoice page.
Example variation: Remove the deposit request and change the balance due date
Now consider the following variation. Suppose you want to remove the deposit payment request and also change the due date of the remaining balance payment request. In other words, you want to remove one payment request and update another.
In this case, the UpdateInvoice
request body must include:
A
payment_requests
field in theinvoice
object that specifies theuid
of the payment request to update, along with the new value for thedue_date
field.The
fields_to_clear
field that specifies theuid
of the payment request to remove.
Example 3: Remove and add payment requests
The following UpdateInvoice
request removes an existing payment request and adds two new payment requests:
Note the following:
fields_to_clear
identifies the specific payment request to remove by providing itsuid
value.invoice
specifiespayment_requests
without referring to any existinguid
value. Therefore, the Invoices API adds these payment requests. If you added auid
value to any of these payment requests, it would indicate you wanted to update the values of an existing payment request.
Example 4: Replace payment request percentages with exact amounts
Consider the following draft invoice that has two payment requests: a deposit of 20% and the remaining balance due at a later date. Here is an excerpt of the invoice:
Now suppose you want to specify the exact amount for these payment requests instead of percentages. These are two distinct updates to the same payment request:
Add a new
fixed_amount_requested_money
field.Remove the
percentage_requested
field.
The following UpdateInvoice
request performs both of these updates:
Both invoice
and fields_to_clear
specify the same uid
value. As a result, the specified update is applied to the same payment request:
invoice
adds thefixed_amount_requested_money
field.fields_to_clear
removes thepercentage_requested
field.
The updated invoice is shown:
Example 5: Update custom fields
Unlike other invoice fields, the Invoices API does not support using sparse updates to add or change custom fields. To make these changes, you must provide the complete custom_fields
list in the update request. For example, consider an invoice that includes the following custom fields:
Note
Custom fields are supported only with an Invoices Plus subscription.
If you want to change the label from "Rules" to "Terms and Conditions", the invoice
object in the request must include complete definitions for both custom fields. For example:
Omitting a custom field object or field from the request removes the object or field, or returns an error if the field is required. However, you can use the fields_to_clear
field if you want to remove all custom fields from the invoice. For example:
Cancel an invoice
You call CancelInvoice to cancel a published invoice. When you cancel an invoice, Square does the following:
Sends a notification to the customer, depending on the
delivery_method
setting:For
EMAIL
, Square sends an email notification.For
SMS
, Square sends a text message.For
SHARE_MANUALLY
, Square does not notify the customer.
Sets the
status
of the invoice toCANCELED
.Sets the
state
of the associated order toCANCELED
.Stops any automatic scheduled actions, such as emailing reminders or charging a card on file. Sellers cannot collect payments for a canceled invoice.
The following is an example CancelInvoice
request. You must provide the invoice ID and current version for all CancelInvoice
requests. You can call ListInvoices
to retrieve the ID and version or call GetInvoice
if you have the ID but need to retrieve the version.
The canceled invoice is returned in the response, as shown in the following example excerpt:
You cannot cancel invoices in the DRAFT
state or in the PAID
, REFUNDED
, CANCELED
, or FAILED
terminal state. Canceled invoices remain accessible in the seller account. The GetInvoice
, ListInvoices
, and SearchInvoices
requests return canceled invoices.
After an invoice is canceled, Square invokes an invoice.canceled
webhook event. The order.updated
event is also invoked after Square sets the associated order to the CANCELED
state.
Delete an invoice
You call DeleteInvoice to delete a draft invoice. You cannot delete published invoices, including those scheduled for processing at a later time. Deleted invoices are removed from the account and are not returned by GetInvoice
, ListInvoices
, or SearchInvoices
requests.
When you delete a draft invoice, Square changes the state
of the associated order to CANCELED
.
The following is an example DeleteInvoice
request. You must provide the invoice ID for all DeleteInvoice
requests. You can call ListInvoices
to retrieve the ID.
The following is an example response:
After an invoice is deleted, Square invokes an invoice.deleted
webhook event. The order.updated
event is also invoked after Square sets the associated order to the CANCELED
state.
Retrieve invoices
Use the GetInvoice
, ListInvoices
, or SearchInvoices
endpoint to retrieve invoices. You can retrieve a specific invoice, list invoices at a specific location, and search for invoices at a specific location for a specific customer.
Note
To view itemization and other order information associated with the invoice, call RetrieveOrder in the Orders API using the order_id
in the invoice.
Get an invoice by ID
Call GetInvoice if you know the invoice ID.
List invoices
Call ListInvoices to retrieve invoices at a specific location. The following example uses the limit
to specify a maximum page size
of three results. The default page size is 100.
The following is an excerpt of an example paged response:
When a response is truncated, the response includes a cursor
to use in the next ListInvoices
call. You add the cursor
query parameter in the request as shown:
Search invoices
Call SearchInvoices to retrieve invoices that match a specific query. You must provide a location ID, and you can optionally include a customer ID if you want to retrieve invoices for a specific customer at the specified location.
The following example request filters by a specific customer and location. In the current implementation, the SearchInvoices
endpoint supports only a single customer ID and a single location ID in the filter.
The following is an excerpt of an example response:
The following example request filters by a specific customer and location, and also sorts the results in order from oldest to newest:
The sort field INVOICE_SORT_DATE
works as follows:
If the invoice is a draft, it uses the invoice
created_at
date.If the invoice is scheduled for publication, it uses the
scheduled_at
date.If the invoice is published, it uses the invoice publication date.
Pay an invoice
Square APIs cannot be used to pay an invoice (or the associated order) or to manage payment status. Square manages all payment flows except when customers remit payment directly to sellers. In this case, sellers can record the direct payment using the Seller Dashboard, POS application, or Square Invoices application. Square then updates the status and payment amounts for the invoice and order accordingly.
When an invoice is published, Square generates and hosts a web page where the customer can pay the invoice. Square also adds the public_url
field containing the page URL to the invoice object (for example, https://squareup.com/pay-invoice/inv:0-ChBoaXkM5QOPv9UO9C_Z1baX2b
).
Square updates the invoice page for each invoice payment request, according to the payment schedule and any prior payments. In addition, if the invoice is configured for automatic payments, Square charges the specified card on file or initiates a bank transfer on the payment due date.
After an invoice payment is made, Square does the following:
Sets the invoice
status
toPAID
,PAYMENT_PENDING
, orPARTIALLY_PAID
and sets thetotal_completed_amount_money
of the payment request to the amount paid.Adds the
payment_id
and other payment information to thetenders
field of the associated order.Sets the order
state
toCOMPLETED
when the order is fully paid.Invokes an
invoice.payment_made
webhook event, along withorder.updated
,payment.created
, andpayment.updated
events.
If an automatic payment fails, Square does the following:
Sets the
automatic_payment_source
field of all payment requests for the invoice toNONE
.Emails an invoice to the customer that contains a link to the Square-hosted invoice page where the customer can pay the amount due.
Invokes an
invoice.scheduled_charge_failed
webhook event. Depending on the cause of the failure, Square might invoke payment events, such as apayment.created
with a status ofFAILED
. Error information indicating why the payment failed is not available in the webhook payload or corresponding payment. In this case, you or the seller might need to contact the customer.
Note
Square takes no explicit action if an invoice becomes overdue. However, you can schedule reminders to be delivered after the payment request due_date
if the payment is not made.
Sellers can view the invoice payment status in the Seller Dashboard, POS application, or Square Invoices application. To determine whether a payment request is overdue using the Invoices API, compare the total_completed_amount_money.amount
field to computed_amount_money.amount
.
Retrieving an invoice payment
Although Square APIs cannot be used to pay an invoice, you can retrieve the corresponding Payment
object after a payment is made. To do so, get the tender that represents the payment in the associated order.
Call GetInvoice to retrieve the invoice, if needed.
Copy the
order_id
from the response.Call RetrieveOrder to retrieve the order.
The following excerpt of an example response shows the
tenders
field:Copy the
id
of the tender that corresponds to the payment you want to retrieve.Call GetPayment. For the
payment_id
parameter, use the tenderid
that you copied in the previous step.
Note
Payments also appear on the Transactions page of the Seller Dashboard.
Refund an invoice
You can call the RefundPayment endpoint in the Refunds API to refund invoice payments.
The invoice status
must be PAID
, CANCELED
, or FAILED
to refund a payment. Invoices with a status of PARTIALLY_PAID
must be canceled using CancelInvoice
before they can be refunded.
After an invoice payment is refunded, Square invokes an invoice.refunded
webhook event, along with refund.created
, refund.updated
, payment.updated
, and order.created
(for the new order that Square creates for the refund) events. The inventory.count.updated
event is also invoked if the associated order was itemized using catalog objects and the seller configured the Inventory management for invoices setting to adjust inventory levels through invoices.
Refunding an invoice payment
To refund an invoice payment, you need the ID of the tender that was recorded for the payment on the associated order. An order can have multiple tenders. You must make a separate call to RefundPayment
for each tender that you want to refund.
Get the order ID from the invoice. To retrieve the invoice, call GetInvoice if you have the invoice ID or call ListInvoices or SearchInvoices if you do not have the ID. The following example request calls
GetInvoice
:Copy the
order_id
from the response.Get the tender ID from the order. To retrieve the order, call RetrieveOrder in the Orders API and provide the order ID.
The following excerpt of an example response shows the
tenders
field:Copy the
id
of the tender. This is the payment ID that you use to refund the payment. Also, note the amount paid for the tender, which is the maximum amount that you can refund for the payment.Refund the payment. Call RefundPayment in the Refunds API and provide the payment ID and the amount to refund.
The following is an example response:
After a refund is processed, the invoice status changes to REFUNDED
if the entire amount paid for the invoice is refunded or PARTIALLY_REFUNDED
if only a portion of the payment is refunded. The original order remains unchanged and set to the COMPLETED
status.
Note
Sellers can also refund invoice payments using the Seller Dashboard, POS application, and Square Invoices application.
Requirements and limitations
The following requirements, limitations, and other considerations apply when using the Invoices API.
Requirements
OAuth permissions. Applications that use OAuth and the Invoices API require the following OAuth permissions.
INVOICES_READ
to use the following endpoints:INVOICES_WRITE
andORDERS_WRITE
to use the following endpoints:CUSTOMERS_READ
andPAYMENTS_WRITE
to charge cards on file.
Your application uses these permissions to manage invoices on behalf of a seller. Depending on its functionality, your application might also require other Square permissions. For more information, see OAuth API Overview.
Location must be active. When creating an invoice, the location of the associated order must have an
ACTIVE
status. If you specify the optionallocation_id
field in aCreateInvoice
request, the value must match thelocation_id
of the order.Invoice recipient must be in the Customer Directory. The customer who receives the invoice must have a customer profile in the seller's Customer Directory. This customer is associated with the invoice using the
primary_recipient.customer_id
field. For more information about creating and managing customer profiles, see Keep Records of Customer Profiles.Seller account must be able to accept payments. The seller account must be set up to accept payments before Square can accept payments on any invoices. The Invoices API does not allow you to publish any invoices configured for automatic payments unless the seller is enabled to accept payments. For invoices scheduled for a future date, the Invoices API also cancels the order and deletes the invoice when the invoice is scheduled to be sent. This requirement also applies to testing with your own Square account in the production environment.
Minimum invoice amount. The minimum amount for an invoice payment request is 100 base units. For more information, see Minimum invoice amounts by currency.
App Marketplace requirements. If you intend to list your application on the Square App Marketplace, see the related Invoices API requirements.
Error handling for Invoices Plus features. Your application must be able to handle errors returned when attempting to create or update an invoice with custom fields or installment payments. These premium features are available only with an Invoices Plus subscription. For more information, see Premium features available with Invoices Plus.
Limitations
Limitations with the Orders API integration. Invoices are associated with an order through the
order_id
field of the invoice. You should be aware of the following considerations related to Orders API integration:When an invoice is canceled or deleted, Square also cancels the associated order by setting the order status to
CANCELED
.Orders that are associated with an invoice cannot be set to the
CANCELED
orCOMPLETED
state using the Orders API.Payment for the order must be made on the invoice. You cannot use Square APIs such as PayOrder or CreatePayment to process a payment for an order that is associated with an invoice. After the invoice is paid in full, Square sets the
state
field of the order toCOMPLETED
.After an order is associated with an invoice, you cannot update order fields that affect the order amount (or their child fields), such as:
line_items
taxes
discounts
To update these immutable fields, you must cancel the invoice, which also cancels the order. You can then create a new order and a new invoice. However, you can update order fields that do not affect the cart.
Invoices created using the Seller Dashboard, POS application, or Square Invoices application do not include the
order_id
field unless a payment has been made on the invoice. Invoices created using the Invoices API require the order ID and therefore always include the order ID.Invoices do not contain information about the order. For itemization and other order information, call
RetrieveOrder
using theorder_id
from the invoice.Only orders with locations in Canada or the United States can include a service charge at this time. For additional order-related requirements and limitations, see Create and publish an invoice.
Limitations with the Customers API integration. Invoices are associated with a customer profile through the
primary_recipient.customer_id
field of the invoice. You should be aware of the following considerations related to Customers API integration:The
InvoiceRecipient
object represents a snapshot of customer data retrieved from the associated customer profile. Square does not update the contact information of the recipient in response to changes in the associated customer profile. To update the customer profile information for a draft invoice, update the profile using the Customers API and then update the invoice by first clearing theprimary_recipient
field and then re-adding it.Invoice recipient fields cannot be updated after the invoice is published. However, Square does update the
customer_id
field if the associated customer profile is merged.Invoices are not automatically updated or canceled if the customer profile assigned as the invoice recipient is deleted from the Customer Directory. If the invoice has remaining scheduled payments, Square continues to send the invoice. Any remaining automatic payments fail, but the customer can still enter the payment information on the Square-hosted invoice page.
For more information about customer-related requirements and limitations, see Create and publish an invoice.
Payments and application fees. You should be aware of the following considerations related to payments and application fees:
Square APIs cannot be used to pay an invoice. Square manages invoice payment flows. For more information, see Pay an invoice.
Although Square APIs cannot be used to pay an invoice, you can call ListPayments or GetPayment using the tender ID from the order to retrieve the corresponding
Payment
object after a payment is made. Payments also appear on the Transactions page of the Seller Dashboard.A
BANK_ON_FILE
automatic payment method cannot be set using the Invoices API. This payment method applies only to recurring invoices that sellers create in first-party Square products.When a bank account payment is made on an invoice, the payment is shown in the
tenders
field of the associated order, which you can retrieve through the Orders API. However, bank account payments cannot be accessed or managed using the Payments API, Refunds API, or other Square APIs.Developers cannot collect application fees for invoices.
Unsupported first-party features. The Invoices API does not support some of the features available in the Square Seller Dashboard, Square Point of Sale application, and Square Invoices application. For example, you cannot use the Invoices API to create or configure the following features:
Color and logo customization for your email invoices and customer payment page.
Recurring invoices.
Invoice templates.
Estimates.
Bulk actions.
Automatic payments from a bank account on file.
Attaching a file to an invoice. The Invoices API preserves any existing attachments on an invoice but the API does not support accessing and modifying invoice attachments.
Adding or viewing a shipping address. You cannot add a shipping address to an invoice that you create with the Invoices API. In addition, the shipping address is not included in invoices that you retrieve with the Invoices API.
SMS
(text message) delivery method. Note that when an invoice is configured to use theSMS
delivery method, Square sends invoices and receipts but not reminders.Although you cannot use the Invoices API to specify
SMS
for the invoicedelivery_method
field, you can use the API to update other invoice fields or changedelivery_method
toEMAIL
orSHARE_MANUALLY
.You should be aware of the following considerations when an invoice is configured for SMS delivery, but the customer opted out of text message updates from Square invoices:
Square cannot send a text message to notify the customer about a change after the invoice is updated.
Calling the
PublishInvoice
endpoint for the invoice returns aBad Request
error.
International availability and considerations
The Invoices API is supported in the following countries: Australia, Canada, France, Ireland, Japan, Spain, the United Kingdom, and the United States. To use the Invoices API to create and manage invoices, the seller account must be activated in one of these countries.
You should be aware of the following location-specific considerations:
Minimum invoice amounts by currency. The minimum amount for an invoice payment request is 100 base units, as shown in the following table.
Currency Base unit Minimum invoice amount AUD Cent $1.00 CAD Cent $1.00 EUR Cent 1.00 EUR GBP Pence £1.00 JPY Yen ¥100 USD Cent $1.00
Invoice recipient tax IDs. For sellers in EU countries and the United Kingdom, customer data for the invoice recipient can include a
tax_ids
field that contains the EU VAT identification number of the customer. This tax ID is displayed on the invoice.The following excerpt shows an example invoice recipient that includes the
tax_ids
field:Similar to other
InvoiceRecipient
fields, the tax ID is retrieved from the associated customer profile and cannot be changed after the invoice is published.Order service charge. Only orders with locations in Canada or the United States can include a service charge at this time. Specifically, the location referenced by the
location_id
of the order or invoice must havecountry
set toCA
orUS
. This behavior aligns with the seller experience in the Square Seller Dashboard, Square Point of Sale application, and Square Invoices application.
Payment conditions field. The
payment_conditions
field is available only for sellers in France. This text field contains payment terms and conditions that are displayed on the invoice, such as late payment penalties and early payment discounts. This field is provided so that sellers in France can comply with requirements for documenting this information.The following excerpt shows an example invoice that includes the
payment_conditions
field. The field can contain up to 2000 characters and use\n
to render a new line. No other formatting characters are supported.If this field is included in
CreateInvoice
orUpdateInvoice
requests for other locations, Square returns the following error:Before attempting to set the
payment_conditions
field, you can call RetrieveMerchant and check the country of the seller account.
Premium features available with Invoices Plus
Square Invoices Plus is a monthly subscription plan that enables Square sellers to use premium invoice features. The following Invoices Plus features are supported by the Invoices API:
Custom fields
Installment payments (used for milestone-based payment schedules)
Note
All other invoice features currently supported by the Invoices API are available without a subscription. However, the Invoices API does not support all first-party invoice features.
When using premium features, you should be aware of the following considerations:
To create invoices with premium features, the seller for whom you create the invoice must have an active (or trial) Invoices Plus subscription. Support for premium features spans the lifetime of the invoice. Therefore, you can add premium features to invoices that were created while the subscription is active, even after the subscription expires.
Square APIs cannot be used to check for subscription status or whether an invoice supports premium features before sending the request.
Instead, you must implement error handling logic for
CreateInvoice
orUpdateInvoice
requests to catch the error returned if the invoice contains an unsupported feature. Then, you must remove any premium features from the invoice and retry the request. Specifically:custom_fields
must be empty or omitted.payment_requests
cannot contain a payment request of typeINSTALLMENT
.
The Invoices API returns
403 MERCHANT_SUBSCRIPTION_NOT_FOUND
for Square version 2021-08-18 or later and400 BAD_REQUEST
for earlier Square versions. For more information, see Migration notes.
Regardless of subscription status, the Invoices API returns the complete invoice in applicable responses and webhook notifications, including fields related to premium features.
Testing Invoices Plus features in the Sandbox
To test premium features and error handling in the Sandbox environment, you can subscribe to Invoices Plus in the Sandbox Seller Dashboard.
The following procedure describes how you can subscribe your default test account to Invoices Plus using a test credit card that is never charged. You must repeat these steps for each test account that you want to subscribe to Invoices Plus.
Open the Developer Dashboard.
In the Sandbox Test Accounts section, choose Open next to Default Test Account. This opens the Sandbox Seller Dashboard associated with the default test account.
After you sign in and open the Sandbox Seller Dashboard as described in the previous steps, navigate to the following page: https://squareupsandbox.com/dashboard/invoices/learn-more
Choose Try free for 30 days.
To make sure that the subscription does not expire after 30 days, provide test credit card information:
Open the Pricing & Subscriptions page for the account. From the main menu in the dashboard, choose Account & Settings, expand Business, and then choose Pricing & Subscriptions.
For the Invoices Plus subscription, choose Subscribe.
Enter the following credit card information, and then choose Subscribe:
For the name on the card, enter any name.
For the card number, enter 4111 1111 1111 1111.
For the CVV, enter 111.
For the expiration date, enter 12/40.
For the postal code, enter 22222 or a similar value for your locale.
If you already have a test credit card on file for the account, you can just choose Subscribe.
Note
In the production environment, each seller using your application must also have an active or trial Invoices Plus subscription to create invoices with premium features.
For more information about the Sandbox environment, see Sandbox Overview.
Webhooks
You can subscribe to webhook notifications for the following invoice events. All invoice events require the INVOICES_READ
permission.
Event | Description |
---|---|
invoice.created | A draft invoice was created. |
invoice.published | An invoice was published. This also applies to invoices that are published but scheduled to be processed at a later time. |
invoice.updated | An invoice was changed. This event is also invoked following invoice.published and invoice.canceled events. |
invoice.payment_made | A payment was made for an invoice. |
invoice.scheduled_charge_failed | A scheduled automatic payment has failed. |
invoice.canceled | An invoice was canceled. |
invoice.refunded | A refund was processed for an invoice. |
invoice.deleted | A draft invoice was deleted. A deleted invoice is removed entirely from the seller account and cannot be retrieved. |
Invoice event notifications include the invoice ID and the invoice object. The exception is invoice.deleted
, which does not include the invoice object.
The following is an example invoice.created
notification:
For more information about subscribing to events and validating notifications, see Square Webhooks Overview.
Migration notes
Premium features require an Invoices Plus subscription
Square Invoices Plus is a paid subscription plan that provides access to premium invoice features. The subscription includes access to the following features that are supported by the Invoices API and which were previously available without a subscription:
Custom fields
Installment payments
Effective date: September 8, 2021
To create invoices with premium features after the effective date, the seller for whom you are creating the invoice must have an active (or trial) Invoices Plus subscription. For more information, see Premium features available with Invoices Plus.
Note
This change applies across all Square versions for new invoices only. Invoices that were created before the effective date and have premium features can continue to use the features without a subscription. This support includes updating the invoice to add or change premium features.
Your application must implement error handling logic for CreateInvoice
or UpdateInvoice
requests that catches the error returned if the invoice contains an unsupported feature. Then, you must remove any premium features from the invoice and retry the request. Specifically:
custom_fields
must be empty or omitted.payment_requests
cannot contain a payment request of typeINSTALLMENT
.
The Invoices API returns one of the following error codes if the invoice contains an unsupported premium feature. The detail
message indicates whether the unsupported feature is custom fields or installment payments. For example, the following errors are returned for a request that contains unsupported installment payments:
Square version 2021-08-18 and later:
403 MERCHANT_SUBSCRIPTION_NOT_FOUND
Square version 2021-07-21 and earlier:
400 BAD REQUEST
New Invoice.accepted_payment_method
The Invoice.accepted_payment_method
field represents the payment methods that customers can use to make a payment on the Square-hosted invoice page.
In Square version 2021-04-21 and later, this field is required to create an invoice and is included in returned invoices. At least one payment method must be set to true
. For valid values, see InvoiceAcceptedPaymentMethods.
This setting is independent of any automatic payment requests for the invoice. It is also independent of the default Payment method setting that sellers can configure for invoices created from first-party Square products. The default Payment method setting cannot be accessed by the Invoices API.
Deprecated InvoicePaymentRequest.request_method
The InvoicePaymentRequest.request_method
field and corresponding InvoiceRequestMethod
enum are deprecated. Request method options are now represented by the following fields:
Invoice.delivery_method
specifies how Square should send invoices, reminders, and receipts to the customer. For valid values, see InvoiceDeliveryMethod.InvoicePaymentRequest.automatic_payment_source
specifies the payment method for an automatic payment. For valid values, see InvoiceAutomaticPaymentSource.
Deprecated in version: 2021-01-21
Retired in version: TBD
The Invoices API continues to accept request_method
in create and update requests until the field is retired, but you should use delivery_method
and automatic_payment_source
when possible. However, starting in version 2021-01-21, request_method
is not included in returned Invoice
objects. The API migrates request_method
options in responses as follows:
request_method | delivery_method | automatic_payment_source |
---|---|---|
NONE | ||
CHARGE_CARD_ON_FILE | CARD_ON_FILE | |
CHARGE_BANK_ON_FILE | BANK_ON_FILE | |
SHARE_MANUALLY | SHARE_MANUALLY | NONE |
SMS | SMS | NONE |
SMS_CHARGE_CARD_ON_FILE | SMS | CARD_ON_FILE |
SMS_CHARGE_BANK_ON_FILE | SMS | BANK_ON_FILE |
Note
The following read-only fields were added for backward compatibility:
CHARGE_BANK_ON_FILE
, added in version 2021-01-21.SMS
,SMS_CHARGE_CARD_ON_FILE
, andSMS_CHARGE_BANK_ON_FILE
, added in version 2021-03-17.
If you need more assistance, contact Developer Support or ask for help in the Developer Forums.