Skip to main content

Order Calculation Examples

This guide provides practical examples showing how to structure Order API payloads for common commerce scenarios including discounts, points redemption, coupons, and external loyalty programs. Endpoint: POST https://api.gameball.co/api/v4.0/integrations/orders Headers:

Field Definitions

Line Item Fields

Order Level Fields

Redemption Fields

Points are earned based on totalPaid only.

Calculation Formulas

Line Item Level

Order Level


Example 1: Basic Order

Scenario: Customer purchases items at full price with no discounts or redemptions applied.
The examples below show only the fields that change from Example 1. All other fields remain the same unless specified.

Example 2: Line Item Discount

Scenario: A specific item has a discount applied directly (e.g. item on sale). Tax is calculated on the full price and the discount is applied afterward.

Example 3: Order-Level Discount

Scenario: A commercial discount is applied to the entire order. Line items stay at full price.
Line items have discount: 0. The full discount is reflected at the order level via totalDiscount.

Example 4: Points Redemption

Scenario: Customer redeems Gameball points to pay part of the order via the hold/complete flow. Step 1: Hold Points (before order)
Response returns holdReference: "HOLD-ABC123" Step 2: Complete Order with holdReference

Example 5: Coupon

Scenario: Customer applies a Gameball coupon code via the lock/complete flow. Step 1: Lock Coupon (before order)
Response returns lockReference: "LOCK-XYZ789" Step 2: Complete Order with lockReference

Example 6: Mixed — Points + Commercial Discount + Coupon

Scenario: Customer has a commercial discount, redeems Gameball points, and applies a coupon — all in one order.
  • All discounts (commercial + points + coupon) are summed in totalDiscount
  • Gameball only uses totalPaid for earning points
  • The pointsHoldReference links the points redemption
  • The couponsLockReference links the coupon burn

Example 7: External Loyalty Program (e.g. Qitaf, Rajhi Points)

Scenario: Customer partially pays using a third-party loyalty program. This is treated as an order-level discount — no Gameball redemption is involved.
Do not use redemption or the redemption object for external loyalty programs. Include the redeemed amount in totalDiscount only. Customer earns Gameball points on totalPaid (475).

Example 8: Discount Types (Free, % Off, Fixed)

Scenario: The discount is applied after tax is calculated, so the discount value covers both the product price and its tax portion. This is common when a POS reduces the line total directly (e.g. “make this item free” or “30% off the final price”). The key rule: tax is calculated on the full price, and the discount value must include the tax portion that’s being given away.

8a — Free Item (Free Product)

Vitamin C is given for free as part of a promo. The line value is **300+300 + 45 tax = 345,sothediscountmustcoverall345**, so the discount must cover all 345.
The customer paid nothing for Vitamin C, so no points are earned on that line. Points are still earned on the Face Moisturizer ($230).

8b — 30% Off (Percentage Discount)

Same items with a 30% off promo on Vitamin C. The discount applies to price + tax: 30% × (300+300 + 45) = $103.50.

8c — Fixed Discount ($20 Off)

A flat $20 off discount is applied to Vitamin C (e.g. a 20-currency coupon code). The discount value is sent as-is — it already represents the amount taken off the customer’s final bill, tax included.
Whether the discount is a free product, a percentage, or a flat fixed amount, the rule is the same: the discount value already accounts for the tax portion — send it as-is. Gameball uses totalPaid to calculate points correctly in all three cases.

Summary Table


Key Takeaway

Points are calculated based on totalPaid only.Gameball doesn’t need to know the breakdown of discounts. Just send:
  • totalPrice (items + taxes, before discounts)
  • totalDiscount (sum of ALL discounts including external loyalty)
  • totalPaid (what customer actually paid)