|
| 1 | +<?php |
| 2 | + |
| 3 | +// bKash Merchant Information |
| 4 | + |
| 5 | +$msisdn = "01200000000"; // bKash Merchant Number |
| 6 | + |
| 7 | +$user = "Xyz"; // bKash Merchant Username |
| 8 | + |
| 9 | +$pass = "123"; // bKash Merchant Password |
| 10 | + |
| 11 | +$url = "https://www.bkashcluster.com:9081"; // bKash API URL with Port Number |
| 12 | + |
| 13 | +$trxid = "66666AAAAA"; // bKash Transaction ID : TrxID |
| 14 | + |
| 15 | + |
| 16 | +// Final URL for getting response from bKash |
| 17 | + |
| 18 | +$bkash_url = $url.'/dreamwave/merchant/trxcheck/sendmsg?user='.$user.'&pass='.$pass.'&msisdn='.$msisdn.'&trxid='.$trxid; |
| 19 | + |
| 20 | + |
| 21 | +$curl = curl_init(); |
| 22 | + |
| 23 | +curl_setopt_array($curl, array( |
| 24 | + |
| 25 | + CURLOPT_PORT => 9081, |
| 26 | + |
| 27 | + CURLOPT_URL => $bkash_url, |
| 28 | + |
| 29 | + CURLOPT_RETURNTRANSFER => true, |
| 30 | + |
| 31 | + CURLOPT_ENCODING => "", |
| 32 | + |
| 33 | + CURLOPT_MAXREDIRS => 10, |
| 34 | + |
| 35 | + CURLOPT_TIMEOUT => 30, |
| 36 | + |
| 37 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
| 38 | + |
| 39 | + CURLOPT_CUSTOMREQUEST => "GET", |
| 40 | + |
| 41 | + CURLOPT_HTTPHEADER => array( |
| 42 | + |
| 43 | + "cache-control: no-cache", |
| 44 | + |
| 45 | + "content-type: application/json" |
| 46 | + ), |
| 47 | + |
| 48 | +)); |
| 49 | + |
| 50 | +$response = curl_exec($curl); |
| 51 | + |
| 52 | +$err = curl_error($curl); |
| 53 | + |
| 54 | +$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
| 55 | + |
| 56 | +curl_close($curl); |
| 57 | + |
| 58 | + if ($err) { |
| 59 | + echo $err; |
| 60 | + } |
| 61 | + else |
| 62 | + { |
| 63 | + $api_response = json_decode ($response, true); // Getting Response from bKash API |
| 64 | + |
| 65 | + //print_r($response); // For Getting all Response Data |
| 66 | + |
| 67 | +// Assign Transaction Information |
| 68 | + |
| 69 | + $transaction_status = $api_response['transaction']['trxStatus']; // Transaction Status Codes |
| 70 | + |
| 71 | + $transaction_amount = $api_response['transaction']['amount']; // bKash Payment Amount |
| 72 | + |
| 73 | + $transaction_reference = $api_response['transaction']['reference']; // bKash Reference for Invoice ID |
| 74 | + |
| 75 | + $transaction_time = $api_response['transaction']['trxTimestamp']; // bKash Transaction Time & Date |
| 76 | + |
| 77 | +// Print Transaction Information |
| 78 | + |
| 79 | + echo $transaction_status."<br>".$transaction_amount."<br>".$transaction_reference."<br>".$transaction_time; |
| 80 | + } |
| 81 | +?> |
0 commit comments