We have created a suite of packages that, together, mock an account servicing entity that has deployed Rafiki, exposing an SPSP endpoint, the Open Payments APIs with its required GNAP auth endpoints to request grants, a STREAM endpoint for receiving Interledger packets, and a UI to view and manage the Rafiki instance. Additionally, we provide a simple request signing service that is used by Postman to generate request signatures required by the Open Payments APIs.
These packages include:
backend
(SPSP, Open Payments APIs, GraphQL Admin APIs, STREAM endpoint)auth
(GNAP auth server)mock-account-servicing-entity
(mocks an Account Servicing Entityfrontend
(Remix app to expose a UI for Rafiki Admin management via interaction with thebackend
Admin APIs)local-http-signatures
(request signature generation for Postman)
These packages depend on the following databases:
- TigerBeetle or Postgres (accounting)
- Postgres (Open Payments resources, auth resources)
- Redis (STREAM details)
We provide containerized versions of our packages together with two pre-configured docker-compose files (peer1 and peer2) to start two Mock Account Servicing Entities with their respective Rafiki backend and auth servers. They automatically peer and 2 to 3 user accounts are created on both of them.
This environment will set up an playground where you can use the Rafiki Admin APIs and the Open Payments APIs.
(a) User Interface - accessible at http://localhost:3030
(b) Admin API - accessible at http://localhost:3001/graphql
(c) Auth API - accessible at http://localhost:3003/graphql
(d) Open Payments API - accessible at http://localhost:3000
(e) Rafiki Admin - accessible at http://localhost:3010
(f) Open Payments Auth API - accessible at http://localhost:3006
(g) Postman Signature Service - accessible at http://localhost:3040
(h) User Interface - accessible at http://localhost:3031
(i) Admin API - accessible at http://localhost:4001/graphql
(j) Auth API - accessible at http://localhost:4003/graphql
(k) Open Payments API - accessible at http://localhost:4000
(l) Rafiki Admin - accessible at http://localhost:4010
(m) Open Payments Auth API - accessible at http://localhost:4006
(n) Postman Signature Service - accessible at http://localhost:3041
(m) Postgres Server - accessible at http://localhost:5432
Navigate to localhost:3030
to view the accounts on one instance of the Mock Account Servicing Entity called Cloud Nine Wallet.
The accounts of the second instance (Happy Life Bank) can be found on localhost:3031
.
When clicking on the Account Name, a list of Transactions appears.
The following should be run from the root of the project.
// If you have spun up the environment before, remember to first tear down and remove volumes!
// start the local environment
pnpm localenv:compose up
// tear down and remove volumes
pnpm localenv:compose down --volumes
If you want to use Postgres as the accounting database instead of TigerBeetle, you can use the psql
variant of the localenv:compose
commands:
pnpm localenv:compose:psql up
pnpm localenv:compose:psql down --volumes
The local environment consists of a primary Rafiki instance and a secondary Rafiki instance, each with
its own docker compose files (Cloud Nine Wallet, Happy Life Bank).
The primary Cloud Nine Wallet docker compose file (./cloud-nine-wallet/docker-compose.yml
) includes the main Rafiki services backend
and auth
, as well
as the required data stores tigerbeetle (if enabled), redis, and postgres, so it can be run on its own. Furthermore,
both include the local-signature-utils
signature generation app for Postman.
The secondary Happy Life Bank docker compose file (./happy-life-bank/docker-compose.yml
) includes only the Rafiki services, not the data stores. It uses the
data stores created by the primary Rafiki instance so it can't be run by itself.
The pnpm localenv:compose up
command starts both the primary instance and the secondary.
// tear down
pnpm localenv:compose down
// tear down and delete database volumes
pnpm localenv:compose down --volumes
Command | Description |
---|---|
pnpm localenv:compose config |
Show all merged config (with Tigerbeetle) |
pnpm localenv:compose up |
Start (with Tigerbeetle) |
pnpm localenv:compose up -d |
Start detached (with Tigerbeetle) |
pnpm localenv:compose down |
Down (with Tigerbeetle) |
pnpm localenv:compose down --volumes |
Down and kill volumes (with Tigerbeetle) |
pnpm localenv:compose:psql config |
Show all merged config (with Postgresql) |
pnpm localenv:compose build |
Build all the containers (with Tigerbeetle) |
pnpm localenv:compose:psql up |
Start (with Postgresql) |
pnpm localenv:compose:psql up -d |
Start detached (with Postgresql) |
pnpm localenv:compose:psql down |
Down (with Postgresql) |
pnpm localenv:compose:psql down --volumes |
Down and kill volumes (with Postgresql) |
pnpm localenv:compose:psql build |
Build all the containers (with Postgresql) |
The Open Payments APIs can be interacted with using the Postman collection (Open Payments APIs and Open Payments Auth APIs). It is configured to use the default endpoints of the local environment.
The Examples folder in the Postman collection includes an eCommerce example that can be executed one by one. It
- requests a grant to create an incoming payment on Philip Fry's account
- creates an incoming payment on Philip Fry's account
- requests a grant to create (and read) a quote on Grace Franklin's account
- creates a quote on Grace Franklin's account
- requests a grant to create (and read) an outgoing payment on Grace Franklin's account
- continues the grant request (via the interaction flow)
- creates an outgoing payment on Grace Franklin's account
- fetches the outgoing payment on Grace Franklin's account
Note that one has to go through the interaction flow after requesting a grant for a outgoing payment. More information about the interaction flow can be found here.
Example walkthrough:
eCom-example.mp4
In order to manage, and view information about the Rafiki instance(s) using a UI, you can navigate to localhost:3010
(Cloud Nine Wallet) or localhost:4010
(Happy Life Bank). This is the frontend
project which runs a Remix app for querying info and executing mutations against the Rafiki Admin APIs.
In addition to the using the Admin UI for interacting with the Admin APIs, you can also use the Apollo explorer (on localhost:3001/graphql
and localhost:4001/graphql
, respectively), and also via the Postman collection. The Postman collection is configured to use the default endpoints of the local environment.
Every payment pointer also serves as an SPSP endpoint. A GET request to e.g. http://localhost:3000/accounts/gfranklin
with Accept
header application/spsp4+json
will return an SPSP response with STREAM connection details.
http GET http://localhost:3000/accounts/gfranklin Host:backend Accept:application/spsp4+json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 220
Content-Type: application/spsp4+json
Date: Thu, 23 Feb 2023 13:07:24 GMT
Keep-Alive: timeout=5
{
"destination_account": "test.rafiki.viXmy1OVHgvmQakNjX1C6kQMri92DzHeISEv-5VzTDuFhrpsrkDzsq5OO9Lfa9yed0L2RJGC9hA_IX-zztTtTZ87shCYvsQ",
"receipts_enabled": false,
"shared_secret": "Rz_vudcg13EPs8ehL2drvZFJS1LJ4Y3EltOI60-lQ78"
}