Skip to content

Square: Calculate Order

Square orders.calculateOrder: arguments, response, policy and SDK examples.

← Orders operations · Get started

Operation square.calculateorder

Provider route: POST /v2/orders/calculate. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["orders"]["calculateOrder"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.orders.calculateOrder(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_square import SquareIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.orders.calculate_order(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
bodyModelRequired within parentExpand Calculate Order — request body — body

Referenced models: Calculate Order — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Calculate Order — response body

Referenced models: Calculate Order — response body

85 more schemas are linked from the tables above, on the schema pages.

Calculate Order — request body — body
FieldTypePresenceDescription and constraints
$objectRoot
orderModelRequired within parentExpand Create Order — request body — body order
The order to be calculated. Expects the entire order, not a sparse update.
proposed_rewardsJSONOptional
proposed_rewards (anyOf 1)arrayAlternativeIdentifies one or more loyalty reward tiers to apply during the order calculation.
The discounts defined by the reward tiers are added to the order only to preview the
effect of applying the specified rewards. The rewards do not correspond to actual
redemptions; that is, no `reward`s are created. Therefore, the reward `id`s are
random strings used only to reference the reward tier.
proposed_rewards (anyOf 1)[]ModelEach itemExpand Pay Order — response body — order rewards item
proposed_rewards (anyOf 2)nullAlternative

Referenced models: Create Order — request body — body order, Pay Order — response body — order rewards item

Calculate Order — response body
FieldTypePresenceDescription and constraints
$objectRoot
errorsarrayOptionalAny errors that occurred during the request.
errors[]ModelEach itemExpand Get Shift — response body — errors item
orderModelOptionalExpand Pay Order — response body — order
The calculated version of the order provided in the request.

Referenced models: Get Shift — response body — errors item, Pay Order — response body — order

Pay Order — response body — order rewards item
FieldTypePresenceDescription and constraints
$objectRootRepresents a reward that can be applied to an order if the necessary
reward tier criteria are met. Rewards are created through the Loyalty API.
idstringRequired within parentThe identifier of the reward.
Minimum length: 1
reward_tier_idstringRequired within parentThe identifier of the reward tier corresponding to this reward.
Minimum length: 1
Get Shift — response body — errors item
FieldTypePresenceDescription and constraints
$objectRootRepresents an error encountered during a request to the Connect API.

See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information.
categorystringRequired within parentIndicates which high-level category of error has occurred during a
request to the Connect API.
The high-level category for the error.
See [ErrorCategory](#type-errorcategory) for possible values
Known values: API_ERROR, AUTHENTICATION_ERROR, INVALID_REQUEST_ERROR, RATE_LIMIT_ERROR, PAYMENT_METHOD_ERROR, REFUND_ERROR, MERCHANT_SUBSCRIPTION_ERROR, EXTERNAL_VENDOR_ERROR
codeModelRequired within parentExpand Get Shift — response body — errors item code
The specific code of the error.
See [ErrorCode](#type-errorcode) for possible values
detailstringOptionalA human-readable description of the error for debugging purposes.
fieldstringOptionalThe name of the field provided in the original request (if any) that
the error pertains to.

Referenced models: Get Shift — response body — errors item code

Create Payment — request body — body tip money
FieldTypePresenceDescription and constraints
$objectRootRepresents an amount of money. `Money` fields can be signed or unsigned.
Fields that do not explicitly define whether they are signed or unsigned are
considered unsigned and can only hold positive amounts. For signed fields, the
sign of the value indicates the purpose of the money transfer. See
[Working with Monetary Amounts](https://developer.squareup.com/docs/build-basics/working-with-monetary-amounts)
for more information.
amountJSONOptional
amount (anyOf 1)JSONAlternative
amount (anyOf 1) (anyOf 1)integerAlternativeThe amount of money, in the smallest denomination of the currency
indicated by `currency`. For example, when `currency` is `USD`, `amount` is
in cents. Monetary amounts can be positive or negative. See the specific
field description to determine the meaning of the sign in a particular case.
Format: int64
Minimum: -9223372036854775808
Maximum: 9223372036854775807
amount (anyOf 1) (anyOf 2)stringAlternativePattern: ^(?:-(?:1[0-9]{18}|[2-8][0-9]{18}|9(?:0[0-9]{17}|1[0-9]{17}|2(?:0[0-9]{16}|1[0-9]{16}|2(?:0[0-9]{15}|[1-2][0-9]{15}|3(?:0[0-9]{14}|[1-2][0-9]{14}|3(?:0[0-9]{13}|[1-6][0-9]{13}|7(?:0[0-9]{12}|1[0-9]{12}|20(?:0[0-9]{10}|[1-2][0-9]{10}|3(?:0[0-9]{9}|[1-5][0-9]{9}|6(?:0[0-9]{8}|[1-7][0-9]{8}|8(?:0[0-9]{7}|[1-4][0-9]{7}|5(?:0[0-9]{6}|[1-3][0-9]{6}|4(?:0[0-9]{5}|[1-6][0-9]{5}|7(?:0[0-9]{4}|[1-6][0-9]{4}|7(?:0[0-9]{3}|[1-4][0-9]{3}|5(?:0[0-9]{2}|[1-7][0-9]{2}|80[0-8]))))))))))))))))|-[1-9][0-9]{0,17}|0|(?:1[0-9]{18}|[2-8][0-9]{18}|9(?:0[0-9]{17}|1[0-9]{17}|2(?:0[0-9]{16}|1[0-9]{16}|2(?:0[0-9]{15}|[1-2][0-9]{15}|3(?:0[0-9]{14}|[1-2][0-9]{14}|3(?:0[0-9]{13}|[1-6][0-9]{13}|7(?:0[0-9]{12}|1[0-9]{12}|20(?:0[0-9]{10}|[1-2][0-9]{10}|3(?:0[0-9]{9}|[1-5][0-9]{9}|6(?:0[0-9]{8}|[1-7][0-9]{8}|8(?:0[0-9]{7}|[1-4][0-9]{7}|5(?:0[0-9]{6}|[1-3][0-9]{6}|4(?:0[0-9]{5}|[1-6][0-9]{5}|7(?:0[0-9]{4}|[1-6][0-9]{4}|7(?:0[0-9]{3}|[1-4][0-9]{3}|5(?:0[0-9]{2}|[1-7][0-9]{2}|80[0-7]))))))))))))))))|[1-9][0-9]{0,17})$(?!\n)
amount (anyOf 2)nullAlternative
currencyJSONOptional
currency (anyOf 1)ModelAlternativeExpand Create Location — request body — body location currency
The type of currency, in __ISO 4217 format__. For example, the currency
code for US dollars is `USD`.

See [Currency](entity:Currency) for possible values.
See [Currency](#type-currency) for possible values
currency (anyOf 2)nullAlternative

Referenced models: Create Location — request body — body location currency

Create Order — request body — body order net amounts
FieldTypePresenceDescription and constraints
$objectRootA collection of various money amounts.
discount_moneyJSONOptional
discount_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The money associated with discounts.
discount_money (anyOf 2)nullAlternative
service_charge_moneyJSONOptional
service_charge_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The money associated with service charges.
service_charge_money (anyOf 2)nullAlternative
tax_moneyJSONOptional
tax_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The money associated with taxes.
tax_money (anyOf 2)nullAlternative
tip_moneyJSONOptional
tip_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The money associated with tips.
tip_money (anyOf 2)nullAlternative
total_moneyJSONOptional
total_money (anyOf 1)ModelAlternativeExpand Create Payment — request body — body tip money
The total money.
total_money (anyOf 2)nullAlternative

Referenced models: Create Payment — request body — body tip money

Pay Order — response body — order pricing options auto apply discounts, auto apply taxes
FieldTypePresenceDescription and constraints
$objectRootPricing options for an order. The options affect how the order's price is calculated.
They can be used, for example, to apply automatic price adjustments that are based on preconfigured
[pricing rules](entity:CatalogPricingRule).
auto_apply_discountsJSONOptional
auto_apply_discounts (anyOf 1)booleanAlternativeThe option to determine whether pricing rule-based
discounts are automatically applied to an order.
auto_apply_discounts (anyOf 2)nullAlternative
auto_apply_taxesJSONOptional
auto_apply_taxes (anyOf 1)booleanAlternativeThe option to determine whether rule-based taxes are automatically
applied to an order when the criteria of the corresponding rules are met.
auto_apply_taxes (anyOf 2)nullAlternative

SDK function policy ID: square.calculateorder. Catalog operation: CalculateOrder. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Square-Version": "2026-11-18"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.