-
Notifications
You must be signed in to change notification settings - Fork 4
/
example-redirect.php
40 lines (34 loc) · 953 Bytes
/
example-redirect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* ZainCash PHP SDK
* @version 1.0.0
*
* @package ZainCashSDK
*
* @author Alhasan Ahmed Al-Nasiry <alhasan.nasiry@gmail.com>
*/
require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload
use AlhasanIQ\ZainCashSDK;
use Dotenv\Dotenv;
$dotenv = new Dotenv(__DIR__);
$dotenv->load();
try {
if (isset($_GET['token'])) {
$zc = new ZainCashSDK([
'msisdn' => $_ENV['ZC_MSISDN'],
'secret' => $_ENV['ZC_SECRET'],
'merchantid' => $_ENV['ZC_MERCHANTID'],
'production_cred' => ($_ENV['ZC_ENV_PRODUCTION'] === 'true'),
'language' => 'en', // 'en' or 'ar'
'redirection_url' => 'https://example.com/test-redirect.php'
]);
$result = $zc->decode($_GET['token']);
if ($result['status'] == 'success') {
// do something (ex: show sucess message)
} else {
// do something (ex: show errors)
}
}
} catch (Exception $e) {
echo $e->getMessage();
}