Skip to main content

Peer Pay CLI

peer-pay-cli runs a local mock of the Peer Pay API and manages your hosted merchant account. Test orders and webhooks against a handler on localhost, then sign up, configure your merchant, and verify your integration from the same terminal.

CLI 0.11.0 adds checkout grants: mint one link, then let the customer choose the payout funding details or the Base USDC on-ramp destination.

Install​

Requires Node.js 22 or newer.

npm install -g @zkp2p/peer-pay-cli
peer-pay-cli --version
peer-pay-cli --help

Run peer-pay-cli with no command in a terminal to choose from a menu. A missing required argument opens a picker or a question instead of failing; see filling in required arguments.

Test locally​

Start your application's webhook handler, then start the mock in another terminal:

peer-pay-cli serve --state ./peer-pay.json

The mock listens on http://127.0.0.1:4020 and saves a local profile. No Peer account, database, or tunnel is needed. Open the URL in a browser for a summary page with quickstart commands. Keep the state file out of version control: it holds local credentials.

Order and payout views, including webhook payloads, include a nullable checkoutGrantId. Older local state files load a missing field as null.

In another terminal, register your handler and create an order:

peer-pay-cli --local webhooks create \
--url http://localhost:3000/webhooks/peer-pay \
--events PAYMENT_SETTLED,ORDER_FULFILLED

peer-pay-cli --local orders create --amount 10

Use the returned order.id as ORDER_ID:

peer-pay-cli --local payments create ORDER_ID --rail venmo
peer-pay-cli --local simulate ORDER_ID --event PAYMENT_SETTLED
peer-pay-cli --local orders get ORDER_ID
peer-pay-cli --local status

The order becomes FULFILLED, and your handler receives signed PAYMENT_SETTLED and ORDER_FULFILLED requests. status reports the integration verified once your handler answers the ORDER_FULFILLED delivery with a 2xx. To inspect delivery attempts, use the webhook.id from the first command:

peer-pay-cli --local webhooks deliveries WEBHOOK_ID

No money moves. The mock does not verify payment proofs, match liquidity, send transactions or email, bill you, or serve a checkout page, and its exchange rates are fixtures. Test redirects, embedded checkout, and the customer's payment experience in the hosted sandbox. Local tests do not complete hosted onboarding.

Connect your application​

Export the local credentials to a new file and load it through your application's environment configuration:

peer-pay-cli --local credentials export --output .env.peer-pay --webhook-id WEBHOOK_ID

This writes PEER_PAY_API_URL, PEER_PAY_API_KEY, and PEER_PAY_WEBHOOK_SECRET. It never overwrites an existing file. Add the file to .gitignore.

Point the SDK at the local API:

import { createCheckout } from '@zkp2p/pay-sdk';

const checkout = await createCheckout(
{ requestedUsdcAmount: '10' },
{
apiBaseUrl: process.env.PEER_PAY_API_URL!,
apiKey: process.env.PEER_PAY_API_KEY!,
},
);

console.log(checkout.order.id);

createCheckout also accepts an idempotencyKey. A retry with the same key returns the same order with a null checkoutUrl, so save the URL from the first response.

Verify webhook signatures over the raw request body, check the timestamp, and deduplicate events by ID. See webhook verification.

Test other outcomes​

# List every event name.
peer-pay-cli --local local events

# Settle part of an order, then create another payment for the remainder.
peer-pay-cli --local simulate ORDER_ID --event PAYMENT_SETTLED --payment-id PAYMENT_ID --amount 4
peer-pay-cli --local payments create ORDER_ID --rail venmo

# Fail an open payment.
peer-pay-cli --local simulate ORDER_ID --event PAYMENT_FAILED --payment-id PAYMENT_ID

# Shorten the payment window for new payments.
peer-pay-cli --local local settings --data '{"quoteTtlSeconds":30}'

# Make payment creation fail with PAYMENTS_PAUSED; set false or restart serve to undo.
peer-pay-cli --local local settings --data '{"paymentCreationPaused":true}'

simulate covers order, payment, refund, bridge, chargeback, and dispute events. Transitions must be valid: refunds and chargebacks need settled funds, and bridge events follow their lifecycle. See simulation.

Test Apple Pay​

Peer enables Apple Pay per merchant; locally, local admin turns it on:

peer-pay-cli --local local admin --data '{"applePayAvailable":true}'
peer-pay-cli --local merchant settings --data '{"enabledRails":["venmo","relay_8453","apple_pay"]}'
peer-pay-cli --local orders create --amount 10
peer-pay-cli --local payments create ORDER_ID --rail relay_8453 --currency USDC --onramp-provider coinbase_apple_pay
peer-pay-cli --local simulate ORDER_ID --event PAYMENT_SETTLED --payment-id PAYMENT_ID --deposit-amount 5

--deposit-amount settles part of the quote in USDC; omit it to fund the whole quote. A partial deposit leaves a balance for another payment.

Test Zcash deposits​

peer-pay-cli --local orders create --data '{"requestedUsdcAmount":"10","enabledRails":["near_intents_133701"],"destinationChainId":"8453","destinationToken":"USDC"}'
peer-pay-cli --local payments create ORDER_ID --rail near_intents_133701 --currency ZEC --refund-to YOUR_TRANSPARENT_ZCASH_ADDRESS
peer-pay-cli --local simulate ORDER_ID --event PAYMENT_SETTLED --payment-id PAYMENT_ID

The payment returns a transparent deposit address, the ZEC amount in eight-decimal base units, and a 20-minute deposit deadline. The local rate is a fixture of 0.01 ZEC per USDC, which local settings rates can change. Invalid refund addresses are rejected before a payment is created.

Test checkout grants locally​

From a source checkout, build with npm run build:packages and npm --workspace apps/peer-pay-cli run build. Start these in separate terminals from the repository root:

node apps/peer-pay-cli/dist/cli.js serve --config ./grant-profiles.json --state ./grant-state.json
VITE_API_BASE_URL=http://127.0.0.1:4020 npm run dev:checkout

Mint a grant and open its checkoutUrl (macOS example):

node apps/peer-pay-cli/dist/cli.js grants create --local --config ./grant-profiles.json --kind onramp --min-amount 10 --max-amount 100 --json > grant.json
open "$(node -p 'JSON.parse(require("node:fs").readFileSync("grant.json", "utf8")).responseObject.checkoutUrl')"

The checkout runs at http://localhost:5173. On-ramp grants can be consumed in the browser without signing in. Payout API tests use the simulator's local-player:<email> bearer token; browser Privy sign-in is a separate hosted flow. See Grants for the flags, custom checkout URL, consumer binding, persistence and local limits.

Test payouts locally​

The builder code is off by default. To include the hosted cashout ERC-8021 suffix, start the simulator with it enabled:

BASE_BUILDER_CODE_ENABLED=true \
peer-pay-cli serve

Local cashout signature requests then include input.body.experimental_data_suffix.

With peer-pay-cli serve running on its default port and jq installed, create a payout, choose a Zelle payout method as the customer, sign the sends, and settle it:

peer-pay-cli payouts configure-local --local --rails zelle --payout-step 10
peer-pay-cli payouts create --local --email customer@example.com --amount 10 --funding-chain-id 8453 --funding-token 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 --idempotency-key local-payout-001

# Copy payoutId and the t query parameter from checkoutUrl in the create response.
PAYOUT_ID=PAYOUT_ID_FROM_RESPONSE
CASHOUT_TOKEN=LINK_TOKEN_FROM_CHECKOUT_URL
PLAYER_URL="http://127.0.0.1:4020/api/v1/cashout-checkout/$PAYOUT_ID"
peer-pay-cli payouts simulate-funding "$PAYOUT_ID" --local --status success --received 10

curl --fail-with-body "$PLAYER_URL/state" \
-H "x-cashout-token: $CASHOUT_TOKEN" -H 'Authorization: Bearer local-player:customer@example.com'
curl --fail-with-body -X PUT "$PLAYER_URL/payout-method" \
-H "x-cashout-token: $CASHOUT_TOKEN" -H 'Authorization: Bearer local-player:customer@example.com' \
-H 'Content-Type: application/json' --data '{"rail":"zelle","payeeHandle":"customer@example.com"}'
CONFIRM_STATE=$(curl --fail-with-body -sS -X POST "$PLAYER_URL/confirm" \
-H "x-cashout-token: $CASHOUT_TOKEN" -H 'Authorization: Bearer local-player:customer@example.com')

# bG9jYWw= is a well-formed base64 stand-in; the local mock accepts any.
SIGNATURES=$(printf '%s' "$CONFIRM_STATE" | jq -c \
'{signatures: [.responseObject.signatureRequests[] | {transactionId, signature: "bG9jYWw="}]}')
curl --fail-with-body -X POST "$PLAYER_URL/signatures" \
-H "x-cashout-token: $CASHOUT_TOKEN" -H 'Authorization: Bearer local-player:customer@example.com' \
-H 'Content-Type: application/json' --data "$SIGNATURES"

peer-pay-cli payouts resolve-send "$PAYOUT_ID" --local
peer-pay-cli payouts simulate-payment "$PAYOUT_ID" --local --step signaled
peer-pay-cli payouts simulate-payment "$PAYOUT_ID" --local --step fulfilled
peer-pay-cli payouts timeline "$PAYOUT_ID" --local
peer-pay-cli payouts emails "$PAYOUT_ID" --local

Submit the signatures before the returned signBy deadline. Without them, resolve-send returns PAYOUT_SIGNATURE_REQUIRED. The payout ends SETTLED, with timeline entries and recorded customer emails. No funds move and no email is sent. See payout commands for the other simulations and local customer checkout for the routes.

Set up your merchant​

peer-pay-cli login --email owner@example.com
peer-pay-cli setup

Login sends an email code and creates your merchant account if needed. Setup asks for your business details and payment preferences, shows the changes, and applies them when you confirm. Follow merchant setup from the terminal for setup files, hosted sandbox testing, and going live.

Local and hosted profiles​

ProfileBackendWebhook destinationPayments
localMock on your computerYour localhost handlerSimulated
NAME-sandboxHosted sandbox, saved by sandbox enable or setupPublic HTTPS endpointSandbox tests
NAMEYour hosted merchant, saved by loginPublic HTTPS endpointLive

After you log in, commands target your Peer Pay account. Add --local, or run peer-pay-cli use local, to target the mock. See profiles for how the CLI picks one.

Help and output​

peer-pay-cli orders --help
peer-pay-cli orders create --help
peer-pay-cli orders create --amount 10 --json

A terminal shows the result without the response envelope; --json, or piping the output, prints the full JSON result. Errors go to stderr and exit with 1. Output redacts credentials; see global options. The command reference lists every command, option, and example.

Use your coding agent​

Continue the integration with Codex, Claude Code, OpenCode, or Gemini CLI:

peer-pay-cli handoff --harness codex --project ./my-store --launch

See handoff for the agents, the instructions, and prompt-only use.