All URIs are relative to https://connect.squareup.com
Method | HTTP request | Description |
---|---|---|
batchRetrieveOrders | POST /v2/locations/{location_id}/orders/batch-retrieve | BatchRetrieveOrders |
createOrder | POST /v2/locations/{location_id}/orders | CreateOrder |
payOrder | POST /v2/orders/{order_id}/pay | PayOrder |
searchOrders | POST /v2/orders/search | SearchOrders |
updateOrder | PUT /v2/locations/{location_id}/orders/{order_id} | UpdateOrder |
BatchRetrieveOrdersResponse batchRetrieveOrders(locationId, body)
BatchRetrieveOrders
Retrieves a set of Orders by their IDs. If a given Order ID does not exist, the ID is ignored instead of generating an error.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OrdersApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
OrdersApi apiInstance = new OrdersApi();
String locationId = "locationId_example"; // String | The ID of the orders' associated location.
BatchRetrieveOrdersRequest body = new BatchRetrieveOrdersRequest(); // BatchRetrieveOrdersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
BatchRetrieveOrdersResponse result = apiInstance.batchRetrieveOrders(locationId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrdersApi#batchRetrieveOrders");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
locationId | String | The ID of the orders' associated location. | |
body | BatchRetrieveOrdersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
CreateOrderResponse createOrder(locationId, body)
CreateOrder
Creates a new Order which can include information on products for purchase and settings to apply to the purchase. To pay for a created order, please refer to the Pay for Orders guide. You can modify open orders using the UpdateOrder endpoint. To learn more about the Orders API, see the Orders API Overview.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OrdersApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
OrdersApi apiInstance = new OrdersApi();
String locationId = "locationId_example"; // String | The ID of the business location to associate the order with.
CreateOrderRequest body = new CreateOrderRequest(); // CreateOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
CreateOrderResponse result = apiInstance.createOrder(locationId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrdersApi#createOrder");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
locationId | String | The ID of the business location to associate the order with. | |
body | CreateOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
PayOrderResponse payOrder(orderId, body)
PayOrder
Pay for an order using one or more approved payments, or settle an order with a total of `0`. The total of the `payment_ids` listed in the request must be equal to the order total. Orders with a total amount of `0` can be marked as paid by specifying an empty array of `payment_ids` in the request. To be used with PayOrder, a payment must: - Reference the order by specifying the `order_id` when creating the payment. Any approved payments that reference the same `order_id` not specified in the `payment_ids` will be canceled. - Be approved with delayed capture. Using a delayed capture payment with PayOrder will complete the approved payment. Learn how to pay for orders with a single payment using the Payments API.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OrdersApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
OrdersApi apiInstance = new OrdersApi();
String orderId = "orderId_example"; // String | The ID of the order being paid.
PayOrderRequest body = new PayOrderRequest(); // PayOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
PayOrderResponse result = apiInstance.payOrder(orderId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrdersApi#payOrder");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | The ID of the order being paid. | |
body | PayOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
SearchOrdersResponse searchOrders(body)
SearchOrders
Search all orders for one or more locations. Orders include all sales, returns, and exchanges regardless of how or when they entered the Square Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc). SearchOrders requests need to specify which locations to search and define a `SearchOrdersQuery` object which controls how to sort or filter the results. Your SearchOrdersQuery can: Set filter criteria. Set sort order. Determine whether to return results as complete Order objects, or as OrderEntry objects. Note that details for orders processed with Square Point of Sale while in offline mode may not be transmitted to Square for up to 72 hours. Offline orders have a `created_at` value that reflects the time the order was created, not the time it was subsequently transmitted to Square.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OrdersApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
OrdersApi apiInstance = new OrdersApi();
SearchOrdersRequest body = new SearchOrdersRequest(); // SearchOrdersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
SearchOrdersResponse result = apiInstance.searchOrders(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrdersApi#searchOrders");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | SearchOrdersRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json
UpdateOrderResponse updateOrder(body)
UpdateOrder
Updates an open Order by adding, replacing, or deleting fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated. An UpdateOrder request requires the following: - The `order_id` in the endpoint path, identifying the order to update. - The latest `version` of the order to update. - The sparse order containing only the fields to update and the version the update is being applied to. - If deleting fields, the dot notation paths identifying fields to clear. To pay for an order, please refer to the Pay for Orders guide. To learn more about the Orders API, see the Orders API Overview.
// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.OrdersApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");
OrdersApi apiInstance = new OrdersApi();
UpdateOrderRequest body = new UpdateOrderRequest(); // UpdateOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
try {
UpdateOrderResponse result = apiInstance.updateOrder(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrdersApi#updateOrder");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | UpdateOrderRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
- Content-Type: application/json
- Accept: application/json