Applies to: Checkout API | Orders API
Learn how to create a checkout for a Square order.
An application can generate a checkout page by specifying an order in a CreatePaymentLink request (see Checkout API). The following example request specifies an Order
object. For simplicity, the example specifies four ad hoc line items.
You can also use catalog items. Note that the catalog_object_id
refers to the CatalogItemVariation ID that’s associated with a particular line item in a transaction. For more information, see Create Orders.
Create payment link
After receiving the requests, Square creates an order, creates a checkout page, and returns the order_id
and URL
to the checkout page in the response. The following is an example response:
{
"payment_link": {
"id": "DT77WJMWL4Q72DL5",
"version": 1,
"description": "",
"order_id": "giFLhtoDkFd29kkccWYHzW2Bh3LZY",
"url": "https://sandbox.square.link/u/QKhT5kUc",
"created_at": "2022-03-16T01:59:01Z"
},
"related_resources": {
"orders": [
{
"id": "C0DMgui6YFmgyURVSRtxr4EShheZY",
"location_id": "{{LOCATION_ID}}",
"source": {
"name": "Test Online Checkout Application"
},
"line_items": [
{
"uid": "8YX13D1U3jO7czP8JVrAR",
"name": "Auto Detailing",
"quantity": "1",
"item_type": "ITEM",
"base_price_money": {
"amount": 12500,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 12500,
"currency": "USD"
},
"gross_sales_money": {
"amount": 12500,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 12500,
"currency": "USD"
}
}
],
"fulfillments": [
{
"uid": "bBpNrxjdQxGQP16sTmdzi",
"type": "DIGITAL",
"state": "PROPOSED"
}
],
"net_amounts": {
"total_money": {
"amount": 12500,
"currency": "USD"
},
"tax_money": {
"amount": 0,
"currency": "USD"
},
"discount_money": {
"amount": 0,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"created_at": "2022-03-03T00:53:15.829Z",
"updated_at": "2022-03-03T00:53:15.829Z",
"state": "DRAFT",
"version": 1,
"total_money": {
"amount": 12500,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
}
}
]
}
}
Applications can use the order ID to access the order details using the Orders API (RetrieveOrder endpoint).
The application can send the payment link to the buyer. The buyer experience is identical to what is described in Quick Pay Checkout.