-
Notifications
You must be signed in to change notification settings - Fork 20
/
bKash-for-Raw-PHP.php
82 lines (44 loc) · 2 KB
/
bKash-for-Raw-PHP.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
// bKash Merchant Information
$msisdn = "01200000000"; // bKash Merchant Number
$user = "Xyz"; // bKash Merchant Username
$pass = "123"; // bKash Merchant Password
$url = "https://www.bkashcluster.com:9081"; // bKash API URL with Port Number
$trxid = "66666AAAAA"; // bKash Transaction ID : TrxID
// Final URL for getting response from bKash
$bkash_url = $url.'/dreamwave/merchant/trxcheck/sendmsg?user='.$user.'&pass='.$pass.'&msisdn='.$msisdn.'&trxid='.$trxid;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_PORT => 9081,
CURLOPT_URL => $bkash_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
//print_r($response); // For Getting all Response Data.
$api_response = json_decode ($response, true); // Getting Response from bKash API.
$transaction_status = $api_response['transaction']['trxStatus']; // Transaction Status Codes
if ($err || $transaction_status == "4001") {
echo 'Problem for Sending Response to bKash API ! Try Again after fews minutes.';
}
else
{
// Assign Transaction Information
$transaction_amount = $api_response['transaction']['amount']; // bKash Payment Amount
$transaction_reference = $api_response['transaction']['reference']; // bKash Reference for Invoice ID
$transaction_time = $api_response['transaction']['trxTimestamp']; // bKash Transaction Time & Date
// Print Transaction Information
echo $transaction_status."<br>".$transaction_amount."<br>".$transaction_reference."<br>".$transaction_time;
}
?>