• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Calculate order BETA

POST /v2/orders/calculate

Calculates an Order.

Name Description
order
Order

Required

The order to be calculated. Expects the entire order, not a sparse update.

proposed_rewards
OrderReward [ ]

Identifies one or more loyalty reward tiers to apply during order calculation. The discounts defined by the reward tiers are added to the order only to preview the effect of applying the specified reward(s). The reward(s) do not correspond to actual redemptions, that is, no rewards are created. Therefore, the reward ids are random strings used only to reference the reward tier.

Response Fields

Name Description
order
Order

The calculated version of the order provided in the request.

errors
Error [ ]

Any errors that occurred during the request.

Examples

You are viewing an old version of the API
POST /v2/orders/calculate
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
curl https://connect.squareup.com/v2/orders/calculate \
  -X POST \
  -H 'Square-Version: 2020-09-23' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "idempotency_key": "b3e98fe3-b8de-471c-82f1-545f371e637c",
    "order": {
      "location_id": "D7AVYMEAPJ3A3",
      "discounts": [
        {
          "name": "50% Off",
          "percentage": "50",
          "scope": "ORDER"
        }
      ],
      "line_items": [
        {
          "name": "Item 1",
          "quantity": "1",
          "base_price_money": {
            "amount": 500,
            "currency": "USD"
          }
        },
        {
          "name": "Item 2",
          "quantity": "2",
          "base_price_money": {
            "amount": 300,
            "currency": "USD"
          }
        }
      ]
    }
  }'
Response JSON
{
  "order": {
    "location_id": "D7AVYMEAPJ3A3",
    "line_items": [
      {
        "uid": "ULkg0tQTRK2bkU9fNv3IJD",
        "quantity": "1",
        "name": "Item 1",
        "base_price_money": {
          "amount": 500,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 500,
          "currency": "USD"
        },
        "total_tax_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_discount_money": {
          "amount": 250,
          "currency": "USD"
        },
        "total_money": {
          "amount": 250,
          "currency": "USD"
        },
        "variation_total_price_money": {
          "amount": 500,
          "currency": "USD"
        },
        "applied_discounts": [
          {
            "uid": "9zr9S4dxvPAixvn0lpa1VC",
            "discount_uid": "zGsRZP69aqSSR9lq9euSPB",
            "applied_money": {
              "amount": 250,
              "currency": "USD"
            }
          }
        ]
      },
      {
        "uid": "mumY8Nun4BC5aKe2yyx5a",
        "quantity": "2",
        "name": "Item 2",
        "base_price_money": {
          "amount": 300,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 600,
          "currency": "USD"
        },
        "total_tax_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_discount_money": {
          "amount": 300,
          "currency": "USD"
        },
        "total_money": {
          "amount": 300,
          "currency": "USD"
        },
        "variation_total_price_money": {
          "amount": 600,
          "currency": "USD"
        },
        "applied_discounts": [
          {
            "uid": "qa8LwwZK82FgSEkQc2HYVC",
            "discount_uid": "zGsRZP69aqSSR9lq9euSPB",
            "applied_money": {
              "amount": 300,
              "currency": "USD"
            }
          }
        ]
      }
    ],
    "discounts": [
      {
        "uid": "zGsRZP69aqSSR9lq9euSPB",
        "name": "50% Off",
        "percentage": "50",
        "applied_money": {
          "amount": 550,
          "currency": "USD"
        },
        "type": "FIXED_PERCENTAGE",
        "scope": "ORDER"
      }
    ],
    "created_at": "2020-05-18T16:30:49.614Z",
    "updated_at": "2020-05-18T16:30:49.614Z",
    "state": "OPEN",
    "version": 1,
    "total_tax_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_discount_money": {
      "amount": 550,
      "currency": "USD"
    },
    "total_tip_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_money": {
      "amount": 550,
      "currency": "USD"
    },
    "total_service_charge_money": {
      "amount": 0,
      "currency": "USD"
    },
    "net_amounts": {
      "total_money": {
        "amount": 550,
        "currency": "USD"
      },
      "tax_money": {
        "amount": 0,
        "currency": "USD"
      },
      "discount_money": {
        "amount": 550,
        "currency": "USD"
      },
      "tip_money": {
        "amount": 0,
        "currency": "USD"
      },
      "service_charge_money": {
        "amount": 0,
        "currency": "USD"
      }
    }
  }
}

Share Feedback

Thanks for visiting the Square API documentation. What's on your mind?