-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnagad-payment-status.php
46 lines (35 loc) · 1.33 KB
/
nagad-payment-status.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
41
42
43
<?php
use Xenon\NagadApi\Helper;
require 'vendor/autoload.php';
if($_GET['status'])
{
$config = [
'NAGAD_APP_ENV' => 'development', //development|production
'NAGAD_APP_LOG' => '1',
'NAGAD_APP_ACCOUNT' => 'xxxxxxxxxx', //demo
'NAGAD_APP_MERCHANTID' => '6830x25', //demo
'NAGAD_APP_MERCHANT_PRIVATE_KEY' => '',
'NAGAD_APP_MERCHANT_PG_PUBLIC_KEY' => '',
'NAGAD_APP_TIMEZONE' => 'Asia/Dhaka',
];
$uri = $_SERVER['REQUEST_URI'];
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$responseUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$responseArray = Helper::successResponse($responseUrl);
if (isset($responseArray['payment_ref_id']))
{
$helper = new Helper($config);
try {
$response = $helper->verifyPayment($responseArray['payment_ref_id']);
$responseObject = json_decode($response, true);
if (isset($responseObject['status']) && $responseObject['status'] =='Success')
{
echo 'Payment successfully done';
}else{
echo 'Failed to pay. Something went wrong';
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
}