-
Notifications
You must be signed in to change notification settings - Fork 47
/
Reversals.php
32 lines (32 loc) · 1.13 KB
/
Reversals.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';
$ReversalsUrl = 'https://sandbox.safaricom.co.ke/mpesa/reversal/v1/request';
$request_data = array(
'Initiator' => 'testapi',
'SecurityCredential' => $SecurityCredential,
'CommandID' => 'TransactionReversal',
'TransactionID' => 'OEI2AK4Q16',
'Amount' => '1',
'ReceiverParty' => '600992',
'RecieverIdentifierType' => '11',
'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',
'Remarks' => 'Test',
'Occasion' => 'work',
);
$data_string = json_encode($request_data);
$headers = array(
'Content-Type: application/json',
'Authorization: Bearer ' . $access_token
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $ReversalsUrl);
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;
?>