This repository contains an example integration of Revolut Pay, demonstrating how to integrate Revolut Pay's payment processing capabilities in your web application. It includes setup instructions, webhook configuration, and testing guidelines using Revolut's Merchant API.
- Node.js 16 or later
-
Clone this repo
$ git clone [email protected]:revolut-engineering/revolut-checkout-example.git $ cd revolut-checkout-example/server
-
Install dependencies
$ npm install
-
Create a Revolut Business sandbox account
-
Update your API keys
Copy and rename
.env.example
file to.env
and update it with your keysREVOLUT_API_PUBLIC_KEY=<your_revolut_public_key> REVOLUT_API_SECRET_KEY=<your_revolut_secret_key>
-
Run the server
$ npm start
Tip
For testing purposes you can use our test cards.
For testing other environments you can change the REVOLUT_API_URL
, update you Revolut keys and start the server again.
The Revolut Merchant API supports webhooks to push event notifications corresponding to order and payment status changes to an specified URL.
Note
For more information, see: Use webhooks to keep track of the payment lifecycle
-
Set a public URL for your localhost
Use ngrok or any similar tool to obtain a public URL.
$ npm install ngrok -g $ ngrok http 5177
-
Set up a webhook URL in the Merchant API
Check the Create a webhook endpoint in the Merchant API specification.
Replace
<yourSecretApiKey>
with the same key you used in the.env
file (REVOLUT_API_SECRET_KEY
) and<yourPublicUrl>
with the public URL obtained in the previous step.curl -L -X POST 'https:/sandbox-merchant.revolut.com/api/1.0/webhooks' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: Bearer <yourSecretApiKey>' \ --data-raw '{ "url": "<yourPublicUrl>", "events": [ "ORDER_COMPLETED", "ORDER_AUTHORISED" ] }'
The response has the following JSON structure:
{ "id": "396a4d93-70c3-44ca-8fb9-ca903a5505d7", "url": "<your_public_url>/webhook", "events": ["ORDER_COMPLETED", "ORDER_AUTHORISED"], "signing_secret": "<signing_secret_key>" }
-
Use the
signing_secret
in your.env
file (REVOLUT_WEBHOOK_SECRET
) and start the server. -
You should see events logged in the console where the CLI is running.
Read more about Revolut Pay on our official Developer Portal.
@revolut/checkout
- RevolutCheckout.js as npm module
© Revolut LTD