Open Country Infrastructure · OCI-Pay

How sign-in and payments work

Two countries, four banks, and a payments operator (NPC) in each country running its switch. People prove who they are with a token from an OCI-ID. Banks and switches prove who they are by signing every request. Money moves bank → switch → bank, and the switch keeps the running tally of who owes whom. A payment app such as Wren can issue addresses of its own, which point at accounts people connect; the use cases show how. Part 1 covers sign-in and permissions, Part 2 payments and settlement.

Who talks to whom

Global Payments Corp/Trusttrust registry · participants + keys COUNTRY IN · INR COUNTRY US · USD NPC IN · PAYMENTS OPERATOR Its own OCI-IDoperator staff Payments switchroutes · tallies tokens NPC US · PAYMENTS OPERATOR Payments switchroutes · tallies Its own OCI-IDoperator staff tokens link STATE BANK OF INDIABank API + ledgerIts own OCI-IDtokens HDFC BANKBank API + ledgerIts own OCI-IDtokens CHASEBank API + ledgerIts own OCI-IDtokens BANK OF AMERICABank API + ledgerIts own OCI-IDtokens signed signed signed signed OCI-ID INthe country's residents · banks accept its tokens too OCI-ID USthe country's residents · banks accept its tokens too ZPAY · PAYMENT APPWren appon Asha's phoneWrenZPay's payment appsession FINCH · PAYMENT APPFinchpayment appFinch appon Lena's phonesession
A payment app belongs to one country and calls only that country's switch: ZPay (Wren) in India, Finch in the US; an account in the other country is reached through it, over the link. A bank never calls another bank. It calls its own country's switch; the switch calls the payee's bank, or the other country's switch over the link (also signed). Each organisation has its own OCI-ID for its own people: the NPC that operates the switch, and each bank. The country's OCI-ID is the residents' identity; the switch does not use it at all. The registry is run by the consortium body, Global Payments Corp/Trust, which belongs to no country. Banks also read it (not drawn).
A person's token is checked against an OCI-ID Machine-to-machine request carrying an OCI-Signature Registry lookup
Use cases

Use cases with a payment app

A bank issues a payment address with the account (asha@sbi). A payment address can also stand apart from the bank: a payment app such as Wren issues the address, called a PayID here (asha@wren), and the person connects it to a bank account. The part after the @ names the app, never the bank.

The person's own app session Signed call between organisations

Every use case is drawn on the same map as "Who talks to whom", without the OCI-IDs, and runs beside it: press Run or Next step, and the call in focus lights up on the map with its number. Grey lines are connections the use case does not use. An indented step (↳) is a request made while the step above it is being handled: its answer is needed before the one above can answer. A call to a bank's own core stays inside the bank.

An app only ever calls the switch it is registered with (Wren: India's), and a bank only its own country's switch; the switch calls the other side. An account in the other country is reached through the home switch, over the link. The app never holds money and never sees the PIN. A bank is also an app for its own customers, so asha@sbi keeps working.

1. Connect a bank

Asha, signed in to Wren, connects her SBI account and picks a PayID.

COUNTRY IN · INRCOUNTRY US · USDNPC IN · PAYMENTS OPERATORNPC US · PAYMENTS OPERATORSTATE BANK OF INDIAHDFC BANKCHASEBANK OF AMERICAGlobal Payments Corp/Trusttrust registry · participants + keysPayments switchroutes · talliesPayments switchroutes · talliesBank API + ledgerBank API + ledgerBank API + ledgerBank API + ledgerWren appon Asha's phoneWrenpayment app
SBI decides whether she is its customer and whether the PIN is right; Wren and the switch only carry the request. SBI also asks the identity that signed Asha in for her phone number, and checks the PIN in its own core: neither is drawn, so those steps light up SBI. Either Asha or SBI can end the connection later; the account reference then stops working.

2. Pay by PayID or QR code

Asha pays ravi@wren 120.00 INR. Ravi's account is at HDFC, which Asha never needs to know.

COUNTRY IN · INRCOUNTRY US · USDNPC IN · PAYMENTS OPERATORNPC US · PAYMENTS OPERATORSTATE BANK OF INDIAHDFC BANKCHASEBANK OF AMERICAGlobal Payments Corp/Trusttrust registry · participants + keysPayments switchroutes · talliesPayments switchroutes · talliesBank API + ledgerBank API + ledgerBank API + ledgerBank API + ledgerWren appon Asha's phoneWrenpayment app
Ravi's address was issued by Wren, so the switch asks Wren whose it is, and tells Wren when the money has arrived. A QR code carries the same address, plus the amount and an order number for a shop. Afterwards the switch's tally reads SBI −120.00, HDFC +120.00.

3. Request a payment, then accept or reject

Quickstep Rewards, a shop that banks with HDFC, asks asha@wren for 499.00 INR from HDFC's app. Asha approves it in Wren.

COUNTRY IN · INRCOUNTRY US · USDNPC IN · PAYMENTS OPERATORNPC US · PAYMENTS OPERATORSTATE BANK OF INDIAHDFC BANKCHASEBANK OF AMERICAGlobal Payments Corp/Trusttrust registry · participants + keysPayments switchroutes · talliesPayments switchroutes · talliesBank API + ledgerBank API + ledgerBank API + ledgerBank API + ledgerWren appon Asha's phoneWrenpayment appQuickstep Rewardsin HDFC's app
A request moves no money by itself; only an approval with the PIN does. If Asha does nothing, the switch marks the request expired and tells the shop's bank.

4. Other use cases

Use caseWhat happens
Check a balanceWren → switch → bank, with the account reference and the encrypted PIN. The balance is shown and not stored by the app.
Pay across a borderUse case 2 with a quote first: exact amount, rate and fee are shown before the PIN. The payer's switch hands the credit to the other country's switch over their link.
A second app on the same accountAsha connects SBI in another app and gets a second PayID. Both move money in the same account; each app shows only its own payments and requests.
Change the bank behind a PayIDAsha connects HDFC and points asha@wren at it. People who pay her change nothing.
Disconnect a bankFrom the app or from the bank. The consent is ended and the account reference is refused from then on.
Shop checkoutThe shop shows a QR with amount and order number (use case 2) or sends a request to the buyer's PayID (use case 3). The shop is told the result either way.
A payment that fails midwayThe held money is released. A timeout is retried with the same key and can never pay twice.
Set or change the PINWith the bank, through the app and the switch, encrypted to the bank. Neither the app nor the switch can read it.
RefundThe shop sends a new payment back to the buyer's PayID, linked to the original. Not designed yet.
Block a senderThe app stops showing requests from an address. Not designed yet.
Part 1

Authentication and authorization

There are three kinds of caller, and each proves itself a different way. OCI-ID answers who a person is. The bank or switch answers what that person may do.

CallerProves identity withThe API maps it toThen allowed
Operator (bank or NPC staff), in a consoleOCI-ID access token
issued to <app>-app
a row in the app's operators table, by verified email or phonethe actions of that row's role
Customer, in a walletOCI-ID access token
plus the account PIN for payments
a bank account, through an identity link (issuer + subject + client)their own account only
Bank or switchOCI-Signature
on every request
a participant in the trust registrybank routes for the country's banks; link routes for the peer switch

An operator signs in to a console

OpenID Connect authorization code flow with PKCE. The console is a public client, so it holds no secret; the PKCE verifier ties the code to the browser that started the sign-in.

sequenceDiagram
  autonumber
  actor O as Operator
  participant C as Console in browser
  participant I as The organisation's own OCI-ID
  participant A as App API (bank or switch)
  O->>C: Open the console
  C->>I: GET /authorize · client_id, redirect_uri, PKCE S256 challenge, state, nonce
  I->>O: Sign-in page
  O->>I: Phone or email + one-time code (or password, Google)
  I->>O: Consent · share name, phone, email
  I-->>C: Redirect to /auth/callback with a code (valid 60 s)
  C->>I: POST /token · code + PKCE verifier
  I-->>C: Access token (ES256, 15 min) + refresh token (30 days)
  C->>A: GET /api/auth/me · Bearer token
  A->>I: GET /.well-known/jwks.json (cached 5 min)
  A->>I: GET /userinfo (first time it sees this person)
  A-->>C: Name, organisation, role
  C->>A: GET /api/rbac/permissions
  A-->>C: The actions this role allows
    
Steps 2–8 are authentication, done entirely by OCI-ID. Steps 9–14 are authorization, done by the app's own API from its operators table. The console only hides buttons; the API refuses the call either way.

What the API checks on every call

  1. The issuer is one this API trusts. It is read first only to pick the key set, then checked again after the signature.
  2. Signed with ES256 by a key that issuer publishes. An unknown key triggers one refetch, at most every 30 seconds.
  3. typ is at+jwt. An ID token is not a pass to an API.
  4. client_id is this app's own client and appears in aud. A token another app obtained is refused.
  5. Not expired.
  6. The person is an active operator, and their role includes the action the route needs.

Failures: 401 means sign in again; 403 means signed in but not allowed; 502 means the OCI-ID could not be reached, which does not sign anyone out.

Roles in the payments console

Actionowneropsviewer
settlement.viewyesyesyes
payments.viewyesyesyes
settlement.runyesyesno
payments.retryyesyesno
team.manageyesnono

In the bank console the owner sees customers, payments, the ledger check and the team; the viewer sees the ledger check only.

A bank or switch calls another

No shared secrets and no tokens. Each request carries an OCI-Signature header: a detached JWS signed with the sender's Ed25519 key over the exact body bytes.

sequenceDiagram
  autonumber
  participant S as Sender (bank or switch)
  participant R as Receiver
  participant T as Trust registry
  Note over S: Sign the body · header carries alg EdDSA, kid, iss, iat, htm, htu
  S->>R: POST … · OCI-Signature + Idempotency-Key
  Note over R: iat within 120 s · htm and htu match this exact request
  R->>T: GET /participants/{iss}
  T-->>R: Kind, country, status, address suffix, key address
  Note over R: Active · right kind for this route (own country's bank, or the peer switch)
  R->>S: GET /.well-known/jwks.json
  Note over R: Signature verifies with the key named by kid (one forced refresh for a rotated key)
  R-->>S: Result
    
Because the method, URL and time are inside the signed header, a captured request cannot be replayed against another route or later. The switch additionally checks that the paying address belongs to the bank that signed.
Part 2

Payments and settlement

A payment inside one country

Example: Asha at SBI pays Ravi at HDFC 120.00 INR. The address suffix (@hdfc) tells the switch which bank to credit.

sequenceDiagram
  autonumber
  actor P as Payer's wallet
  participant PB as Payer's bank
  participant S as Switch
  participant RB as Payee's bank
  P->>PB: GET /v1/keys/pin
  P->>PB: POST /v1/payments · Bearer token, PIN as JWE, Idempotency-Key
  Note over PB: Token → account · PIN correct · enough balance
Place a hold · payment is pending PB->>S: POST /v1/payments · signed Note over S: Signature ok · sender owns the paying address
State: received S->>RB: POST /switch/v1/credit · signed Note over RB: Signature ok · book the money in to the payee RB-->>S: Credited, payee's name Note over S: received → credited → completed
Positions: payer's bank −120.00, payee's bank +120.00 S-->>PB: completed Note over PB: Capture the hold · book customer → settlement account PB-->>P: completed
The payer's money is only held until the switch confirms. If the payee's bank refuses, the switch marks the payment failed and the payer's bank releases the hold.

States

At the switch:

received→credited→completedorfailed

At the payer's bank, and what a caller sees:

pending→completedorfailed

The PIN travels encrypted to the bank's own key (ECDH-ES, A256GCM) with a one-use nonce. Five wrong PINs lock the account for 15 minutes.

When a step times out

  1. A timeout is not a failure. The payment stays pending and the hold stays in place.
  2. The payer's bank re-sends the same request with the same Idempotency-Key, at most every 30 seconds.
  3. The switch picks the payment up where it stopped; a repeat never credits twice.
  4. An operator can push a stuck payment from the console with "Try again" (payments.retry).

A payment across the border

Example: Asha at SBI (IN) pays Lena at Chase (US). She sends 248.00 INR, pays a 20.00 INR fee, and Lena receives 20.00 USD at the fixed rate of 12.40 INR per USD. A quote comes first, so the payer sees the exact amounts before entering the PIN.

sequenceDiagram
  autonumber
  participant PB as Payer's bank (IN)
  participant SX as Switch IN
  participant SC as Switch US
  participant RB as Payee's bank (US)
  PB->>SX: POST /v1/quotes · signed
  SX->>SC: POST /link/v1/quotes · signed
  SC->>RB: POST /switch/v1/lookup · signed
  SC-->>SX: Payee's name, receive amount, rate
  SX-->>PB: Quote · send, receive, fee, total debit · valid 10 min
  PB->>SX: POST /v1/payments with quote_id · signed
  Note over SX: Quote unused, unexpired, same amounts · mark it used
  SX->>SC: POST /link/v1/payments · signed
  Note over SC: Sender is the peer switch · amounts match the fixed rate
  SC->>RB: POST /switch/v1/credit · signed, with the exchange details
  RB-->>SC: Credited
  Note over SC: Positions: payee's bank +20.00 USD, link to IN −20.00 USD
  SC-->>SX: completed
  Note over SX: Positions: payer's bank −248.00 and −20.00 fee,
link to US +248.00, fees +20.00 SX-->>PB: completed
Each switch records the payment in its own currency. The link position on one side mirrors the link position on the other: IN owes US 248.00 INR, which US sees as 20.00 USD owed to it.

Settlement

Every completed payment adds rows to the switch's positions, and each payment's rows sum to zero. An open position is the net of all payments since the last cycle. These were switch IN's positions after the four test payments of 24 November, before a cycle was run that evening.

All amounts in INR. SBI: −120.00 to Ravi, −248.00 and −20.00 fee to Lena, +60.00 from Ravi. Its payment to Priya also passes through the switch, but both sides are SBI, so it nets to zero. The bank's own ledger shows the same 328.00 in its settlement account.

What a settlement cycle does

  1. An operator with settlement.run presses "Run settlement cycle".
  2. In one transaction the switch stamps every open position row with the new cycle's id.
  3. It nets them per participant and currency and stores the result: who pays, who is paid, the link amount in both currencies, fees, and whether it balanced.
  4. Open positions are now empty. With nothing open, the switch answers "nothing to settle".

What it does not do

A cycle is bookkeeping. It records the net amounts each bank must pay or receive; it does not itself move funds between banks. In this simulation that final transfer is not modelled.

The trust registry runs in its own store (oci-gpc). If it stops, signatures cannot be checked and payments between banks stop.