Not seeing the Discounts field in the returned payload after using the API to fetch an order

Hello,

I am retrieving orders using the php sdk and api version 43.2.0.20251016 with a sandbox account. In the documentation it shows that there should be a Discounts field returned with all of the discounts applied to the order or Null if no discounts are applied. But in what I am getting for the order this field is missing. Any idea why?

This is what I am getting back. I do not have an applied discount to this order but I used to be able to check for null (with the old php sdk) now there isn’t even a field.

array:1 [▼
  "order" => array:17 [▼
    "id" => "v889tQAPTbtMqb01ZK78vCRP4cNZY"
    "state" => "COMPLETED"
    "source" => array:1 [▶]
    "tenders" => array:1 [▶]
    "version" => 4
    "closed_at" => "2025-12-31T16:51:14.758Z"
    "created_at" => "2025-12-31T16:51:14.029Z"
    "line_items" => array:2 [▶]
    "updated_at" => "2025-12-31T16:51:15.000Z"
    "location_id" => "LTX4QSAAJJK0E"
    "net_amounts" => array:5 [▶]
    "total_money" => array:2 [▶]
    "total_tax_money" => array:2 [▶]
    "total_tip_money" => array:2 [▶]
    "net_amount_due_money" => array:2 [▶]
    "total_discount_money" => array:2 [▶]
    "total_service_charge_money" => array:2 [▶]
  ]
]

Little update I went back to check some of the old orders and they had this field

"orderDiscountArray": null

This is the full payload from the old order

+"id": "xxxxxxxx"
  +"locationId": "xxxxxxxx"
  +"created_at": "xxxxxxxxxx"
  +"orderDiscountArray": null
  +"lineItems": array:1 [▶]
  +"refund": null
  +"totalMoney": xxxxx
  +"taxMoney": 0
  +"discountMoney": 0
  +"tipMoney": 0
  +"tenders": array:1 [▶
    0 => {#1606 ▶}
  ]


Another edit. Does this have to do with adding the orders via the api and not making them through the app? IS it another sandbox issue?

Last edit:

I figured it out. The Discounts Key only shows up if there are discounts applied now unlike before when it would return NULL.

THanks

Don

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Apply Taxes, Discounts, and Service Charges
Apply Catalog Taxes to Orders
Payments API Integration

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Figured this out if anyone else is wondering the Discounts field is only provided if there are discounts applied. Unlike in previous version of the api where there was always a field and would just be set to NULL if there were not any discounts applied.

Glad to hear that you figured it out. :slight_smile:

Hello Don,

In the latest versions of the Square API and SDKs, fields that are not set or are empty are often omitted from the response to reduce payload size. This means that if no discounts are applied to an order, the discounts field might not appear in the response at all, rather than being present with a null value.

This behavior is consistent with how many modern APIs handle optional fields. If you need to check for the presence of discounts, you should first check if the discounts field exists in the response. If it does not exist, you can assume that no discounts were applied to the order.

If you have any further questions or need additional assistance, feel free to ask!

Best regards.

This answer was reviewed by @Bryan-Square.