1. Go to this page and download the library: Download znojil/revolut-business library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
znojil / revolut-business example snippets
use Znojil\RevolutBusiness\Client;
use Znojil\RevolutBusiness\Config;
use Znojil\RevolutBusiness\FileTokenStorage;
$config = new Config(
clientId: 'YOUR_CLIENT_ID',
issuer: 'example.com', // the domain of your redirect URI
privateKey: file_get_contents('/path/to/privatekey.pem'),
sandbox: false // true for the sandbox environment
);
$client = new Client($config, new FileTokenStorage('/path/to/tokens.json'));
// once, with the code from the redirect
$client->authorize($_GET['code']);
use Znojil\RevolutBusiness\Request\GetAccountsRequest;
foreach($client->send(new GetAccountsRequest) as $account){
$account->id; // string
$account->name; // ?string
$account->balance; // float
$account->currency; // Currency enum, or string for a currency not in the enum
$account->state; // AccountState enum
$account->accountType; // AccountType enum
$account->createdAt; // DateTimeImmutable
}
use Znojil\RevolutBusiness\DTO\PaymentReceiverDTO;
use Znojil\RevolutBusiness\Enum\Currency;
use Znojil\RevolutBusiness\Enum\TransferReasonCode;
use Znojil\RevolutBusiness\Request\CreatePaymentRequest;
$result = $client->send(new CreatePaymentRequest(
accountId: '05018b0d-e67c-4fec-bea6-415e9da9432c',
receiver: new PaymentReceiverDTO('7e18625a-3e6c-4d4f-8429-216c25309a5f', null, null),
amount: 123.45,
currency: Currency::Gbp,
requestId: 'invoice-2026-03', // your own idempotency key
reference: 'Invoice 2026/03',
transferReasonCode: TransferReasonCode::Services
));
$result->id; // string
$result->state; // TransactionState enum
use Znojil\RevolutBusiness\TokenPair;
use Znojil\RevolutBusiness\TokenStorage;
final class MyTokenStorage implements TokenStorage{
public function load(): ?TokenPair{
// return null when nothing is stored yet
}
public function save(TokenPair $tokenPair): void{
$tokenPair->accessToken; // string
$tokenPair->expirationDatetime; // DateTimeImmutable
$tokenPair->refreshToken; // string
}
}
$client = new Client($config, new MyTokenStorage);
use Znojil\RevolutBusiness\Client;
use Znojil\RevolutBusiness\Http\Client as RevolutHttpClient;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
class MyCustomHttpClient implements RevolutHttpClient{
public function send(string $method, string|UriInterface $uri, array $headers = [], mixed $data = null, array $options = []): ResponseInterface{
// your implementation
}
}
$client = new Client($config, $tokenStorage, new MyCustomHttpClient);
use Znojil\RevolutBusiness\Clear;
use Znojil\RevolutBusiness\Request\UpdatePaymentDraftRequest;
// only the title is sent, the schedule stays as it is
$client->send(new UpdatePaymentDraftRequest($draftId, title: 'New title'));
// the schedule is explicitly removed
$client->send(new UpdatePaymentDraftRequest($draftId, scheduleFor: Clear::Value));
use Znojil\RevolutBusiness\Enum\Currency;
use Znojil\RevolutBusiness\Request\GetAccountRequest;
$account = $client->send(new GetAccountRequest($accountId));
if($account->currency instanceof Currency){
// a known currency
}else{
// a currency not covered by the enum, as a raw string
}
use Znojil\RevolutBusiness\Auth\Exception\AuthenticationException;
use Znojil\RevolutBusiness\Exception\ClientException;
use Znojil\RevolutBusiness\Exception\ServerException;
try{
$result = $client->send(new CreatePaymentRequest(...));
}catch(ClientException $e){
echo $e->getMessage(); // error message from Revolut
echo $e->getCode(); // HTTP status code
echo $e->apiErrorCode; // ?int error code from Revolut
echo $e->apiErrorId; // ?string error id, useful when contacting support
}catch(ServerException $e){
// Revolut server error (5xx)
}catch(AuthenticationException $e){
// the refresh token has expired or been revoked — run the consent flow again
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.