SquareConnect\OrdersApi

May 28, 2020 · View on GitHub

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

MethodHTTP requestDescription
batchRetrieveOrdersPOST /v2/locations/{location_id}/orders/batch-retrieveBatchRetrieveOrders
calculateOrderPOST /v2/orders/calculateCalculateOrder
createOrderPOST /v2/locations/{location_id}/ordersCreateOrder
payOrderPOST /v2/orders/{order_id}/payPayOrder
searchOrdersPOST /v2/orders/searchSearchOrders
updateOrderPUT /v2/locations/{location_id}/orders/{order_id}UpdateOrder

batchRetrieveOrders

\SquareConnect\Model\BatchRetrieveOrdersResponse batchRetrieveOrders(locationid,location_id, 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

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$location_id = "location_id_example"; // string | The ID of the orders' associated location.
$body = new \SquareConnect\Model\BatchRetrieveOrdersRequest(); // \SquareConnect\Model\BatchRetrieveOrdersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->batchRetrieveOrders($location_id, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->batchRetrieveOrders: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
location_idstringThe ID of the orders' associated location.
body\SquareConnect\Model\BatchRetrieveOrdersRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\BatchRetrieveOrdersResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]

calculateOrder

Note: This endpoint is in beta.

\SquareConnect\Model\CalculateOrderResponse calculateOrder($body)

CalculateOrder

Calculates an Order.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$body = new \SquareConnect\Model\CalculateOrderRequest(); // \SquareConnect\Model\CalculateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->calculateOrder($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->calculateOrder: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
body\SquareConnect\Model\CalculateOrderRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\CalculateOrderResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]

createOrder

\SquareConnect\Model\CreateOrderResponse createOrder(locationid,location_id, 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

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$location_id = "location_id_example"; // string | The ID of the business location to associate the order with.
$body = new \SquareConnect\Model\CreateOrderRequest(); // \SquareConnect\Model\CreateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->createOrder($location_id, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
location_idstringThe ID of the business location to associate the order with.
body\SquareConnect\Model\CreateOrderRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\CreateOrderResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]

payOrder

Note: This endpoint is in beta.

\SquareConnect\Model\PayOrderResponse payOrder(orderid,order_id, 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

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$order_id = "order_id_example"; // string | The ID of the order being paid.
$body = new \SquareConnect\Model\PayOrderRequest(); // \SquareConnect\Model\PayOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->payOrder($order_id, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->payOrder: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
order_idstringThe ID of the order being paid.
body\SquareConnect\Model\PayOrderRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\PayOrderResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]

searchOrders

\SquareConnect\Model\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

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$body = new \SquareConnect\Model\SearchOrdersRequest(); // \SquareConnect\Model\SearchOrdersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->searchOrders($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->searchOrders: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
body\SquareConnect\Model\SearchOrdersRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\SearchOrdersResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]

updateOrder

Note: This endpoint is in beta.

\SquareConnect\Model\UpdateOrderResponse updateOrder(locationid,location_id, order_id, $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

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: oauth2
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new SquareConnect\Api\OrdersApi();
$location_id = "location_id_example"; // string | The ID of the order's associated location.
$order_id = "order_id_example"; // string | The ID of the order to update.
$body = new \SquareConnect\Model\UpdateOrderRequest(); // \SquareConnect\Model\UpdateOrderRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

try {
    $result = $apiInstance->updateOrder($location_id, $order_id, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrdersApi->updateOrder: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

NameTypeDescriptionNotes
location_idstringThe ID of the order's associated location.
order_idstringThe ID of the order to update.
body\SquareConnect\Model\UpdateOrderRequestAn object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

\SquareConnect\Model\UpdateOrderResponse

Authorization

oauth2

HTTP request headers

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

[Back to top] [Back to API list] [Back to Model list] [Back to README]