checkout_api = client.checkout
CheckoutApi
- Create Checkout
- Retrieve Location Settings
- Update Location Settings
- Retrieve Merchant Settings
- Update Merchant Settings
- List Payment Links
- Create Payment Link
- Delete Payment Link
- Retrieve Payment Link
- Update Payment Link
This endpoint is deprecated.
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.
def create_checkout(location_id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
location_id |
String |
Template, Required | The ID of the business location to associate the checkout with. |
body |
Create Checkout Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Create Checkout Response Hash
.
location_id = 'location_id4'
body = {
:idempotency_key => '86ae1696-b1e3-4328-af6d-f1e04d947ad6',
:order => {
:order => {
:location_id => 'location_id',
:reference_id => 'reference_id',
:customer_id => 'customer_id',
:line_items => [
{
:quantity => '2',
:name => 'Printed T Shirt',
:applied_taxes => [
{
:tax_uid => '38ze1696-z1e3-5628-af6d-f1e04d947fg3'
}
],
:applied_discounts => [
{
:discount_uid => '56ae1696-z1e3-9328-af6d-f1e04d947gd4'
}
],
:base_price_money => {
:amount => 1500,
:currency => 'USD'
}
},
{
:quantity => '1',
:name => 'Slim Jeans',
:base_price_money => {
:amount => 2500,
:currency => 'USD'
}
},
{
:quantity => '3',
:name => 'Woven Sweater',
: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',
:amount_money => {
:amount => 100,
:currency => 'USD'
},
:scope => 'LINE_ITEM'
}
]
},
:idempotency_key => '12ae1696-z1e3-4328-af6d-f1e04d947gd4'
},
: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',
:additional_recipients => [
{
:location_id => '057P5VYJ4A5X1',
:description => 'Application fees',
:amount_money => {
:amount => 60,
:currency => 'USD'
}
}
]
}
result = checkout_api.create_checkout(
location_id: location_id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Retrieves the location-level settings for a Square-hosted checkout page.
def retrieve_location_settings(location_id:)
Parameter | Type | Tags | Description |
---|---|---|---|
location_id |
String |
Template, Required | The ID of the location for which to retrieve settings. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Retrieve Location Settings Response Hash
.
location_id = 'location_id4'
result = checkout_api.retrieve_location_settings(location_id: location_id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Updates the location-level settings for a Square-hosted checkout page.
def update_location_settings(location_id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
location_id |
String |
Template, Required | The ID of the location for which to retrieve settings. |
body |
Update Location Settings Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Update Location Settings Response Hash
.
location_id = 'location_id4'
body = {
:location_settings => {}
}
result = checkout_api.update_location_settings(
location_id: location_id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Retrieves the merchant-level settings for a Square-hosted checkout page.
def retrieve_merchant_settings
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Retrieve Merchant Settings Response Hash
.
result = checkout_api.retrieve_merchant_settings
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Updates the merchant-level settings for a Square-hosted checkout page.
def update_merchant_settings(body:)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Update Merchant Settings Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Update Merchant Settings Response Hash
.
body = {
:merchant_settings => {}
}
result = checkout_api.update_merchant_settings(body: body)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Lists all payment links.
def list_payment_links(cursor: nil,
limit: nil)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
String |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. If a cursor is not provided, the endpoint returns the first page of the results. For more information, see Pagination. |
limit |
Integer |
Query, Optional | A limit on the number of results to return per page. The limit is advisory and the implementation might return more or less results. If the supplied limit is negative, zero, or greater than the maximum limit of 1000, it is ignored. Default value: 100 |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type List Payment Links Response Hash
.
result = checkout_api.list_payment_links
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Creates a Square-hosted checkout page. Applications can share the resulting payment link with their buyer to pay for goods and services.
def create_payment_link(body:)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Payment Link Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Create Payment Link Response Hash
.
body = {
:idempotency_key => 'cd9e25dc-d9f2-4430-aedb-61605070e95f',
:quick_pay => {
:name => 'Auto Detailing',
:price_money => {
:amount => 10000,
:currency => 'USD'
},
:location_id => 'A9Y43N9ABXZBP'
}
}
result = checkout_api.create_payment_link(body: body)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Deletes a payment link.
def delete_payment_link(id:)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The ID of the payment link to delete. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Delete Payment Link Response Hash
.
id = 'id0'
result = checkout_api.delete_payment_link(id: id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Retrieves a payment link.
def retrieve_payment_link(id:)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The ID of link to retrieve. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Retrieve Payment Link Response Hash
.
id = 'id0'
result = checkout_api.retrieve_payment_link(id: id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Updates a payment link. You can update the payment_link
fields such as
description
, checkout_options
, and pre_populated_data
.
You cannot update other fields such as the order_id
, version
, URL
, or timestamp
field.
def update_payment_link(id:,
body:)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The ID of the payment link to update. |
body |
Update Payment Link Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
This method returns a ApiResponse
instance. The data
property in this instance returns the response data which is of type Update Payment Link Response Hash
.
id = 'id0'
body = {
:payment_link => {
:version => 1,
:checkout_options => {
:ask_for_shipping_address => true
}
}
}
result = checkout_api.update_payment_link(
id: id,
body: body
)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end