-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfirmationUrl.php
33 lines (28 loc) · 1.59 KB
/
confirmationUrl.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
<?php
require '../wp-config.php';
$mpesaResponse = file_get_contents('php://input');
$callback_confirmation_message=array("ResCode"=>0, "ResDescription"=>"Mpesa data received successfully");
print_r(json_encode($callback_confirmation_message));
file_put_contents('M_PESAConfirmationResponse.txt',$mpesaResponse,FILE_APPEND);
$jsonMpesaResponse = json_decode($mpesaResponse, true);
$transaction = array(
'TransactionType' => $jsonMpesaResponse['TransactionType'],
'TransID' => $jsonMpesaResponse['TransID'],
'TransTime' => $jsonMpesaResponse['TransTime'],
'TransAmount' => $jsonMpesaResponse['TransAmount'],
'BusinessShortCode' => $jsonMpesaResponse['BusinessShortCode'],
'BillRefNumber' => $jsonMpesaResponse['BillRefNumber'],
'InvoiceNumber' => $jsonMpesaResponse['InvoiceNumber'],
'OrgAccountBalance' => $jsonMpesaResponse['OrgAccountBalance'],
'ThirdPartyTransID' => $jsonMpesaResponse['ThirdPartyTransID'],
'MSISDN' => $jsonMpesaResponse['MSISDN'],
'FirstName' => $jsonMpesaResponse['FirstName'],
'MiddleName' => $jsonMpesaResponse['MiddleName'],
'LastName' => $jsonMpesaResponse['LastName']
);
// insert data to db.
// global $wpdb;
// $table_name = $wpdb->$table_prefix . 'mobile_payments';
// $wpdb->insert_response($table_name,$transaction);
insert_response($transaction);
?>