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
- A buyer abroad funds their balance in USD, EUR, GBP or CAD by bank transfer. Storspay is the account underneath ("Powered by Storspay").
- At checkout the order's money moves into escrow (held).
- 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.
- The seller cashes out at any time.
- The marketplace gets a webhook at every step and earns a platform fee per order.
Who is what
| Party | Storspay object | Verification |
|---|---|---|
| Marketplace | Workspace (platform), API keys, platform fee earnings | Business 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)
- Seller's price US$33.34, platform fee US$1.00 → the buyer's escrow is US$34.34.
- Release: seller +33.34, marketplace +1.00, escrow −34.34.
- Refund: buyer +34.34 (the platform fee is refunded too).
- The platform fee is on top, paid from the escrowed amount at release, never taken from the seller's price.
- If the seller must receive an exact NGN amount, price the order with a payout quote (
POST /v1/quotes,intent: "payout") and escrow that total. Otherwise the NGN figure is an estimate until the payout is sent.
Steps (outline)
- Open the buyer and the seller.
POST /v1/accounts(orPOST /v1/virtual-accountswithholder) and a hosted verification link for each. Wait foraccount.activatedandvirtual_account.created. - Buyer funds the balance. The buyer sends a bank transfer to their account details, with the reference. Webhooks
deposit.received,deposit.credited. - Set your platform fee.
PUT /v1/platform-feeswith a rule forescrow_release. - Add the seller's bank account.
POST /v1/beneficiarieswithStorspay-Account-Id: <seller>. - Checkout: hold the order's money.
POST /v1/escrows(orPOST /v1/transferswithescrow) from the buyer to the seller withclientRef= your order id →transfer.held. - Delivered: release.
POST /v1/escrows/{id}/release(orPOST /v1/transfers/{id}/release), optionally withcashOut: { beneficiaryId, quoteId }→transfer.released,platform_fee.earned, thenpayout.created…payout.paid. - Not delivered: cancel.
POST /v1/escrows/{id}/cancel(orPOST /v1/transfers/{id}/cancel) →transfer.refunded. - Seller cashes out any time.
POST /v1/cash-outs(orPOST /v1/transfers) from the seller withbeneficiaryId.
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.
- Two-way (optional). The seller gets paid by a collection:
POST /v1/collectionswithcreditTo: { accountId: <seller> }.
Try it in the sandbox
- Open a buyer named "Test Approved" (
clientRef: "buyer-001",country: "USA") and a seller named "Test Approved" (clientRef: "pharmacy-001",type: "business",country: "NGA"). POST /v1/sandbox/deposits{ "amount": "100.00", "currency": "USD" }withStorspay-Account-Id: <buyer>.PUT /v1/platform-feeswith{ "flow": "escrow_release", "currency": "USD", "fixed": "1.00" }.- Seller beneficiary: NGN bank account
9900000000("Sandbox: paid"). POST /v1/transferswithamount: { "amount": "34.34", "currency": "USD" },escrow,clientRef: "order-1001".POST /v1/transfers/{id}/releasewithclientRef: "order-1001-release"andcashOut.- Variants: refund a second order with
/cancel; let one expire withPOST /v1/sandbox/transfers/{id}/expire; cash out to9900000002(failed,recipient_details: the money stays in the seller's balance) and to9900000006(review hold, then/decline); a buyer named "Test Rejected" getsapplication.rejected, and its money calls return403 ACCOUNT_NOT_VERIFIED; replay step 5 and get the same transfer withStorspay-Replayed: true; freeze the buyer and a new transfer gets409 ACCOUNT_FROZEN.