const checkoutApi = client.checkoutApi;
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.
async createCheckout( locationId: string,
body: CreateCheckoutRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreateCheckoutResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
locationId |
string |
Template, Required | The ID of the business location to associate the checkout with. |
body |
CreateCheckoutRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const locationId = 'location_id4';
const body: CreateCheckoutRequest = {
idempotencyKey: '86ae1696-b1e3-4328-af6d-f1e04d947ad6',
order: {
order: {
locationId: 'location_id',
referenceId: 'reference_id',
customerId: 'customer_id',
lineItems: [
{
quantity: '2',
name: 'Printed T Shirt',
appliedTaxes: [
{
taxUid: '38ze1696-z1e3-5628-af6d-f1e04d947fg3',
}
],
appliedDiscounts: [
{
discountUid: '56ae1696-z1e3-9328-af6d-f1e04d947gd4',
}
],
basePriceMoney: {
amount: BigInt(1500),
currency: 'USD',
},
},
{
quantity: '1',
name: 'Slim Jeans',
basePriceMoney: {
amount: BigInt(2500),
currency: 'USD',
},
},
{
quantity: '3',
name: 'Woven Sweater',
basePriceMoney: {
amount: BigInt(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',
amountMoney: {
amount: BigInt(100),
currency: 'USD',
},
scope: 'LINE_ITEM',
}
],
},
idempotencyKey: '12ae1696-z1e3-4328-af6d-f1e04d947gd4',
},
askForShippingAddress: true,
merchantSupportEmail: '[email protected]',
prePopulateBuyerEmail: '[email protected]',
prePopulateShippingAddress: {
addressLine1: '1455 Market St.',
addressLine2: 'Suite 600',
locality: 'San Francisco',
administrativeDistrictLevel1: 'CA',
postalCode: '94103',
country: 'US',
firstName: 'Jane',
lastName: 'Doe',
},
redirectUrl: 'https://merchant.website.com/order-confirm',
additionalRecipients: [
{
locationId: '057P5VYJ4A5X1',
description: 'Application fees',
amountMoney: {
amount: BigInt(60),
currency: 'USD',
},
}
],
};
try {
const { result, ...httpResponse } = await checkoutApi.createCheckout(
locationId,
body
);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves the location-level settings for a Square-hosted checkout page.
async retrieveLocationSettings( locationId: string,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveLocationSettingsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
locationId |
string |
Template, Required | The ID of the location for which to retrieve settings. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
RetrieveLocationSettingsResponse
const locationId = 'location_id4';
try {
const { result, ...httpResponse } = await checkoutApi.retrieveLocationSettings(locationId);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Updates the location-level settings for a Square-hosted checkout page.
async updateLocationSettings( locationId: string,
body: UpdateLocationSettingsRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<UpdateLocationSettingsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
locationId |
string |
Template, Required | The ID of the location for which to retrieve settings. |
body |
UpdateLocationSettingsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
UpdateLocationSettingsResponse
const locationId = 'location_id4';
const body: UpdateLocationSettingsRequest = {
locationSettings: {},
};
try {
const { result, ...httpResponse } = await checkoutApi.updateLocationSettings(
locationId,
body
);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves the merchant-level settings for a Square-hosted checkout page.
async retrieveMerchantSettings(requestOptions?: RequestOptions): Promise<ApiResponse<RetrieveMerchantSettingsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
RetrieveMerchantSettingsResponse
try {
const { result, ...httpResponse } = await checkoutApi.retrieveMerchantSettings();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Updates the merchant-level settings for a Square-hosted checkout page.
async updateMerchantSettings( body: UpdateMerchantSettingsRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<UpdateMerchantSettingsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
UpdateMerchantSettingsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
UpdateMerchantSettingsResponse
const body: UpdateMerchantSettingsRequest = {
merchantSettings: {},
};
try {
const { result, ...httpResponse } = await checkoutApi.updateMerchantSettings(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Lists all payment links.
async listPaymentLinks( cursor?: string,
limit?: number,
requestOptions?: RequestOptions): Promise<ApiResponse<ListPaymentLinksResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
string | undefined |
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 |
number | undefined |
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 |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await checkoutApi.listPaymentLinks();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Creates a Square-hosted checkout page. Applications can share the resulting payment link with their buyer to pay for goods and services.
async createPaymentLink( body: CreatePaymentLinkRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<CreatePaymentLinkResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
CreatePaymentLinkRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const body: CreatePaymentLinkRequest = {
idempotencyKey: 'cd9e25dc-d9f2-4430-aedb-61605070e95f',
quickPay: {
name: 'Auto Detailing',
priceMoney: {
amount: BigInt(10000),
currency: 'USD',
},
locationId: 'A9Y43N9ABXZBP',
},
};
try {
const { result, ...httpResponse } = await checkoutApi.createPaymentLink(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Deletes a payment link.
async deletePaymentLink( id: string,
requestOptions?: RequestOptions): Promise<ApiResponse<DeletePaymentLinkResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The ID of the payment link to delete. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const id = 'id0';
try {
const { result, ...httpResponse } = await checkoutApi.deletePaymentLink(id);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves a payment link.
async retrievePaymentLink( id: string,
requestOptions?: RequestOptions): Promise<ApiResponse<RetrievePaymentLinkResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The ID of link to retrieve. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const id = 'id0';
try {
const { result, ...httpResponse } = await checkoutApi.retrievePaymentLink(id);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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.
async updatePaymentLink( id: string,
body: UpdatePaymentLinkRequest,
requestOptions?: RequestOptions): Promise<ApiResponse<UpdatePaymentLinkResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
id |
string |
Template, Required | The ID of the payment link to update. |
body |
UpdatePaymentLinkRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const id = 'id0';
const body: UpdatePaymentLinkRequest = {
paymentLink: {
version: 1,
checkoutOptions: {
askForShippingAddress: true,
},
},
};
try {
const { result, ...httpResponse } = await checkoutApi.updatePaymentLink(
id,
body
);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch (error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}