JamiDev

Storefront

Sell your JamiDev products from your own website, with no secret in the browser and the money landing in your Jami wallet.

The storefront build of jami-sdk (0.4.0 and later) sells your published products from your own site. Card checkout runs entirely in the browser with no API token, and the money lands in your Jami wallet. Use it when you want your own product grid instead of a checkout link.

It ships two ways:

  • a drop-in <script> that exposes a JamiStore global, and
  • an importable module: import { JamiStorefront, mountStorefront } from 'jami-sdk/storefront'.

How it works

  • Hosted checkout (card): the SDK sends the buyer to Jami's hosted checkout page for a public product token (p_…) or checkout-link token (cl_…). Nothing secret is needed.
  • Pay with Jami wallet: the SDK sends the buyer to a small server you host (walletPay) that runs Sign in with Jami and a wallet:send. wallet:send is only granted to confidential (server) clients, so this step can't run in a browser.

Drop-in script

<script src="https://cdn.jsdelivr.net/npm/jami-sdk@0.4.1/dist/jami-storefront.global.js"></script>
<div id="shop"></div>
<script>
  const { JamiStorefront, mountStorefront } = window.JamiStore;

  const store = new JamiStorefront({
    // Omit walletPay to offer hosted card checkout only.
    walletPay: { endpoint: 'https://your-server.com/pay/wallet', recipient: 'yourhandle' },
  });

  // Built-in product grid, no dependencies
  mountStorefront('#shop', {
    storefront: store,
    returnUrl: location.origin + '/thanks',
    products: [
      { token: 'p_AbC123', title: 'Leather Bag', priceEtb: 2500, image: 'https://…' },
      { token: 'p_XyZ789', title: 'Canvas Tote', priceEtb: 900,  image: 'https://…' },
    ],
  });
</script>

Copy each product's p_… token from Store → Products. Publish the product first; only published products open at checkout. You supply the product list yourself, so the storefront never calls the API and never needs your token.

Your own UI

Skip mountStorefront and drive the redirects yourself:

import { JamiStorefront } from 'jami-sdk/storefront';

const store = new JamiStorefront({
  walletPay: { endpoint: 'https://your-server.com/pay/wallet', recipient: 'yourhandle' },
});

store.checkout('p_AbC123');                                   // → hosted checkout
store.payWithWallet({ amountMinor: 250000, reference: 'p_AbC123' }); // → wallet server

// Or build URLs without redirecting (e.g. for an <a href>):
store.getCheckoutUrl('cl_LinkToken', { returnUrl: 'https://shop.example/thanks' });

Amounts are integer ETB minor units (santim): 250000 = 2,500.00 ETB.

Options

new JamiStorefront({
  issuer?: string,          // default 'https://jami.bio'
  walletPay?: {
    endpoint: string,       // your confidential wallet-pay server (absolute URL)
    recipient: string,      // the receiving Jami handle or user id
  },
});

store.walletEnabled reflects whether walletPay was configured; the built-in grid only renders a wallet button when it is (and the product has a price).

Wallet-pay endpoint contract

When walletPay is set, the wallet button sends the buyer to:

GET {endpoint}?recipient=<handle>&amountMinor=<santim>&reference=<token>&return_url=<url>

Your server (a confidential OAuth client) must:

  1. Start Sign in with Jami with scope wallet:send, persisting state + the PKCE code_verifier.
  2. On the callback, exchange the code and call wallet.send to recipient for amountMinor (idempotency key advised).
  3. Record the order and redirect the buyer back to return_url (e.g. with ?status=paid).

Card checkout needs no server. Only the wallet button does.

Notes

  • The storefront only accepts public tokens (p_…, cl_…). Internal product ids are rejected so they never end up in shareable URLs.
  • Redirect helpers (checkout, payWithWallet) require a browser; the URL builders (getCheckoutUrl, getWalletPayUrl) work anywhere.
  • Fulfil hosted-checkout orders from the order.completed webhook. Wallet payments don't create JamiDev orders; your wallet-pay server records them.

On this page