ShopEazydevelopers
Concepts

Money, VAT and time

Amounts in minor units, VAT-inclusive prices, and timestamps in epoch milliseconds.

Money

Money is always an object with an integer amount in minor units and an ISO currency. Never a float.

{ "amount": 14900, "currency": "ZAR" }

That is R149,00. R19,99 is 1999.

  • Amounts are integers. Do the arithmetic in minor units and format at the last step.
  • Today a store's currency is ZAR. Read currency from the object rather than assuming it.
  • The Merchant API's dashboard figures come as strings that are already formatted. Do not work them out again.

To show an amount the way ShopEazy's own storefront does, with a space for thousands and a comma for cents, such as R1 234,50, the Storefront client has a helper:

import { formatMoney } from '@shopeazy/storefront-client';

formatMoney({ amount: 123450, currency: 'ZAR' }); // "R1 234,50"

VAT

Prices are VAT-inclusive at 15%. The price a shopper sees is the price they pay. VAT is never added on top.

An order's totals.tax is the VAT that is already inside totals.total. Read it from the API instead of working it out yourself.

{
  "subtotal": { "amount": 23000, "currency": "ZAR" },
  "discount": { "amount": 0, "currency": "ZAR" },
  "shipping": { "amount": 0, "currency": "ZAR" },
  "tax": { "amount": 3000, "currency": "ZAR" },
  "total": { "amount": 23000, "currency": "ZAR" },
  "paid": { "amount": 0, "currency": "ZAR" },
  "balanceDue": { "amount": 23000, "currency": "ZAR" }
}

Prices, titles and totals are always worked out on the server. Quote before you charge, and never send a price you computed.

Time

Timestamps are epoch milliseconds (integers), in UTC.

{ "createdAt": 1792636800000 }

Convert them to South African Standard Time (SAST, UTC+2) to show them to a merchant or shopper. South Africa has no daylight saving.

new Date(1792636800000).toLocaleString('en-ZA', { timeZone: 'Africa/Johannesburg' });

Where a time is not a timestamp

  • Booking availability. GET /v1/store/products/{slug}/availability groups open slots by date, a YYYY-MM-DD string in the store's timezone. The response names that timezone (for example Africa/Johannesburg). Each slot's at is an epoch millisecond timestamp.
  • Dates of birth on a membership application are YYYY-MM-DD.
  • Daily limits reset at 00:00 UTC, which is 02:00 in South Africa. See Rate limits.

On this page