cart-circle-checkCheckout Terminal

A checkout terminal is a two-device flow.

One device shows the cart. Another device is the “payment terminal”. The customer signs in and approves on the payment terminal.

Flow

  1. Create a channel on the first device.

  2. Enter the channel URL on the payment terminal device (QR or deep link).

  3. Call signIn or transferTokens with { channelId } from the first device.

  4. Transaction details will appear on the payment terminal.

  5. Close the channel when you’re done.

Checkout Terminal Flow
import { RevibaseProvider, transferTokens } from "@revibase/lite";

const provider = new RevibaseProvider();

async function runCheckoutTerminalFlow() {
  const orderTotal = 1_000_000n;
  const merchantWallet = "MERCHANT_WALLET_ADDRESS";

  // 1) Create channel
  const { channelId, url } = await provider.createChannel();
  // 2) Open `url` on the checkout device (QR code or deep link)

  const { txSig, user } = await transferTokens(
    provider,
    {
      amount: orderTotal,
      destination: merchantWallet,
    },
    { channelId },
  );

  // 3) Close channel when done
  await provider.closeChannel(channelId);

  return { txSig, url };
}

You can optionally call signIn(provider, { channelId }) first if you want an explicit “connect” step.

Confirm txSig on-chain using your RPC before fulfilling the order.

Last updated