Skip to content

3. The account page

With the stored card id your server can show everything a member needs. A Website key can read only cards whose ids it knows.

account.mjs
import { getCard, getHistory, walletLinks } from './walletcraft.mjs';
const card = await getCard(user.walletcraftCardId);
const links = walletLinks(card);
  • QR code — encode links.page with any QR library on your server or in the page. Scanning it on a phone opens the card page, which offers Apple Wallet or Google Wallet depending on the phone.
  • Buttons — on a phone, link straight to the wallet:
<a href="{links.apple}"><img src="{links.appleBadge}" alt="Add to Apple Wallet" height="48" /></a>
<a href="{links.google}"
><img src="{links.googleBadge}" alt="Add to Google Wallet" height="48"
/></a>

card.loyaltyBalance is the points (or stamps) and card.loyaltyTier the level name (or null). The card’s own display text — e.g. “☕ 4 / 6” — is in card.fieldValues.

const { items } = await getHistory(card.id, 10);
// items: [{ type: 'purchase', amount: 45.9, currency: 'PLN', points: 4, balance: 4, createdAt: '…' }, …]
type Meaning
purchase A purchase (amount, currency) and the points earned
redeem Points spent
reward A stamp card’s reward was given
adjust A correction by the company
cancel Reverses the operation in cancels
tier The level changed (note = new level)

To show “Card is in your phone ✓”, listen to the card.added and card.removed webhooks.

import { getConsent, setConsent } from './walletcraft.mjs';
const { marketingConsent } = await getConsent(card.id); // true / false
await setConsent(card.id, false, 'news-2026-10'); // the user unticked "Send me news and offers"

Each change is added to the customer’s consent history. Withdrawing must be as easy as giving — a single toggle in the account page is enough.