Meet Toki Operator

Docs/Wallet SDK

Wallet

Open and close the wallet, and show or hide its launcher.

The wallet is Toki's customer hub on your storefront. In Popup mode, the Toki Wallet app embed adds a launcher, a floating icon that opens the wallet as a popup or sidebar. In Expanded mode, the Expanded Wallet block shows the wallet open on a page, without a launcher. You can call these methods as soon as the SDK loads: if the wallet is still loading, the latest call runs as soon as it's ready.

open#

tokiWallet.open(route?)→ Promise<void>

Opens the wallet, optionally at a specific screen.

In Popup mode, the wallet opens over the page, or switches to route if it's already open. In Expanded mode, the page scrolls to the wallet and it shows route. Without route, the wallet opens at its Default Tab (Home unless you've changed it), or stays where it is if it's already open.

Guests see the sign-in screen whatever the route, so open("/auth") is how you ask them to sign in; tokiWalletUserAuthenticated fires once they have. If you've turned off Auto-join users to the rewards program, a customer who hasn't joined yet sees the join screen.

It also works on pages where your wallet settings hide the launcher. As with a click on the launcher, opening the wallet for a signed-in customer completes any Sign In Rewards activity you have, within its limits.

Arguments

  • routestring

    The screen to show: "/home", "/home/earn" (ways to earn), "/home/activities", "/home/activity/<activityId>" (one activity; the wallet dispatches toki:public:activity:opened), "/home/challenges", "/reward-overview", "/transactions" (points history), "/credits/spend" (spend points), "/profile", "/profile/edit", "/paid-memberships/subscriptions", "/orders/<orderId>", "/home/groups/<groupId>" (a loyalty group) or "/auth" (the sign-in screen; signed-in customers see Home).

Returns

Promise<void>

Nothing, once it's done.

Events

Example
document
  .querySelector("#edit-profile")
  .addEventListener("click", () => {
    tokiWallet.open("/profile/edit")
  })
action

close#

tokiWallet.close()→ Promise<void>

Closes the wallet.

In Popup mode, the popup or sidebar closes and the launcher stays as it is. The next open() without a route starts at the Default Tab. In Expanded mode, the wallet stays on the page.

Returns

Promise<void>

Nothing, once it's done.

Example
window.addEventListener(
  "toki:public:cart:discount-code:added",
  () => {
    tokiWallet.close()
  },
)
action

hide#

tokiWallet.hide()→ Promise<void>

Closes the wallet and hides its launcher until the next page load.

Use it on pages where the launcher gets in the way, such as a landing page with its own call to action. open() still opens the wallet, and show() brings the launcher back. Expanded mode has no launcher.

Returns

Promise<void>

Nothing, once it's done.

Example
if (location.pathname === "/pages/vip-launch") {
  tokiWallet.hide()
}
action

show#

tokiWallet.show()→ Promise<void>

Shows the wallet's launcher again after hide().

It shows the launcher without opening the wallet; to open it, call open(). Your wallet's page and device settings still decide where the launcher appears. Expanded mode has no launcher.

Returns

Promise<void>

Nothing, once it's done.

Example
tokiWallet.hide()
// Later, once the customer has finished your quiz:
tokiWallet.show()