# Enroll `pob-chain` And Become Payment-Ready

Date: 2026-04-03

## Goal

This runbook defines the shortest supported path for an operator, merchant owner, customer app, or AI agent to enroll a PoB merchant flow and reach a state that is **payment-ready**.

## Payment-Ready Definition

A merchant flow is **payment-ready** when all of the following are true:

1. the merchant contract is registered in the on-chain registry
2. the merchant contract's token contract is also registered in the registry
3. the merchant owner API token exists
4. the fee owner API token exists
5. the customer has a merchant settlement wallet linked for that merchant contract
6. the fee settlement wallet can be derived for that customer

The CLI command `node cli.mjs payment-ready-check ... --json` evaluates this state directly.

## Standard Workflow

### 1. Generate the fee owner API token

```bash
node cli.mjs generate-api-token \
  --user-id operator01 \
  --password 'operator-password'
```

### 2. Generate the merchant owner API token

```bash
node cli.mjs generate-api-token \
  --user-id merchant01 \
  --password 'merchant-password'
```

### 3. Register the customer if needed

```bash
node cli.mjs register-user \
  --user-id customer01 \
  --password 'customer-password' \
  --wallet-type cloud
```

### 4. Register the customer with the merchant contract

```bash
node cli.mjs merchant-register \
  --user-id customer01 \
  --password 'customer-password' \
  --contract-name 'fuel merchant' \
  --merchant-owner-user-id merchant01 \
  --merchant-owner-password 'merchant-password' \
  --json
```

### 5. Verify readiness

```bash
node cli.mjs payment-ready-check \
  --user-id customer01 \
  --password 'customer-password' \
  --contract-name 'fuel merchant' \
  --json
```

## Browser JS Workflow

```js
await window.SPAAdapter.login({
  userId: "customer01",
  password: "customer-password",
});

await window.SPAAdapter.connectWallet("https://.../rpc");

const contract = await window.SPAAdapter.getContractFromRegistry("fuel merchant");
const status = await window.SPAAdapter.getSettlementWalletsForContract(contract.address);
const stored = await window.SPAAdapter.getStoredApiTokensForContract(contract.address);
```

Use `merchantRegister(contract.address, merchantOwnerUserId, merchantOwnerPassword)` to complete enrollment from the browser.

## Notes

- Default environment values live in `config.js` and currently point at the sandbox deployment.
- `merchantRegister(...)` is the operation that links the customer to the merchant and provisions settlement wallets.
- `payment-ready-check` is the fastest supported verification path for agents.
