Gluwa SDK for PHP

If your service is developed in PHP, the features we provide are available through the SDK. The Gluwa SDK for PHP is a library with powerful features that enable PHP developers to easily make requests to the Gluwa APIs.

Getting started

Download the PHP Package below and upload it to your server. The SDK requires PHP 5.6 or greater.

$ composer require gluwa/gluwa-php

Create and initialize a Gluwa object. Then, enter the APIKey, APISecret and WebookSecret generated from the Gluwa Dashboard, and an Ethereum wallet to manage your funds. You can use credentials from sandbox dashboard and a Rinkeby wallet if you want to test in the sandbox environment.

require_once('../___library/Gluwa/autoload.php');
$GluwaPro = new \Gluwa\Gluwa([
'__DEV__' => false, // "true" if you want to use the sandbox mode.
'APIKey' => '',
'APISecret' => '',
'WebhookSecret' => '',
'MasterEthereumPrivateKey' => '',
'MasterEthereumAddress' => '',
]);

If you are using PHP 5.6, you need to enable php-bcmath because it is not enabled by default prior PHP 7. If it is not installed yet, just install it. Please visit here for more information.

If you receive the following message, you should install gmp extention on your server. Please visit this site to find a solution.

Function gmp_init is unavailable. Please make sure php_gmp extension is available

Now you are ready to use the Gluwa API.

Method Examples

$Response = $Gluwa->postTransaction([
'Currency' => 'USDG',
'Amount' => '1.78',
'Target' => '', // Required - Target Address
'MerchantOrderID' => '', // optional
'Note' => '', // optional
'Expiry' => 1800, // optional
]);

$Response = $Gluwa->getPaymentQRCode([
'Currency' => 'USDG',
'Amount' => '1',
'Note' => '', // optional
'MerchantOrderID' => '', // optional
'Expiry' => 1800, // optional
]);

$Response = $Gluwa->getListTransactionHistory([
'Currency' => 'USDG',
'Limit' => '100', // optional
'Status' => 'Confirmed', // optional
'Offset' => '0', // optional
]);

$Response = $Gluwa->getListTransactionDetail([
'Currency' => 'USDG',
'TxnHash' => '',
]);

$Response = $Gluwa->getAddresses([
'Currency' => 'USDG',
]);

When user completes transfer via the QR code, the Gluwa API sends a webhook to your webhook endpoint. Verify that the values ​​actually sent by the Gluwa server are correct.

Payload and Signature of webhook can be obtained as follows:

$Headers = getallheaders();
$Signature = $Headers['X-REQUEST-SIGNATURE'];
$Payload = file_get_contents("php://input");

Verify the requested Signature and Payload as follows:

$Response2 = $Gluwa->validateWebhook([
'Payload' => $Payload,
'Signature' => $Signature,
]);
Response

Type

Description

boolean

This will return true if it is a valid webhook. If it returns false, user didn't successfully process the deposit.