CheckoutApi checkoutApi = client.getCheckoutApi();
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.
CompletableFuture<CreateCheckoutResponse> createCheckoutAsync(
final String locationId,
final CreateCheckoutRequest body)
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. |
String locationId = "location_id4";
CreateCheckoutRequest body = new CreateCheckoutRequest.Builder(
"86ae1696-b1e3-4328-af6d-f1e04d947ad6",
new CreateOrderRequest.Builder()
.order(new Order.Builder(
"location_id"
)
.referenceId("reference_id")
.customerId("customer_id")
.lineItems(Arrays.asList(
new OrderLineItem.Builder(
"2"
)
.name("Printed T Shirt")
.appliedTaxes(Arrays.asList(
new OrderLineItemAppliedTax.Builder(
"38ze1696-z1e3-5628-af6d-f1e04d947fg3"
)
.build()
))
.appliedDiscounts(Arrays.asList(
new OrderLineItemAppliedDiscount.Builder(
"56ae1696-z1e3-9328-af6d-f1e04d947gd4"
)
.build()
))
.basePriceMoney(new Money.Builder()
.amount(1500L)
.currency("USD")
.build())
.build(),
new OrderLineItem.Builder(
"1"
)
.name("Slim Jeans")
.basePriceMoney(new Money.Builder()
.amount(2500L)
.currency("USD")
.build())
.build(),
new OrderLineItem.Builder(
"3"
)
.name("Woven Sweater")
.basePriceMoney(new Money.Builder()
.amount(3500L)
.currency("USD")
.build())
.build()
))
.taxes(Arrays.asList(
new OrderLineItemTax.Builder()
.uid("38ze1696-z1e3-5628-af6d-f1e04d947fg3")
.type("INCLUSIVE")
.percentage("7.75")
.scope("LINE_ITEM")
.build()
))
.discounts(Arrays.asList(
new OrderLineItemDiscount.Builder()
.uid("56ae1696-z1e3-9328-af6d-f1e04d947gd4")
.type("FIXED_AMOUNT")
.amountMoney(new Money.Builder()
.amount(100L)
.currency("USD")
.build())
.scope("LINE_ITEM")
.build()
))
.build())
.idempotencyKey("12ae1696-z1e3-4328-af6d-f1e04d947gd4")
.build()
)
.askForShippingAddress(true)
.merchantSupportEmail("[email protected]")
.prePopulateBuyerEmail("[email protected]")
.prePopulateShippingAddress(new Address.Builder()
.addressLine1("1455 Market St.")
.addressLine2("Suite 600")
.locality("San Francisco")
.administrativeDistrictLevel1("CA")
.postalCode("94103")
.country("US")
.firstName("Jane")
.lastName("Doe")
.build())
.redirectUrl("https://merchant.website.com/order-confirm")
.additionalRecipients(Arrays.asList(
new ChargeRequestAdditionalRecipient.Builder(
"057P5VYJ4A5X1",
"Application fees",
new Money.Builder()
.amount(60L)
.currency("USD")
.build()
)
.build()
))
.build();
checkoutApi.createCheckoutAsync(locationId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves the location-level settings for a Square-hosted checkout page.
CompletableFuture<RetrieveLocationSettingsResponse> retrieveLocationSettingsAsync(
final String locationId)
Parameter | Type | Tags | Description |
---|---|---|---|
locationId |
String |
Template, Required | The ID of the location for which to retrieve settings. |
RetrieveLocationSettingsResponse
String locationId = "location_id4";
checkoutApi.retrieveLocationSettingsAsync(locationId).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Updates the location-level settings for a Square-hosted checkout page.
CompletableFuture<UpdateLocationSettingsResponse> updateLocationSettingsAsync(
final String locationId,
final UpdateLocationSettingsRequest body)
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. |
UpdateLocationSettingsResponse
String locationId = "location_id4";
UpdateLocationSettingsRequest body = new UpdateLocationSettingsRequest.Builder(
new CheckoutLocationSettings.Builder()
.build()
)
.build();
checkoutApi.updateLocationSettingsAsync(locationId, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves the merchant-level settings for a Square-hosted checkout page.
CompletableFuture<RetrieveMerchantSettingsResponse> retrieveMerchantSettingsAsync()
RetrieveMerchantSettingsResponse
checkoutApi.retrieveMerchantSettingsAsync().thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Updates the merchant-level settings for a Square-hosted checkout page.
CompletableFuture<UpdateMerchantSettingsResponse> updateMerchantSettingsAsync(
final UpdateMerchantSettingsRequest body)
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. |
UpdateMerchantSettingsResponse
UpdateMerchantSettingsRequest body = new UpdateMerchantSettingsRequest.Builder(
new CheckoutMerchantSettings.Builder()
.build()
)
.build();
checkoutApi.updateMerchantSettingsAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Lists all payment links.
CompletableFuture<ListPaymentLinksResponse> listPaymentLinksAsync(
final String cursor,
final Integer limit)
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 |
checkoutApi.listPaymentLinksAsync(null, null).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Creates a Square-hosted checkout page. Applications can share the resulting payment link with their buyer to pay for goods and services.
CompletableFuture<CreatePaymentLinkResponse> createPaymentLinkAsync(
final CreatePaymentLinkRequest body)
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. |
CreatePaymentLinkRequest body = new CreatePaymentLinkRequest.Builder()
.idempotencyKey("cd9e25dc-d9f2-4430-aedb-61605070e95f")
.quickPay(new QuickPay.Builder(
"Auto Detailing",
new Money.Builder()
.amount(10000L)
.currency("USD")
.build(),
"A9Y43N9ABXZBP"
)
.build())
.build();
checkoutApi.createPaymentLinkAsync(body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Deletes a payment link.
CompletableFuture<DeletePaymentLinkResponse> deletePaymentLinkAsync(
final String id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The ID of the payment link to delete. |
String id = "id0";
checkoutApi.deletePaymentLinkAsync(id).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
Retrieves a payment link.
CompletableFuture<RetrievePaymentLinkResponse> retrievePaymentLinkAsync(
final String id)
Parameter | Type | Tags | Description |
---|---|---|---|
id |
String |
Template, Required | The ID of link to retrieve. |
String id = "id0";
checkoutApi.retrievePaymentLinkAsync(id).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});
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.
CompletableFuture<UpdatePaymentLinkResponse> updatePaymentLinkAsync(
final String id,
final UpdatePaymentLinkRequest body)
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. |
String id = "id0";
UpdatePaymentLinkRequest body = new UpdatePaymentLinkRequest.Builder(
new PaymentLink.Builder(
1
)
.checkoutOptions(new CheckoutOptions.Builder()
.askForShippingAddress(true)
.build())
.build()
)
.build();
checkoutApi.updatePaymentLinkAsync(id, body).thenAccept(result -> {
// TODO success callback handler
System.out.println(result);
}).exceptionally(exception -> {
// TODO failure callback handler
exception.printStackTrace();
return null;
});