This repository implements Revolut Open Banking Payment Initiation Service Provider (PISP) flow using the Revolut sandbox, following the guide at Revolut Developer Docs.
This is the server implementation that accompanies the openbanking.nr repository, providing the backend functionality to support the Open Banking circuit implementation and the demo escrow app.
- Initiate a payment using the PISP sandbox
- Retrieve signed payment initiation confirmation
- Verify JWS of payment initiation confirmation and payment status
- Certificate verification (parsing, validation, OCSP status)
-
Create a Revolut developer account at https://developer.revolut.com/portal/signin
-
Follow the revolut guide here to obtain:
- private.key
- client_id
- transport.pem
- jwks url
- kid
-
Create a Revolut business sandbox account at https://sandbox-business.revolut.com/signin (note: at time of writing the personal sandbox account does not have dummy funds to execute payments)
-
Clone the repository
-
create a keys folder in the root of the project and add the following files:
- private.key
- transport.pem
-
Install dependencies:
npm install -
Run ngrok to expose your local server in a seperate terminal. Install ngrok if not already installed:
ngrok http 3000tip: run static domain with ngrok by creating ngrok account and obtaining the link from dashboard so you dont have to keep doing step 5 every time you run it.
-
Copy the Forwarding URL from ngrok, appending "/callback" to the end, and paste it into:
a. the Revolut developer portal as the Redirect URL appending "/callback" at end like this:
b. the .env file in this repo -
create environment file:
cp .env.example .env -
modify .env file with variables obtained earlier
-
run the server:
node src/server.js
Use standalone scripts to test and validate the payment flow to simulate the "Frontend" :
-
payments.js: Execute the complete payment initiation flow
cd scripts node payments.jsThis script:
- Gets an access token
- Creates a payment consent
- Generates an authorization URL
- After user authorization, initiates the payment
- Saves results to paymentInitResponse.json and paymentConsentResponse.json
-
checkPaymentStatus.js: Verify the status of an initiated payment
cd scripts node checkPaymentStatus.jsNote: The sandbox environment payments remain in "Pending" status. To see a "Confirmed" status, you need to manually use the Business API to simulate the state change.
-
verifyRevolutJws.js: Verify the JWS signature and certificates
cd scripts node verifyRevolutJws.jsThis script:
- Verifies JWS signatures using the crypto library
- Parses the certificate data
- Performs certificate validation (both high-level and low-level)
- Attempts OCSP verification (partial implementation)
Run the server for integration with frontend applications:
node src/server.js
- POST /initiate-payment: Creates a payment consent and returns authorization URL
- POST /execute-payment: Completes the payment after user authorization
- GET /payment-status/:paymentId: Retrieves current payment status
- POST /commitment: Creates a new commitment record
- GET /commitment/:hash: Retrieves a commitment by hash
- GET /commitments: Lists all commitments
- DELETE /commitments: Purges all commitments
The server uses a simple SQLite database (commitments.sqlite) to store and track payment commitments. Each commitment record contains:
- Hash: Unique identifier for the commitment
- Amount: Payment amount
- Currency: Payment currency
- Debtor: Sender information
- Creditor: Recipient information
- Timestamp: Creation time
The project is organized with a focus on modularity and separation of concerns. The src directory contains the core server implementation:
| File | Description |
|---|---|
| server.js | Main application entry point. Initializes Express server, sets up routes, and handles HTTPS configuration. |
| paymentService.js | Implements the core Open Banking payment functionality, including payment initiation, consent management, and JWS signature generation. |
| jws.js | Handles JSON Web Signature (JWS) creation and verification, essential for the Open Banking security protocols. |
| commitmentDb.js | Database interface for storing and retrieving payment commitments, using SQLite as the underlying storage. |
| commitments.sqlite | SQLite database file that stores payment commitment records. |
| stateManager.js | Manages application state, particularly for the OAuth flow and session handling. |
| callback.js | Processes callbacks from the Open Banking authorization server after user consent. |
| callback.html | HTML template displayed to users after the authorization flow completes. |
The scripts directory contains standalone utilities for testing and verification:
- payments.js: Executes the complete payment flow
- checkPaymentStatus.js: Verifies payment status
- verifyRevolutJws.js: Validates JWS signatures and certificates
Contains the Open Banking certificates necessary for the trust chain:
- Root CA certificates
- Issuing CA certificates
This project is licensed under the MIT License. See the LICENSE file for details.