Skip to content

Latest commit

 

History

History
270 lines (176 loc) · 11.3 KB

OrdersApi.md

File metadata and controls

270 lines (176 loc) · 11.3 KB

SquareConnect.OrdersApi

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

batchRetrieveOrders

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.OrdersApi();

var locationId = "locationId_example"; // String | The ID of the orders' associated location.

var body = new SquareConnect.BatchRetrieveOrdersRequest(); // BatchRetrieveOrdersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.batchRetrieveOrders(locationId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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.

Return type

BatchRetrieveOrdersResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

createOrder

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.OrdersApi();

var locationId = "locationId_example"; // String | The ID of the business location to associate the order with.

var body = new SquareConnect.CreateOrderRequest(); // CreateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createOrder(locationId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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.

Return type

CreateOrderResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

payOrder

Note: This endpoint is in beta.

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.OrdersApi();

var orderId = "orderId_example"; // String | The ID of the order being paid.

var body = new SquareConnect.PayOrderRequest(); // PayOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.payOrder(orderId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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.

Return type

PayOrderResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

searchOrders

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.OrdersApi();

var body = new SquareConnect.SearchOrdersRequest(); // SearchOrdersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.searchOrders(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
body SearchOrdersRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

SearchOrdersResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateOrder

Note: This endpoint is in beta.

UpdateOrderResponse updateOrder(locationId, orderId, 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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.OrdersApi();

var locationId = "locationId_example"; // String | The ID of the order's associated location.

var orderId = "orderId_example"; // String | The ID of the order to update.

var body = new SquareConnect.UpdateOrderRequest(); // UpdateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.updateOrder(locationId, orderId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
locationId String The ID of the order's associated location.
orderId String The ID of the order to update.
body UpdateOrderRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateOrderResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json