Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
360 lines (235 loc) · 13.1 KB

OrdersApi.md

File metadata and controls

360 lines (235 loc) · 13.1 KB

SquareConnect.OrdersApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
batchRetrieveOrders POST /v2/orders/batch-retrieve BatchRetrieveOrders
calculateOrder POST /v2/orders/calculate CalculateOrder
createOrder POST /v2/orders CreateOrder
payOrder POST /v2/orders/{order_id}/pay PayOrder
retrieveOrder GET /v2/orders/{order_id} RetrieveOrder
searchOrders POST /v2/orders/search SearchOrders
updateOrder PUT /v2/orders/{order_id} UpdateOrder

batchRetrieveOrders

BatchRetrieveOrdersResponse batchRetrieveOrders(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 body = SquareConnect.OrdersApi.constructFromObject({}); // BatchRetrieveOrdersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

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

Parameters

Name Type Description Notes
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

calculateOrder

Note: This endpoint is in beta.

CalculateOrderResponse calculateOrder(body)

CalculateOrder

Calculates an Order.

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 = SquareConnect.OrdersApi.constructFromObject({}); // CalculateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

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

Parameters

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

Return type

CalculateOrderResponse

Authorization

oauth2

HTTP request headers

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

createOrder

CreateOrderResponse createOrder(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.

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 = SquareConnect.OrdersApi.constructFromObject({}); // CreateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

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

Parameters

Name Type Description Notes
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.

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 = SquareConnect.OrdersApi.constructFromObject({}); // String | The ID of the order being paid.

var body = SquareConnect.OrdersApi.constructFromObject({}); // 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

retrieveOrder

RetrieveOrderResponse retrieveOrder(orderId)

RetrieveOrder

Retrieves an Order by ID.

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 = SquareConnect.OrdersApi.constructFromObject({}); // String | The ID of the order to retrieve.

apiInstance.retrieveOrder(orderId).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 to retrieve.

Return type

RetrieveOrderResponse

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 = SquareConnect.OrdersApi.constructFromObject({}); // 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(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.

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 = SquareConnect.OrdersApi.constructFromObject({}); // String | The ID of the order to update.

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

apiInstance.updateOrder(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 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