Skip to content

Widget

The widget is a rewards shop that Luxorr hosts and you embed in your page. It shows the store’s gifts in your player’s language, priced in your brand’s coins for the player’s country, in the look that your team set for the brand. The player picks a gift, enters a delivery address, and confirms. Before Luxorr creates the order, it asks your server to debit the coins.

Use it when you want a shop on your site without building one. To build your own shop, use the rewards store API instead. To send one gift to one player, use personal links.

Requires:

  • A key with the REWARD_STORES scope.
  • A widget debit URL and at least one widget allowed origin on that key. Your Administrator sets both in the key form, in Settings > API access.
  • A LIVE or SCHEDULED rewards store that serves the player’s brand.
  • A webhook URL or a reader of the event feed, for refunds.

The following table shows what you build and what Luxorr does:

You build Luxorr does
One server call for each player visit, to open a session Shows the store, the gift pages, the address form, and the player’s order history
Two lines of HTML to embed the widget Checks the price, the stock, and the address
One debit endpoint Asks your endpoint to debit the coins, and then creates the order
Refunds on order.cancelled and widget.debit.voided Buys, packs, and delivers the gift

You hold the player’s balance, and Luxorr keeps none. The following table shows when your system moves the player’s coins:

When You do
Your debit endpoint receives widget.debit and approves it Deduct coinPrice from the player’s balance, once for each debitId.
widget.debit.voided arrives for a debitId that you deducted Refund that coinPrice, once. No order was created.
widget.debit arrives for a debitId that was already voided Decline it, and deduct nothing.
order.cancelled arrives for an order whose id is a debitId that you deducted Refund that order’s coinPrice, once.
Anything else Nothing.

A widget order’s id is the debitId of the debit that paid for it, so one record for each debitId covers both refunds. Refund each debitId at most once, whichever event arrives.

When a signed-in player opens your rewards page, your server opens a session for that player. Never call this from the browser, because it needs your key.

POST /v1/widget-sessions
Authorization: Bearer lxr_live_…
Content-Type: application/json
{
"storeId": "4b3a2918-0716-4f5e-8d4c-3b2a19080716",
"brandId": "0a6f2e1c-3b5d-4e7f-8a9b-0c1d2e3f4a5b",
"playerId": "player-123",
"country": "DE",
"locale": "de-DE",
"balance": "1200",
"prefill": {
"name": "Wendy Player",
"email": "[email protected]",
"phone": "+4915112345678",
"address": { "street": "Beispielstraße 12", "city": "Berlin", "postalCode": "10115" }
},
"customFields": [
{ "fieldId": "5c4b3a29-1807-4f6e-8d5c-4b3a29180746", "textValue": "player-123" }
],
"origin": "https://www.operator.example"
}

The following table describes each field:

Field Rules
storeId Required. A SCHEDULED or LIVE store that serves the brand. The widget shows a SCHEDULED store with its opening date, and the store takes no orders yet.
brandId Required. The player’s brand. The prices, the coin currency, and the widget’s look follow it.
playerId Required. Your own ID for the player, 1 to 128 characters. The debit call and the player’s widget orders carry it.
country Required. An ISO 3166-1 alpha-2 code. Prices and availability are for this country, and orders ship to it. The player can’t change it.
locale Optional. The widget’s language: one of tenant.locales in GET /me. Luxorr also writes the player’s status emails and the order’s productName in this language.
balance Optional. The player’s balance as a decimal string, shown in the widget’s header. It’s for display only: the debit answer updates it.
prefill Optional. The values that the address form starts with. The player can change them. Every field is optional.
customFields Answers to your own order fields, as on a store order. The player is never asked them, so you must answer every required field here.
origin The origin of the page that shows the widget, such as https://www.operator.example. The widget then opens on that origin only. Required if the key opens the widget on the site named in each session, and then it can be any origin. Otherwise optional, and it must be one of the key’s widget allowed origins. For more information, see Choose where the widget opens.

The API returns 201:

{
"token": "lxw_5f0c2a9e7b1d4e3f8a6c0b9d2e4f1a7c_3kTn9QeX1bV7wYp2LmZr8sHd4uFj6cAo0gNiKxEy5Rq",
"expiresAt": "2026-10-17T11:04:31Z",
"frameUrl": "https://gifts.luxorr.io/widget/v1/frame"
}

After you open a session, keep the following in mind:

  • Give token to the player’s page only. It lets that page act for that one player, in that one store, brand, and country.
  • Treat token as an opaque value. Pass it to the widget exactly as you received it, and don’t rely on its length or form. The widget never puts the token in a web address.
  • A session lasts 60 minutes, and you can’t extend it. Open a new one when it ends. For more information, see onSessionExpired in Options.
  • Each call opens a new session, so you don’t need an Idempotency-Key.
  • The session ends early if the key is revoked, or can no longer use the REWARD_STORES scope or the session’s brand, or if API access is turned off.

The following table lists the refusals:

Refusal Meaning
400 invalid_request A field is missing or invalid: storeId, brandId, playerId, country, a locale that isn’t enabled for your account, balance, a required custom field that you left out, or an origin that isn’t an origin or that the key doesn’t allow. errors[] names each.
403 insufficient_scope The key doesn’t have the REWARD_STORES scope.
422 widget_not_configured The key has no widget debit URL, or it opens the widget only on listed sites and lists none.
422 reward_store_not_found Your key can’t use this store, or the store isn’t SCHEDULED or LIVE.
422 brand_not_found The store doesn’t serve the brand, or your key can’t use it.

Load the script from the widget host, and mount the widget with the token:

<div id="rewards"></div>
<script src="https://gifts.luxorr.io/widget/v1/embed.js"></script>
<script>
LuxorrWidget.mount({ target: '#rewards', mode: 'inline', session: 'lxw_…' })
</script>

The page must be on an origin that the session allows. An origin is https://host or https://host:port, with no path, such as https://www.operator.example. The browser refuses to show the widget in a page on any other origin.

Your Administrator chooses one of the following in the key’s Where the Widget Opens setting:

Setting Where the widget opens origin when you open a session
Only the sites listed here On the key’s widget allowed origins, up to 10. Optional. If you send it, it must be one of them, and the widget opens on that origin only.
The site named in each session On the origin that each session names. The key lists no sites. Required. Any origin.

If you choose the site per session, keep the following in mind:

  • Take origin from your own list of sites, or from a host that your server has checked. Never pass on a value that the browser sent, such as an Origin or Referer header or a form field. Any site that gets a session for its own origin can show a signed-in player’s widget.
  • Protect the endpoint that opens sessions so that other sites can’t call it for your signed-in players. For example, check the request’s Origin header against your list of sites, and use same-site cookies.

The following table describes each mode:

mode What the player sees
inline The shop fills the element that target names, and grows with its content.
launcher A floating button in the corner of the page, in the brand’s look and on the side that your team chose. It opens the shop in a centered dialog over your page on a desktop, and full screen on a phone. target is ignored.

You choose the mode for each page. A page can mount both.

const widget = LuxorrWidget.mount({
target: '#rewards',
mode: 'inline',
session: 'lxw_…',
onSessionExpired: async () => {
const answer = await fetch('/rewards/session', { method: 'POST' })
return (await answer.json()).token
},
onOrderPlaced: ({ orderId, reference, coinPrice, balance }) => {},
onBalanceChanged: (balance) => {},
colorScheme: 'dark',
})

The following table describes each option:

Option Rules
target A CSS selector or an element. Required for inline.
mode Required. inline or launcher.
session Required. The token from Open a session, as you received it. mount throws an error if it isn’t one.
onSessionExpired Optional. Called when the session ends while the widget is open. Return a new token from your server, and the widget carries on without reloading the page. It’s also called if the widget hasn’t started 10 seconds after it got a token, and at most once every 10 seconds. If the widget hasn’t started after two tokens in a row, from this callback or from setSession, it stops asking and logs a console warning. The most likely causes are a page origin that isn’t one of the key’s widget allowed origins, or an invalid token. After that, each setSession call tries once more with its token. Without this option, the widget shows that the session expired.
onOrderPlaced Optional. Called after an order is created, with the order id, its reference (G-…), the coinPrice, and the new balance (or null).
onBalanceChanged Optional. Called with the balance that your debit endpoint returned, as a decimal string, or null. Update your own balance display with it.
colorScheme Optional. light, dark, or auto. Pass the mode your page is in, so the widget matches it. auto, or leaving it out, shows the brand’s default mode. Any other value is ignored, with a console error. See Light and dark mode.

mount returns { unmount(), open(), close(), setSession(token), setBalance(balance), setColorScheme(scheme) }:

  • open and close show and hide a launcher’s overlay.
  • setSession gives the widget a new token at any time. The widget uses it when its current session ends. It renews the session of the same player only. If a different player signs in on the page, call unmount, and then mount a new widget with that player’s token.
  • A value that isn’t a token from Open a session is ignored, with a console error.

The widget shows the balance that you sent when you opened the session, and the balance that your debit endpoint returns on each order. If the player’s balance changes for any other reason, such as a refund on order.cancelled or widget.debit.voided, or coins won elsewhere on your site, tell the widget:

widget.setBalance('1650')

balance is a decimal string, or null to hide it. The widget shows it at once, without reloading or opening a new session, and keeps it when you give it a new session for the same player. Any other value is ignored, with a console error.

Widgets on one page share a balance. If a page mounts more than one widget, for example inline and as a launcher, and their sessions are for the same player and brand, a balance change in one widget reaches the others. That includes an order placed in one widget, a debit answer, and setBalance on any of them. Widgets for another player or brand keep their own balance. Luxorr calls onOrderPlaced and onBalanceChanged only for the widget where the change happened, so a page with two widgets isn’t told twice.

If your page has a light and a dark mode, pass the current one as colorScheme when you mount the widget, and tell the widget each time the player switches:

widget.setColorScheme('light')

The widget and the launcher button change colors at once, without reloading. auto goes back to the brand’s default mode. Any other value is ignored, with a console error.

Your team chooses in Widget Style whether the brand offers both modes or only one. A brand that offers only one mode always shows it, whatever you pass.

When the player confirms an order, Luxorr checks the store, the price, the stock, and the address, and then sends a request to your widget debit URL:

POST https://wallet.operator.example/luxorr/debit
Content-Type: application/json
Luxorr-Signature: t=1760698800,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
{
"type": "widget.debit",
"debitId": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
"playerId": "player-123",
"brandId": "0a6f2e1c-3b5d-4e7f-8a9b-0c1d2e3f4a5b",
"storeId": "4b3a2918-0716-4f5e-8d4c-3b2a19080716",
"productId": "2f1e0d9c-8b7a-4695-a483-72615f4e3d2c",
"coinPrice": "450",
"currency": { "name": "Gold Coins", "symbol": "GC" },
"environment": "production"
}

To answer the debit, do the following:

  1. Verify Luxorr-Signature exactly as for a webhook, with the key’s webhook secret, on the raw body. Refuse an unsigned or stale request.
  2. Decline a voided debitId. If widget.debit.voided already arrived for this debitId, return approved: false with reason: "other", and move no coins. Luxorr gave up on that debit and creates no order for it.
  3. Use debitId as your idempotency key. If you already answered this debitId, return the same answer again, and move no coins.
  4. Check the player and the balance. If you approve, deduct coinPrice. Answer within 5 seconds. Luxorr doesn’t retry.

An approval looks like this:

{ "approved": true, "balance": "750", "reference": "tx-981" }

A refusal looks like this:

{ "approved": false, "reason": "insufficient_balance", "balance": "300" }

The following table describes each field of your answer:

Field Rules
approved Required. true after you deducted the coins, false if you didn’t.
balance Optional. The player’s balance after your decision, as a decimal string. The widget shows it, and onBalanceChanged receives it.
reference Optional, for an approval only. Your transaction ID, up to 128 characters. Luxorr stores it on the order.
reason For a refusal only. insufficient_balance, player_blocked, or other.

The following table shows what happens with each answer:

Your answer The order The widget
200, approved Created. It then follows your account’s approval setting, like any store order. The order reference and the new balance.
200, declined with insufficient_balance Not created. No stock is taken. That the player doesn’t have enough coins, with the balance that you sent.
200, declined with another reason Not created. That the player’s coins couldn’t be used, and that nothing was taken.
Anything else: a timeout, a status other than 200, or a body that isn’t this JSON Not created. Luxorr sends widget.debit.voided. That no order was placed, that any coins taken will be returned, and to try again.

The widget debit URL must use HTTPS and resolve to a public address.

widget.debit.voided tells you that Luxorr didn’t create an order for a debit that it asked for. Your answer didn’t arrive in time or couldn’t be read, or the order failed after you approved it, for example because the last unit sold in between.

{
"id": "0b7e5f3c-2a1d-4c6e-9f8a-7b6c5d4e3f21",
"type": "widget.debit.voided",
"occurredAt": "2026-10-17T10:05:02Z",
"environment": "production",
"data": {
"debitId": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
"playerId": "player-123",
"coinPrice": "450",
"currency": { "name": "Gold Coins", "symbol": "GC" },
"reason": "debit_outcome_unknown"
}
}

When a void arrives, keep the following in mind:

  • If you deducted coins for that debitId, refund them once. If you never deducted, for example because you declined or the call hasn’t reached you, move no coins.
  • Record every voided debitId, whether you deducted or not. Luxorr voids a debit if your answer didn’t arrive in time, so the call itself can still reach you later. Decline any widget.debit that carries a voided debitId, as in Answer the debit, so that a late call never takes coins for an order that wasn’t created.
  • reason is order_not_created (you approved, and then the order failed) or debit_outcome_unknown (Luxorr couldn’t read your answer).
  • Only the key that opened the session receives the void: as a webhook, signed and retried like every other, and in that key’s event feed. Your other keys never receive it, even if they have the REWARD_STORES scope and the same brand. Don’t revoke the key, or remove the brand from it, while voids might be pending. After that, no key can read those voids from the feed.
  • A declined debit sends nothing, because you moved no coins.

A widget order is a store order that the key that opened the session placed. It sends order.approved, order.cancelled, order.sent, and order.completed like any other store order, at most once each, and only to that key. That key can also read it with GET /reward-store-orders. Refund on order.cancelled, once for each order, as described in Coins.

Store orders carry two fields that tell widget orders apart, in reads and in events:

Field Description
channel WIDGET for a widget order, API for an order placed with POST /reward-store-orders.
playerId The playerId of the session that the order came from, or null for an API order.

The player can’t cancel an order in the widget. Your team cancels orders. The widget’s My orders button opens a list of the player’s own widget orders for the brand, with their status and tracking. It never shows the recipient’s name or address.

Your team sets each brand’s look in the Luxorr workspace, in Workspace > Branding, with Widget Style on the brand, and each store’s layout and banners on the store’s own page. A saved change appears the next time the widget loads. The Widget Style page also shows the embed code, and previews the widget with sample gifts or with one of the brand’s stores. Your team chooses the following:

  • Look: one of two ready-made looks, Halden and Meridian, or Custom, which starts from either and changes any color, font, letter style or corner. Each look has a light and a dark version and sets the colors, fonts, headings, buttons, and corners of every screen.
  • Light and dark mode: both modes, so your page can switch between them with colorScheme, with one of them as the default, or only light or only dark.
  • Layout, per store: a hero banner across the top with the player’s balance on it, a side banner in a panel on the left, or no banner. On a tablet or phone, the side layout shows the hero banner instead. A layout whose image hasn’t been uploaded shows no banner.
  • Banners, per store: the store’s banner is the hero (4:1, 2400 × 600 px), and the side layout adds a side banner (1:2, 600 × 1200 px).
  • Launcher side, and CSS rules of its own for the widget’s classes.

The layout belongs to the store, so mount() has no layout option. The widget lays itself out by its own width: as on a phone below 640 pixels, as on a tablet below 1024 pixels, and as on a desktop above. An inline widget in a narrow column therefore looks as it does on a phone.

Your team can also write CSS rules of its own, which apply inside the widget after the look. The widget style reference lists every property a look sets, and the classes those rules can target and that are kept across releases. To style one mode only, target .lxw-root[data-scheme='dark'] or .lxw-root[data-scheme='light'].

The launcher button is drawn in your page, outside the widget, so the custom CSS doesn’t reach it. It shows the brand’s mark, “Rewards”, and the player’s balance in the look’s colors, on the side your team chose, and its balance changes with the widget’s. To restyle it further, target its lxw-launcher class from your own page’s CSS.

Keep the following in mind:

  • CSS that targets anything else might break when the widget changes.
  • The widget loads nothing from outside Luxorr. A url() to another host doesn’t load, and an @import is refused when your team saves the style.
  • Fonts come from the list on the style page. Luxorr hosts them, and no request goes to a font provider.

The widget has the following limits:

  • 300 requests a minute for each session, from the widget to Luxorr. Above that, the widget’s calls return 429 rate_limited.
  • One gift for each order. There is no cart.
  • The widget serves rewards stores only, not personal links or campaigns.
  • It fits narrow pages and phones, inline and in the launcher’s dialog.

For every error code, see Errors. For an end-to-end example, see Operator widget.