This tutorial presents how to create a file payment, which allows you to initiate a transaction batch with a single consent.
File payments are available only for Revolut Business users.
The procedure is similar to the procedure for other payment endpoints, but it includes additional steps and considerations required to upload the batch files.
Before you begin, ensure that you have:
payments
scope in the Developer Portalclient_id
from the Developer Portaltransport.pem
and signing.pem
certificates, from the Developer Portal or QTSP issuing bodyjwks_url
in the Developer Portal that is specific to your signing.pem
certificate. Ensure that the x5c
claim is specified.If unsure, head to Get Started and review the setup process.
,
):Field | Required | Description |
---|---|---|
Name | Yes | Can contain up to 80 characters. If recipient type is INDIVIDUAL , this field must contain a first and a last name, separated by a space. |
Recipient type | Yes | Can be either INDIVIDUAL or COMPANY . |
Account number | For non-IBAN countries | Must contain valid account number if provided. |
Sort code or Routing number | For UK/US local transfers | Must contain valid sort code or routing number if provided. |
IBAN | For IBAN countries | Must contain valid IBAN if provided. |
BIC | All the countries except for UK/US local | Must contain valid BIC if provided. |
Recipient bank country | Yes | Must contain a valid ISO 3166-1 country code. |
Currency | Yes | Must contain valid ISO 4217 currency code. |
Amount | Yes | Must match the following pattern [0-9]*(\.[0-9]*)? . |
Payment reference | Yes | Can contain up to 100 characters. |
Recipient country | No | Must contain a valid ISO 3166-1 country code if provided. |
State or province | No | Can contain up to 50 characters. |
Address line 1 | No | Can contain up to 50 characters. |
Address line 2 | No | Can contain up to 50 characters. |
City | No | Can contain up to 50 characters. |
Postal code | No | Can contain up to 50 characters. |
For the purpose of this tutorial, we will use the following sample file contents and save it as file.csv
:
Name,Recipient type,Account number,Sort code or Routing number,IBAN,BIC,Recipient bank country,Currency,Amount,Payment reference,Recipient country,State or province,Address line 1,Address line 2,City,Postal code
John Smith,INDIVIDUAL,40513598,207409,,,GB,GBP,10,First comment,GB,,Revolutest LTD,Somewhere in London,London,E14 5AB
John Doe,INDIVIDUAL,90352556,600001,,,GB,GBP,10,Second comment,GB,,Revolutest LTD,Somewhere in London,London,E14 5AB
If you use your own CSV file, remember to replace the file name later when you compute the hash.
Compute the SHA256
hash of the CSV file. To do it from a Command Line Interface (CLI), follow these steps:
Open the CLI, for example, Terminal in macOS.
In your CLI, navigate to the directory in which you saved the CSV file.
Compute the SHA256
hash of your CSV file.
If you're using your own CSV file, replace file.csv
with your file's name.
cat file.csv | shasum -a 256 | xxd -r -p | base64
The above command returns the SHA256
hash of the CSV file. For our sample file.csv
, this would be:
2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=
Save the resulting hash for further steps.
The resulting hash will be different with any minor modification to the file, so it uniquely identifies the contents of the file.
Request an access token for client credentials using the /token
endpoint and the client_credentials
grant type with the scope payments
:
curl --cert transport.pem --key private.key \
--location --request POST 'https://oba-auth.revolut.com/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=payments' \
--data-urlencode 'client_id=<your client_id>'
Response:
{
"access_token": "<JWT client credentials>",
"token_type": "Bearer",
"expires_in": 2399
}
You can use this token to:
When your token expires and you need a new one, repeat this procedure to generate a new token.
Create a consent to initiate a file payment on behalf of a Revolut customer.
When you create the consent, ensure that you:
Use your access token that you obtained with grant_type=client_credentials
as the Bearer token.
Specify the x-idempotency-key
header so that when there is a network failure and you do not receive the ID from the response, you can safely retry the request.
Provide the x-jws-signature
header in the API request.
It must contain a valid JSON Web Signature (JWS) of the request payload body. When generating the signature, use the following JSON header:
{
"alg": "PS256",
"kid": "<kid parameter of your signing certificate>",
"crit": ["http://openbanking.org.uk/tan"],
"http://openbanking.org.uk/tan": "<root domain of your JWKS URL>"
}
The result is a string consisting of the above header in base64 encoding, followed by two dots and the cryptographic signature.
The signature in the JWS validates the header and payload as text, so make sure the payload used when generating the signature is exactly the same as the payload sent in the request payload, including JSON formatting, line breaks and spacing.
You can read more about JSON Web Signatures here.
Make a file payment consent request. An example request looks like this:
curl --location --request POST 'https://oba.revolut.com/file-payment-consents' \
--header 'x-fapi-financial-id: 001580000103UAvAAM' \
--header 'Content-Type: application/json' \
--header 'x-idempotency-key: 123' \
--header 'Authorization: Bearer <insert JWT client credentials from step 3.>' \
--header 'x-jws-signature: <insert JWS>' \
--data '{
"Data": {
"Initiation": {
"FileType": "text/csv",
"FileHash": "2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=",
"FileReference": "reference1234"
}
}
}
Response:
{
"Data": {
"Status": "AwaitingUpload",
"StatusUpdateDateTime": "2023-11-08T16:23:57.491851Z",
"CreationDateTime": "2023-11-08T16:23:57.491851Z",
"ConsentId": "f3e5d778-a0b6-48c5-bae2-886f0097d51f",
"Initiation": {
"FileType": "text/csv",
"FileHash": "2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=",
"FileReference": "reference1234"
}
},
"Links": {
"Self": "https://oba.revolut.com/file-payment-consents/f3e5d778-a0b6-48c5-bae2-886f0097d51f"
},
"Meta": {
"TotalPages": 1
}
}
For the full list of available parameters and other details:
The consent has been created, and the CSV file has been loaded.
The ID of the created consent (Data.ConsentId
) is returned in the response.
Copy this value, as you will need it for further steps. In our example, the obtained consent ID is f3e5d778-a0b6-48c5-bae2-886f0097d51f
.
After the consent has been successfully created, you must upload the CSV file in a separate request.
grant_type=client_credentials
as the Bearer token.ConsentId
obtained after creating the consent.x-jws-signature
header parameter, use the same process as described in the previous step and provide the content of the CSV file as the payload.--data '@/Users/john.doe/Desktop/file.csv'
.curl --location 'https://oba.revolut.com/file-payment-consents/<insert ConsentId from step 4.>/file' \
--header 'x-fapi-financial-id: 001580000103UAvAAM' \
--header 'Content-Type: text/csv' \
--header 'x-idempotency-key: 123' \
--header 'Authorization: Bearer <insert JWT client credentials from step 3.>' \
--header 'x-jws-signature: <insert JWS>' \
--data '@<insert full path to your CSV file>'
For the full list of available parameters and other details:
On successful upload, you receive an empty JSON object as a response:
{}
After you create a consent, you need the user to authorise the consent so that you can initiate a payment on their behalf.
Create a JWT request parameter with the following header and payload. Use the private key corresponding to your signing certificate. This signature will be validated using the JWKS endpoint that you specified when you registered your application.
The values of client_id
, redirect_uri
, kid
, and scope
should correspond to those for your specific application and consent request.
The value of openbanking_intent_id
is the value of the ConsentId
field returned in the consent creation response.
state
is an OAuth parameter that lets you restore the state of the application after redirection. If provided, this value is returned in the redirect URI.
Header:
{
"alg": "PS256",
"kid": "<insert kid>"
}
Body:
{
"response_type": "code id_token",
"client_id": "<insert client_id>",
"redirect_uri": "<insert redirect_uri>",
"scope": "payments",
"state": "<insert state>",
"claims": {
"id_token": {
"openbanking_intent_id": {
"value": "<insert ConsentId>"
}
}
}
}
Create an authorisation URL with the following parameters. Make sure they are URL-encoded.
Parameter | Description | Required |
---|---|---|
response_type | Always set to code id_token . | yes |
client_id | The client ID for your application. | yes |
redirect_uri | One of the redirect URIs that you defined when you created the application. | yes |
scope | The scope that you are requesting, for example, accounts or payments . For file payments, you need the scope payments . | yes |
request | The encoded JWT generated in the previous step. | yes |
response_mode | If set to fragment , parameters are passed in the fragment section of the redirect URI. Otherwise, they are passed in the URI query. Passing parameters in fragment is considered to be more secure. | no |
A sample authorisation URL looks like this:
https://oba.revolut.com/ui/index.html?response_type=code%20id_token&scope=payments&redirect_uri=<insert redirect URL>&client_id=<insert client_id>&request=<insert JWT from step 3.>
Once you have redirected the user to the authorisation URL, they will need to provide their Revolut credentials and complete the payment authorisation.
After authorising the payment, the user will be redirected back to the redirect URL (redirect_uri
) containing the authorisation code (code
) as a URL parameter, as in the below example:
https://example.com/?code=oa_sand_sPoyVs-oMhyR36j5N-ZEVLfK9rQWPNssgIQqsOFZQ-c&id_token=<JWT id_token>&state=example_state
Use this authorisation code in the next step.
The code
is valid only for two minutes.
Exchange the code
parameter obtained when getting the consent for a new access token:
curl --key private.key --cert transport.pem \
--location --request POST 'https://oba-auth.revolut.com/token' \
--header 'Content-Type:application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode'code=<insert code>'
Response
{
"access_token":"oa_prod_tP1Nofi1ixsRfBmVBtVPdIVN0J5x91imqmheQIWTS5s",
"token_type":"Bearer",
"expires_in":86376,
"id_token":"<JWT id_token>"
}
The access token (access_token
) returned in this response will allow you to execute the batch payment.
This access token is valid only for 24 hours.
Now you can initiate the file payment on the user's behalf. Make a call to the /file-payments
endpoint to initiate the payments.
In the request body, use the same JSON content which was used previously in the consent request, and add the Data.ConsentId
key with the ConsentId
value which you received when creating the consent.
For this request, you must also use:
x-jws-signature
header, which you must calculate again with the new payload.curl --location --request POST 'https://oba.revolut.com/file-payments' \
--header 'x-fapi-financial-id: 001580000103UAvAAM' \
--header 'Content-Type: application/json' \
--header 'x-idempotency-key: 123' \
--header 'Authorization: Bearer <insert access_token from step 8.>' \
--header 'x-jws-signature: <insert JWS>' \
--data '{
"Data": {
"ConsentId": "f3e5d778-a0b6-48c5-bae2-886f0097d51f",
"Initiation": {
"FileType": "text/csv",
"FileHash": "2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=",
"FileReference": "reference1234"
}
}
}
Response:
{
"Data": {
"ConsentId": "f3e5d778-a0b6-48c5-bae2-886f0097d51f",
"CreationDateTime": "2023-11-13T13:46:47.678627Z",
"FilePaymentId": "e82cced4-8277-4220-bb0a-72775876f2ea",
"Initiation": {
"DebtorAccount": {
"SchemeName": "UK.OBIE.IBAN",
"Identification": "GB95REVO00997053872360",
"Name": "John Doe"
},
"FileHash": "2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=",
"FileReference": "reference1234",
"FileType": "text/csv"
},
"Status": "InitiationCompleted",
"StatusUpdateDateTime": "2023-11-13T13:46:47.678627Z"
},
"Links": {
"Self": "https://oba.revolut.com/file-payments/e82cced4-8277-4220-bb0a-72775876f2ea"
},
"Meta": {
"TotalPages": 1
}
}
For more details about this call:
You have successfully initiated your first file payment.
Save the FilePaymentId
value from the response so that you can later check the status of the payments execution.
After you execute a file payment, it will typically go into the InitiationInProcess
status.
To check the status of the batch payment, make a request and provide the file payment ID.
client_credentials
and scope payments
while it's still valid.
After the token has expired, generate a new one in the same way.FilePaymentId
value obtained when initiating the payment.Request:
curl --location 'https://oba.revolut.com/file-payments/<FilePaymentId>' \
--header 'x-fapi-financial-id: 001580000103UAvAAM' \
--header 'Authorization: Bearer <access_token>'
Response:
{
"Data": {
"Status": "InitiationCompleted",
"StatusUpdateDateTime": "2023-11-13T13:46:49.116202Z",
"CreationDateTime": "2023-11-13T13:46:47.678627Z",
"FilePaymentId": "e82cced4-8277-4220-bb0a-72775876f2ea",
"ConsentId": "f3e5d778-a0b6-48c5-bae2-886f0097d51f",
"Initiation": {
"DebtorAccount": {
"SchemeName": "UK.OBIE.IBAN",
"Identification": "GB95REVO00997053872360",
"Name": "John Doe"
},
"FileType": "text/csv",
"FileHash": "2nDGfxr0OI5+ts/iz9/+mk3VYTxhamlWA3P65a5LuKs=",
"FileReference": "reference1234"
}
},
"Links": {
"Self": "https://oba.revolut.com/file-payments/e82cced4-8277-4220-bb0a-72775876f2ea"
},
"Meta": {
"TotalPages": 1
}
}
For more details about this call:
You can also check the status of all the payments included in the file payment.
client_credentials
and scope payments
while it's still valid.
After the token has expired, generate a new one in the same way.FilePaymentId
value obtained when initiating the payment.Request:
curl --location 'https://oba.revolut.com/file-payments/<FilePaymentId>/report-file' \
--header 'x-fapi-financial-id: 001580000103UAvAAM' \
--header 'Authorization: Bearer <access_token>'
Response:
{
"Payments": [
{
"Amount": {
"Amount": "10.00",
"Currency": "GBP"
},
"Reference": "First comment",
"Status": "Created"
},
{
"Amount": {
"Amount": "10.00",
"Currency": "GBP"
},
"Reference": "Second comment",
"Status": "Created"
}
]
}
For more details about this call: