hmimeee / revolut
A package to integrate Revolut payment gateway. Revolut is a British financial technology company that offers banking services, but as of December 2022 does not have a UK banking licence.
Requires
- php: >=5.6.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
Requires (Dev)
- guzzlehttp/guzzle: *
- phpunit/phpunit: ^5.7 || ^9.0
README
A package to integrate Revolut payment gateway. Revolut is a British financial technology company that offers banking services, but as of December 2022 does not have a UK banking licence.
Read the documentation below to integrate the library for your PHP Application.
Requirements
PHP 5.6.0 and later.
Composer
You can install the bindings via Composer. Run the following command:
composer require hmimeee/revolut
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Dependencies
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Getting Started
Simple usage looks like:
$revolut = getRevolut([ 'env' => 'sandbox', //or, live 'key' => 'Your marchant secret key here' ]); $response = $revolut->createOrder([ 'amount' => 1210, //The amount must be the smallest currency unit like (from $12.10 to 1210) 'currency' => 'GBP', 'description' => 'An example order', //Can skip it as it's optional. 'name' => 'John Doe', //Can skip it as it's optional. 'email' => 'email@example.com', //Can skip it as it's optional. ]); if ($response['status']) { $orderId = $response['data']->id; //Keep the Order ID to verify the payment in the Webhook Endpoint. header("location:" . $response['data']->checkout_url); } else { echo $response['message']; }
Webhook Endpoint Preparing
A Post request will be sent from Revolut along with the data below:
{ "event": "ORDER_COMPLETED", "order_id": "9fc01989-3f61-4484-a5d9-ffe768531be9", "merchant_order_ext_ref": "Test #3928" }
Now match with the Order ID and take your further action like the code below:
if($_POST['event'] == 'ORDER_COMPLETED') { //Match that previous $orderId with $_POST['order_id'], and take proper action. }
💥 Boom! You've done everything.