• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Create checkout

POST /v2/locations/{location_id}/checkouts

Links a checkoutId to a checkout_page_url that customers are directed to in order to provide their payment information using a payment processing workflow hosted on connect.squareup.com.

NOTE: The Checkout API has been updated with new features. For more information, see Checkout API highlights. We recommend that you use the new CreatePaymentLink endpoint in place of this previously released endpoint.


Permissions
PAYMENTS_WRITE
ORDERS_WRITE
Try in API Explorer
Name Description
location_id
string

Required

The ID of the business location to associate the checkout with.

Name Description
idempotency_key
string

Required

A unique string that identifies this checkout among others you have created. It can be any valid string but must be unique for every order sent to Square Checkout for a given location ID.

The idempotency key is used to avoid processing the same order more than once. If you are unsure whether a particular checkout was created successfully, you can attempt it again with the same idempotency key and all the same other parameters without worrying about creating duplicates.

You should use a random number/string generator native to the language you are working in to generate strings for your idempotency keys.

For more information, see Idempotency.

Min Length 1 Max Length 192
order
CreateOrderRequest

Required

The order including line items to be checked out.

ask_for_shipping_address
boolean

If true, Square Checkout collects shipping information on your behalf and stores that information with the transaction information in the Square Seller Dashboard.

Default: false.

merchant_support_email
string

The email address to display on the Square Checkout confirmation page and confirmation email that the buyer can use to contact the seller.

If this value is not set, the confirmation page and email display the primary email address associated with the seller's Square account.

Default: none; only exists if explicitly set.

Max Length 254
pre_populate_buyer_email
string

If provided, the buyer's email is prepopulated on the checkout page as an editable text field.

Default: none; only exists if explicitly set.

Max Length 254
pre_populate_shipping_address
Address

If provided, the buyer's shipping information is prepopulated on the checkout page as editable text fields.

Default: none; only exists if explicitly set.

redirect_url
string

The URL to redirect to after the checkout is completed with checkoutId, transactionId, and referenceId appended as URL parameters. For example, if the provided redirect URL is http://www.example.com/order-complete, a successful transaction redirects the customer to:

http://www.example.com/order-complete?checkoutId=xxxxxx&referenceId=xxxxxx&transactionId=xxxxxx

If you do not provide a redirect URL, Square Checkout displays an order confirmation page on your behalf; however, it is strongly recommended that you provide a redirect URL so you can verify the transaction results and finalize the order through your existing/normal confirmation workflow.

Default: none; only exists if explicitly set.

Max Length 800
additional_recipients
ChargeRequestAdditionalRecipient [ ]

The basic primitive of a multi-party transaction. The value is optional. The transaction facilitated by you can be split from here.

If you provide this value, the amount_money value in your additional_recipients field cannot be more than 90% of the total_money calculated by Square for your order. The location_id must be a valid seller location where the checkout is occurring.

This field requires PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS OAuth permission.

This field is currently not supported in the Square Sandbox.

note
string

An optional note to associate with the checkout object.

This value cannot exceed 60 characters.

Max Length 60

Response Fields

Name Description
checkout
Checkout

The newly created checkout object associated with the provided idempotency key.

errors
Error [ ]

Any errors that occurred during the request.

Examples

You are viewing an old version of the API
POST /v2/locations/{location_id}/checkouts
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
  • Node.js
curl https://connect.squareup.com/v2/locations/location_id0/checkouts \
  -X POST \
  -H 'Square-Version: 2022-05-12' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "86ae1696-b1e3-4328-af6d-f1e04d947ad6",
    "redirect_url": "https://merchant.website.com/order-confirm",
    "order": {
      "idempotency_key": "12ae1696-z1e3-4328-af6d-f1e04d947gd4",
      "order": {
        "location_id": "location_id",
        "customer_id": "customer_id",
        "reference_id": "reference_id",
        "line_items": [
          {
            "name": "Printed T Shirt",
            "quantity": "2",
            "base_price_money": {
              "amount": 1500,
              "currency": "USD"
            },
            "applied_discounts": [
              {
                "discount_uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4"
              }
            ],
            "applied_taxes": [
              {
                "tax_uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3"
              }
            ]
          },
          {
            "name": "Slim Jeans",
            "quantity": "1",
            "base_price_money": {
              "amount": 2500,
              "currency": "USD"
            }
          },
          {
            "name": "Woven Sweater",
            "quantity": "3",
            "base_price_money": {
              "amount": 3500,
              "currency": "USD"
            }
          }
        ],
        "taxes": [
          {
            "uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3",
            "type": "INCLUSIVE",
            "percentage": "7.75",
            "scope": "LINE_ITEM"
          }
        ],
        "discounts": [
          {
            "uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
            "type": "FIXED_AMOUNT",
            "scope": "LINE_ITEM",
            "amount_money": {
              "amount": 100,
              "currency": "USD"
            }
          }
        ]
      }
    },
    "additional_recipients": [
      {
        "location_id": "057P5VYJ4A5X1",
        "description": "Application fees",
        "amount_money": {
          "amount": 60,
          "currency": "USD"
        }
      }
    ],
    "ask_for_shipping_address": true,
    "merchant_support_email": "merchant+support@website.com",
    "pre_populate_buyer_email": "example@email.com",
    "pre_populate_shipping_address": {
      "address_line_1": "1455 Market St.",
      "address_line_2": "Suite 600",
      "locality": "San Francisco",
      "administrative_district_level_1": "CA",
      "postal_code": "94103",
      "country": "US",
      "first_name": "Jane",
      "last_name": "Doe"
    }
  }'
Response JSON
{
  "checkout": {
    "id": "CAISEHGimXh-C3RIT4og1a6u1qw",
    "checkout_page_url": "https://connect.squareup.com/v2/checkout?c=CAISEHGimXh-C3RIT4og1a6u1qw&l=CYTKRM7R7JMV8",
    "ask_for_shipping_address": true,
    "merchant_support_email": "merchant+support@website.com",
    "pre_populate_buyer_email": "example@email.com",
    "pre_populate_shipping_address": {
      "address_line_1": "1455 Market St.",
      "address_line_2": "Suite 600",
      "locality": "San Francisco",
      "administrative_district_level_1": "CA",
      "postal_code": "94103",
      "country": "US",
      "first_name": "Jane",
      "last_name": "Doe"
    },
    "redirect_url": "https://merchant.website.com/order-confirm",
    "order": {
      "location_id": "location_id",
      "customer_id": "customer_id",
      "reference_id": "reference_id",
      "line_items": [
        {
          "name": "Printed T Shirt",
          "quantity": "2",
          "applied_taxes": [
            {
              "tax_uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3",
              "applied_money": {
                "amount": 103,
                "currency": "USD"
              }
            }
          ],
          "applied_discounts": [
            {
              "discount_uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
              "applied_money": {
                "amount": 100,
                "currency": "USD"
              }
            }
          ],
          "base_price_money": {
            "amount": 1500,
            "currency": "USD"
          },
          "total_tax_money": {
            "amount": 103,
            "currency": "USD"
          },
          "total_discount_money": {
            "amount": 100,
            "currency": "USD"
          },
          "total_money": {
            "amount": 1503,
            "currency": "USD"
          }
        },
        {
          "name": "Slim Jeans",
          "quantity": "1",
          "base_price_money": {
            "amount": 2500,
            "currency": "USD"
          },
          "total_money": {
            "amount": 2500,
            "currency": "USD"
          }
        },
        {
          "name": "Woven Sweater",
          "quantity": "3",
          "base_price_money": {
            "amount": 3500,
            "currency": "USD"
          },
          "total_money": {
            "amount": 10500,
            "currency": "USD"
          }
        }
      ],
      "taxes": [
        {
          "uid": "38ze1696-z1e3-5628-af6d-f1e04d947fg3",
          "type": "INCLUSIVE",
          "percentage": "7.75",
          "scope": "LINE_ITEM"
        }
      ],
      "discounts": [
        {
          "uid": "56ae1696-z1e3-9328-af6d-f1e04d947gd4",
          "type": "FIXED_AMOUNT",
          "scope": "LINE_ITEM",
          "amount_money": {
            "amount": 100,
            "currency": "USD"
          },
          "applied_money": {
            "amount": 100,
            "currency": "USD"
          }
        }
      ],
      "total_money": {
        "amount": 14503,
        "currency": "USD"
      },
      "total_tax_money": {
        "amount": 103,
        "currency": "USD"
      },
      "total_discount_money": {
        "amount": 100,
        "currency": "USD"
      }
    },
    "created_at": "2017-06-16T22:25:35Z",
    "version": 1,
    "additional_recipients": [
      {
        "location_id": "057P5VYJ4A5X1",
        "description": "Application fees",
        "amount_money": {
          "amount": 60,
          "currency": "USD"
        }
      }
    ]
  }
}

Error Descriptions

400 Bad request AMOUNT_TOO_HIGH

The requested payment amount is too high for the provided payment source.

>
403 Forbidden CARD_PROCESSING_NOT_ENABLED

The location provided in the API call is not enabled for credit card processing.

>
400 Bad request
{
  "errors": [
    {
      "code": "AMOUNT_TOO_HIGH",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}