-
Notifications
You must be signed in to change notification settings - Fork 42
/
AccountBalance.php
32 lines (32 loc) · 1.11 KB
/
AccountBalance.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
<?php
include 'accessToken.php';
include 'securitycridential.php';
$AccountBalanceUrl = 'https://sandbox.safaricom.co.ke/mpesa/accountbalance/v1/query';
$InitiatorName = '';
$pass = "";
$BusinessShortCode = "";
$request_data = array(
'Initiator' => $InitiatorName,
'SecurityCredential' => $SecurityCredential,
'CommandID' => 'AccountBalance',
'PartyA' => $BusinessShortCode,
'IdentifierType' => '4',
'Remarks' => 'ok',
'QueueTimeOutURL' => 'https://1c95-105-161-14-223.ngrok-free.app/MPEsa-Daraja-Api/QueueTimeOutURL.php',
'ResultURL' => 'https://1c95-105-161-14-223.ngrok-free.app/MPEsa-Daraja-Api/ResultURL.php',
);
$data_string = json_encode($request_data);
$headers = array(
'Content-Type: application/json',
'Authorization:Bearer ' . $access_token
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $AccountBalanceUrl);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>