Money
Every amount in the API is an integer in the currency’s minor unit, paired with an ISO 4217 currency code.
| You mean | You send |
|---|---|
| 45.00 SEK | {"value": 4500, "currency": "SEK"} |
| 129.90 NOK | {"value": 12990, "currency": "NOK"} |
| 9.95 EUR | {"value": 995, "currency": "EUR"} |
Always send whole numbers in minor units. A decimal such as 45.5 is rejected, and 45 means 0.45 kr, not 45 kr.
Showing amounts
Section titled “Showing amounts”Prices that LoyX returns carry two extra fields, so you can format them without hard-coding rules:
{ "value": 4500, "currency": "SEK", "minor_units": 100, "locale": "sv-SE" }minor_unitsis the divisor:4500 / 100 = 45.00.localeis the RFC 5646 locale to format with.sv-SEgives45,00 kr.
Totals are computed by LoyX
Section titled “Totals are computed by LoyX”On a sale you send line items with a unit price and a quantity. LoyX computes the line totals and the basket total itself, and ignores totals you send. A rounding difference in your system cannot change what the member earns.
If your system only knows what the customer paid, not the lines, send that amount as totals.paid_minor instead of items. See Record a sale.
Currencies
Section titled “Currencies”A brand’s program has one currency. Send sales in that currency. The API reference lists the accepted codes.