-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.php
38 lines (30 loc) · 1.29 KB
/
config.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
34
35
36
37
38
<?php
function insert_response($jsonMpesaResponse){
$dbName = 'tezripol_jugoma_prime_house';
$dbHost = 'localhost';
$dbUser = 'tezripol_jugoma';
$dbPass = 'hIs4UoY7m{le';
try{
$con = new PDO("mysql:dbhost=$dbHost;dbname=$dbName", $dbUser, $dbPass);
//echo "Connection was successful";
}
catch(PDOException $e){
die("Error Connecting ".$e->getMessage());
}
try{
$insert = $con->prepare("INSERT INTO `wp_mobile_payments`(`TransactionType`, `TransID`, `TransTime`, `TransAmount`, `BusinessShortCode`, `BillRefNumber`, `InvoiceNumber`, `OrgAccountBalance`, `ThirdPartyTransID`, `MSISDN`, `FirstName`, `MiddleName`, `LastName`) VALUES (:TransactionType, :TransID, :TransTime, :TransAmount, :BusinessShortCode, :BillRefNumber, :InvoiceNumber, :OrgAccountBalance, :ThirdPartyTransID, :MSISDN, :FirstName, :MiddleName, :LastName)");
$insert->execute((array)($jsonMpesaResponse));
$Transaction = fopen('Transaction.txt', 'a');
fwrite($Transaction, json_encode($jsonMpesaResponse));
fclose($Transaction);
}
catch(PDOException $e){
$errLog = fopen('error.txt', 'a');
fwrite($errLog, $e->getMessage());
fclose($errLog);
$logFailedTransaction = fopen('failedTransaction.txt', 'a');
fwrite($logFailedTransaction, json_encode($jsonMpesaResponse));
fclose($logFailedTransaction);
}
}
?>