Skip to content

Commit

Permalink
debugging the validation and confirmation urls
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-Wambua committed Nov 12, 2022
1 parent 7f4c2aa commit aa3c672
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
17 changes: 6 additions & 11 deletions confirmation_url.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<?php
header('Content-type: application/json');

$responce = '{
"ResultCode" : 0,
"ResultDesc" : "Confirmation received succesfully"
}';

//DATA
$mpesaResponce = file_get_contents('php://input');

//log the responce
$logfile= "M-PESAConfirmationResponceContent.txt";
$jsonMpesaresponce = json_decode($mpesaResponce,TRUE);
$mpesaResponcejson = file_get_contents('php://input');
//Put the resultng json in a php variable
$Mpesaresponce = json_decode($mpesaResponcejson,true);

//write to file
$log = fopen($logfile,'a+');
fwrite($log,$mpesaResponce);
$log = fopen('MpesaConfirmationResponce.txt','a');
fwrite($log,$mpesaResponcejson);
fclose($log);


echo $responce;



?>
4 changes: 3 additions & 1 deletion simulate.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$url = 'https://sandbox.safaricom.co.ke/mpesa/c2b/v1/simulate';

$curl = curl_init();

$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);

curl_setopt($curl, CURLOPT_HTTPHEADER, [
Expand All @@ -25,5 +25,7 @@

$curl_responce = curl_exec($curl);
print_r($curl_responce);


echo $curl_responce;
?>
13 changes: 5 additions & 8 deletions validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
}';

//DATA
$mpesaResponce = file_get_contents("php://input");

//log the responce
// then the string above is converted again into a php variable
$logfile= "ValidationResponceContent.txt";
$jsonMpesaresponce = json_decode($mpesaResponce,true);
$mpesaResponcejson = file_get_contents('php://input');
//Put the resultng json in a php variable
$Mpesaresponce = json_decode($mpesaResponcejson,true);

//write to file
$log = fopen($logfile,'a');
fwrite($log,$mpesaResponce);
$log = fopen('ValidationResponce.txt','a');
fwrite($log,$mpesaResponcejson);
fclose($log);


Expand Down

0 comments on commit aa3c672

Please sign in to comment.