Storspay Docs
Support

Marketplace with escrow: the RxAll reference flow

Buyers abroad fund a balance, each order's money waits in escrow, and the seller is paid on delivery.

Outline. The full guide with code follows. Sandbox access comes with the Enterprise plan.

RxAllDelivered is a pharmacy marketplace and the reference integration for every marketplace on Storspay. Any marketplace can follow the same steps; nothing here is specific to RxAll.

The flow

  1. A buyer abroad funds their balance in USD, EUR, GBP or CAD by bank transfer. Storspay is the account underneath ("Powered by Storspay").
  2. At checkout the order's money moves into escrow (held).
  3. On delivery the marketplace calls release: the money goes to the seller's Storspay Account in USD, or straight on to the seller's NGN bank account. No delivery → cancel, which refunds the buyer.
  4. The seller cashes out at any time.
  5. The marketplace gets a webhook at every step and earns a platform fee per order.

Who is what

PartyStorspay objectVerification
MarketplaceWorkspace (platform), API keys, platform fee earningsBusiness verification and go-live review
Buyer (abroad)Account holder type: individual, Storspay Account (USD; EUR if funded in EUR)Identity check by hosted link; lives in the US, UK, EU or Canada
Seller (pharmacy)Account holder type: business, Storspay Account, beneficiary (its NGN bank account)Business verification by hosted link, with its pharmacy licence

Order lifecycle

%%{init: {"theme": "base", "themeVariables": {"primaryColor": "#6B3FA0", "primaryTextColor": "#FFFFFF", "primaryBorderColor": "#5A2D8C", "lineColor": "#6B3FA0", "textColor": "#1E1E2E", "background": "#F5F0E8"}}}%%
stateDiagram-v2
    [*] --> held : transfer with escrow (checkout)
    held --> released : release (delivered)
    held --> refunded : cancel (not delivered)
    held --> refunded : holdUntil passes (default 14 days)
    released --> [*] : seller credited (optional cash-out payout)
    refunded --> [*] : buyer refunded

Money for one order (illustrative, USD)

Steps (outline)

  1. Open the buyer and the seller. POST /v1/accounts (or POST /v1/virtual-accounts with holder) and a hosted verification link for each. Wait for account.activated and virtual_account.created.
  2. Buyer funds the balance. The buyer sends a bank transfer to their account details, with the reference. Webhooks deposit.received, deposit.credited.
  3. Set your platform fee. PUT /v1/platform-fees with a rule for escrow_release.
  4. Add the seller's bank account. POST /v1/beneficiaries with Storspay-Account-Id: <seller>.
  5. Checkout: hold the order's money. POST /v1/escrows (or POST /v1/transfers with escrow) from the buyer to the seller with clientRef = your order id → transfer.held.
  6. Delivered: release. POST /v1/escrows/{id}/release (or POST /v1/transfers/{id}/release), optionally with cashOut: { beneficiaryId, quoteId } → transfer.released, platform_fee.earned, then payout.created … payout.paid.
  7. Not delivered: cancel. POST /v1/escrows/{id}/cancel (or POST /v1/transfers/{id}/cancel) → transfer.refunded.
  8. Seller cashes out any time. POST /v1/cash-outs (or POST /v1/transfers) from the seller with beneficiaryId.

Production guard (slice 2c): While held payments are guarded off on live, requests to /v1/escrows, /v1/transfers, and /v1/cash-outs return HTTP 409 { code: "not_enabled" }. No money moves until slice 2b and the Ops switch are live.

  1. Two-way (optional). The seller gets paid by a collection: POST /v1/collections with creditTo: { accountId: <seller> }.

Try it in the sandbox

  1. Open a buyer named "Test Approved" (clientRef: "buyer-001", country: "USA") and a seller named "Test Approved" (clientRef: "pharmacy-001", type: "business", country: "NGA").
  2. POST /v1/sandbox/deposits { "amount": "100.00", "currency": "USD" } with Storspay-Account-Id: <buyer>.
  3. PUT /v1/platform-fees with { "flow": "escrow_release", "currency": "USD", "fixed": "1.00" }.
  4. Seller beneficiary: NGN bank account 9900000000 ("Sandbox: paid").
  5. POST /v1/transfers with amount: { "amount": "34.34", "currency": "USD" }, escrow, clientRef: "order-1001".
  6. POST /v1/transfers/{id}/release with clientRef: "order-1001-release" and cashOut.
  7. Variants: refund a second order with /cancel; let one expire with POST /v1/sandbox/transfers/{id}/expire; cash out to 9900000002 (failed, recipient_details: the money stays in the seller's balance) and to 9900000006 (review hold, then /decline); a buyer named "Test Rejected" gets application.rejected, and its money calls return 403 ACCOUNT_NOT_VERIFIED; replay step 5 and get the same transfer with Storspay-Replayed: true; freeze the buyer and a new transfer gets 409 ACCOUNT_FROZEN.