Applies to: Invoices API | Orders API | Customers API | Cards API
Learn how to create, configure, and publish invoices using the Invoices API.
Applications can use the Invoices API to request or collect payment from customers on behalf of a Square seller. First, call the CreateInvoice endpoint to create a draft invoice for an order (which must be created with the Orders API) and configure the payment schedule, recipient, and other invoice settings. Then, call the PublishInvoice endpoint to begin processing the invoice.
To create and publish an invoice, you must be prepared to provide the following information:
The ID of the associated order. If needed, call SearchOrders to get the order ID.
- The order status must be
OPEN
. - The order cannot include rewards.
- The order cannot use pricing rules (rule-based pricing options), which means that 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
. - The
treatment_type
of the service charge isn'tAPPORTIONED_TREATMENT
.
- The
- The order status must be
The ID of the customer profile that represents the invoice recipient. If needed, call SearchCustomers to get the customer ID.
- The customer profile must include
email_address
orphone_number
. An email address is required if the invoice is delivered by email or configured for automatic payment. - The invoice recipient can be the customer associated with the order or a different customer.
- The customer profile must include
The ID of a card on file if the invoice is configured for automatic payment. To obtain the card ID, call ListCards using the
customer_id
query parameter.The payment schedule for the invoice, list of payment methods accepted on the invoice payment page, and delivery method that Square should use to communicate with the recipient. For more information, see Configuring payment requests and Configuring how Square processes an invoice.
In addition, you should be aware of the following considerations:
An order can be associated with a single invoice, and an invoice can be associated with a single order. After an order is associated with an invoice, updates to the order are subject to restrictions.
Orders created from Square Online or other Square products cannot be associated with an invoice because they don't initially include an order ID.
To use custom fields or installment payments, the seller for whom you create the invoice must have an active (or trial) Invoices Plus subscription.
Invoice requirements and features might vary by location. For more information, see International availability and considerations.
When a customer ID is first specified for an invoice, Square retrieves contact information from the customer profile and adds it to the invoice. However, this recipient information isn't updated if the information changes in the Customer Directory.
The invoice recipient might not be the same customer associated with the underlying order or with any invoice payments.
For more information and other considerations, see Requirements and limitations.
Call CreateInvoice to create a draft invoice. Ensure that the requirements and limitations are met and provide the following information in the request:
order_id
with the ID of the associated order.primary_recipient.customer_id
with the ID of the customer who receives the invoice. This field isn't required to create the invoice, but it's required to publish the invoice.payment_requests
for the invoice, with one or more payment requests that equal thetotal_money
of the order. For more information, see Configuring payment requests.delivery_method
that Square should use to communicate with the recipient.accepted_payment_methods
that customers can use to pay the invoice on the invoice payment page. At least one of the following payment methods must be enabled:card
(credit or debit card)square_gift_card
bank_account
buy_now_pay_later
cash_app_pay
This setting is independent of any automatic payment requests for the invoice. Customers can choose to make a payment from the invoice payment page even when the invoice is configured for automatic payments.
An optional
idempotency_key
to ensure idempotency.
The following example request includes one BALANCE
payment request due by September 30, 2022:
Create invoice
You can also configure the invoice to be processed at a future date and configure reminders for before and after the due date. The following CreateInvoice
request directs Square to send the invoice on the scheduled_at
date and send a reminder 1 day before the payment due date.
Create invoice
The following is an example response. Note that the status
of the returned invoice is set to DRAFT
.
{
"invoice": {
"id": "inv:0-ChBoaXkM5QOPv9UO9C_Zexample",
"version": 0,
"location_id": "S8GWD5example",
"order_id": "AdSjVqPCzOAQqvTnzy46VLexample",
"payment_requests": [
{
"uid": "ccc0fc9b-c2a5-42a9-836d-92d01example",
"request_type": "BALANCE",
"due_date": "2022-09-30",
"tipping_enabled": false,
"computed_amount_money": {
"amount": 2699,
"currency": "USD"
},
"total_completed_amount_money":{
"amount":0,
"currency":"USD"
},
"reminders": [
{
"uid": "b0325b84-b231-4c8a-b3ca-d9e23example",
"relative_scheduled_days": -1,
"message": "Your invoice is due tomorrow",
"status": "PENDING"
}
],
"automatic_payment_source": "NONE"
}
],
"primary_recipient": {
"customer_id": "DJREAYPRBMSSFAB4TGAexample",
"given_name": "John",
"family_name": "Doe",
"email_address": "[email protected]"
},
"invoice_number": "000028",
"title": "My Invoice Title",
"scheduled_at": "2022-09-01T09:00:00Z",
"status": "DRAFT",
"timezone": "Etc/UTC",
"created_at": "2022-08-26T19:01:32Z",
"updated_at": "2022-08-26T19:01:32Z",
"accepted_payment_methods": {
"card": true,
"square_gift_card": true,
"bank_account": false,
"buy_now_pay_later": false,
"cash_app_pay": false
},
"delivery_method": "EMAIL",
"sale_or_service_date": "2022-08-24",
"store_payment_method_enabled": true
}
}
For more CreateInvoice
request examples, see Walkthrough: Create and Publish Invoices.
After an invoice is created, Square adds the following fields to each payment request:
computed_amount_money
with the amount of the payment request.total_completed_amount_money
with a zero amount, which represents the amount paid for the payment request. Square updates the amount after the payment request is paid.
When 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.
The following optional fields are commonly used in CreateInvoice
requests. For information about all optional invoices fields, see Invoice.
Field | Description |
---|---|
scheduled_at | The date to process the invoice and generate the invoice payment page, according to the delivery method and payment request settings. If not specified, Square processes the invoice immediately after it's published. |
reminders | Reminders for a payment request that Square should send relative to the due date (before or after). If the payment is made before the due date, Square doesn't send any remaining scheduled reminders. |
invoice_number | A user-friendly string that displays on the invoice. You might use the invoice number for client-side operations. If not specified, Square assigns a value. |
title | The invoice title that displays on the invoice. If not specified, the business name is used as the title. |
description | The description that displays on the invoice. |
sale_or_service_date | The date of the sale or the date when the service was rendered. This date displays on the invoice but doesn't drive any business logic. |
custom_fields | Up to two custom fields that display on the invoice. Custom fields require an Invoices Plus subscription. |
store_payment_method_enabled | Indicates whether to allow customers to save credit card, debit card, or bank transfer payment information when paying an invoice. The default value is false . When set to true , Square displays a Save my card on file or Save my bank on file checkbox on the invoice payment page. If the checkbox is selected, Square creates a card on file or a bank account on file for the customer using the information provided in the payment form. Stored payment information can be used for future automatic payments. Allowing customers to save gift cards on file for invoice payments isn't supported. |
To publish an invoice, call PublishInvoice provide the following information:
- The ID of the invoice to publish. The invoice must be in the
DRAFT
state. - The current
version
of the invoice. - An optional
idempotency_key
used to ensure idempotency.
You can use the id
and version
fields from the invoice returned in the CreateInvoice
response. If you need to get the ID and version, call SearchInvoices or ListInvoices. If you have the ID but need the version, call GetInvoice.
Important
When publishing invoices configured for card-on-file payments, the CUSTOMERS_READ
and PAYMENTS_WRITE
permissions are required in addition to ORDERS_WRITE
and INVOICES_WRITE
.
Publish invoice
The following is an example response:
{
"invoice": {
"id": "inv:0-ChBoaXkM5QOPv9UO9C_Zexample",
"version": 1,
"location_id": "S8GWD5example",
"order_id": "AdSjVqPCzOAQqvTnzy46VLexample",
"payment_requests": [
{
"uid": "ccc0fc9b-c2a5-42a9-836d-92d01example",
"request_type": "BALANCE",
"due_date": "2021-09-29",
"tipping_enabled": false,
"computed_amount_money": {
"amount": 2699,
"currency": "USD"
},
"total_completed_amount_money":{
"amount":0,
"currency":"USD"
},
"automatic_payment_source": "NONE",
"reminders": [
{
"uid": "b0325b84-b231-4c8a-b3ca-d9e23example",
"relative_scheduled_days": -1,
"message": "Your invoice is due tomorrow",
"status": "PENDING"
}
]
}
],
"invoice_number": "000028",
"title": "My Invoice Title",
"public_url": "https://squareupsandbox.com/pay-invoice/inv:0-ChBoaXkM5QOPv9UO9C_Zexample",
"next_payment_amount_money": {
"amount": 2699,
"currency": "USD"
},
"status": "UNPAID",
"timezone": "Etc/UTC",
"created_at": "2021-08-30T19:01:32Z",
"updated_at": "2021-08-30T19:05:01Z",
"primary_recipient": {
"customer_id": "DJREAYPRBMSSFAB4TGAexample",
"given_name": "John",
"family_name": "Doe",
"email_address": "[email protected]"
},
"accepted_payment_methods": {
"card": true,
"square_gift_card": true,
"bank_account": false,
"buy_now_pay_later": false,
"cash_app_pay": false
},
"delivery_method": "EMAIL",
"sale_or_service_date": "2021-08-24",
"store_payment_method_enabled": true
}
}
The status of the returned invoice depends on how the invoice is configured. For example, the status is SCHEDULED
if scheduled_at
is set to a future date or UNPAID
if the payment due_date
is set to a future date.
After an invoice is published and the scheduled_at
date (if specified) is reached, Square does the following:
Generates the invoice payment page where customers can make a payment.
Adds the
public_url
field with the payment page URL to the invoice.Adds the
next_payment_amount_money
field with the next payment amount due to the invoice, unless an automatic payment for the balance is completed immediately.Processes the invoice based on the invoice settings and handles the remaining workflow.
For example, Square can email the invoice, charge a card on file, or let you or the seller send the payment page URL to the customer. Square collects all invoice payments, either directly from customers (from the online payment page) or through automatic payments. Square also updates the invoice payment status and sends reminders and receipts as scheduled.
When the invoice is published, Square invokes invoice.published
and invoice.updated
webhook events, along with additional events if the invoice is configured to immediately collect an automatic payment. For more information, see Pay an invoice.
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 an Invoices Plus subscription) | 1 DEPOSIT and 2–12 INSTALLMENT |
All payments in installments (requires an Invoices Plus subscription) | 2–12 INSTALLMENT |
Deposit or installment payments can be specified by percentage or as a fixed amount. For percentage-based payments, Square computes the amount based on the total_money
amount of the order.
Note
For sellers who accept Afterpay (or Clearpay) payments, you can enable invoices to accept Buy Now Pay Later payments. For more information, see Buy Now Pay Later payments with Afterpay.
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:... "payment_requests": [ { "request_type":"BALANCE", "due_date":"2030-02-01" } ] ...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:... "payment_requests": [ { "request_type":"DEPOSIT", "due_date":"2030-02-01", "percentage_requested":"50" }, { "request_type":"BALANCE", "due_date":"2030-03-01" } ] ...This example contains two payment requests. The first is a
DEPOSIT
that uses thepercentage_requested
field to request 50% of the total amount of the order. The balance is for the remaining amount, which isn't explicitly specified.
Deposit with two installments (requires an Invoices Plus subscription)
A deposit can also be combined with 2–12 installment payments.
Percentage example
The following
payment_requests
example shows how to use thepercentage_requested
field to request a 50% deposit and the balance paid in two equal installments:... "payment_requests": [ { "request_type":"DEPOSIT", "due_date":"2030-02-01", "percentage_requested":"50" // 50% of total order amount }, { "request_type":"INSTALLMENT", "percentage_requested":"50", // 50% of remaining balance after deposit "due_date":"2030-03-01" }, { "request_type":"INSTALLMENT", "percentage_requested":"50", // 50% of remaining balance after deposit "due_date":"2030-04-01" } ] ...The percentage requested for the installments applies to the amount remaining after the deposit is paid. For an order with a total amount of $100, the invoice would request a $50 deposit, followed by two installments of $25 each.
Fixed amount example
Instead of percentages, you can use the
fixed_amount_requested_money
field to specify exact amounts for deposits and installments, as shown in the followingpayment_requests
example:... "payment_requests": [ { "request_type":"DEPOSIT", "due_date":"2030-07-30", "fixed_amount_requested_money":{ "amount":5000, // A $50 payment "currency":"USD" } }, { "request_type":"INSTALLMENT", "fixed_amount_requested_money":{ "amount":2500, // A $25 payment "currency":"USD" }, "due_date":"2030-08-30" }, { "request_type":"INSTALLMENT", "fixed_amount_requested_money":{ "amount":2500, // A $25 payment "currency":"USD" }, "due_date":"2030-09-30" } ] ...
The following considerations apply when configuring payment requests:
The
due_date
andrequest_type
fields must be specified for all payment requests.For
DEPOSIT
orINSTALLMENT
payment requests, either a percentage-based amount or a fixed amount must be specified.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 total payment amounts in
The
automatic_payment_source
field of the payment request indicates whether the request is configured for automatic payments. The following are valid values:Value Description 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 provide 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. The customer must approve each payment.
This value cannot be set from the Invoices API. It applies only to invoices that sellers create in Square products, such as the Square Dashboard.If an automatic payment fails, Square sends an invoice to the customer.
For each payment request, you can use the
reminders
field to schedule one or more reminders relative to thedue_date
of the payment. For more information, see InvoicePaymentReminder.Square sends reminders at 11:00 AM in the
timezone
of the invoice. If the payment is made before the scheduled reminder date, Square doesn't send the reminder.
After you publish an invoice, Square performs activities to manage the payment schedule (such as sending a reminder to the customer or initiating an automatic payment) based on invoice settings.
The following sections describe how to configure invoice settings to control how Square processes the invoice.
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 invoice payment page.- For each payment request, configure the following fields:
due_date
- Specify the due date of the payment.automatic_payment_source
- Keep the default value ofNONE
.request_type
,reminders
, and other payment fields - Specify as needed. For invoices with multiple payment requests, Square sends invoices and reminders according to the payment schedule. For more information, see Configuring payment requests and Automatic communication from Square.
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 invoice payment 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 due date of the payment. Square charges the card on file on this date.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 - Specify as needed. For invoices with multiple payment requests, Square sends invoices and reminders according to the payment schedule. For more information, see Configuring payment requests and Automatic communication from Square.
In this case, the seller or the application developer follows up with the customer. Square doesn't 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 invoice payment page.- For each payment request, configure the following fields:
due_date
- Specify the due date of the payment.automatic_payment_source
- Keep the default value ofNONE
.request_type
,reminders
, and other payment fields - Specify as needed. For more information, see Configuring payment requests.
Note
The following settings can be configured only from Square products:
SMS
(text message) delivery method - See additional SMS considerations.BANK_ON_FILE
automatic payment method.
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
.