| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/HostingSpaces/admin/penpalamerica.com/wwwroot/penpal/webhooks/ |
Upload File : |
<?php
include "general.php";
include "connect.php";
// Retrieve the request's body
$body = rawurldecode(@file_get_contents("php://input"));
// retrieve the signature sent in the reques header's.
$signature = (isset($_SERVER['HTTP_VERIF_HASH']) ? $_SERVER['HTTP_VERIF_HASH'] : '');
//$body = "id=585525748&txRef=amebqdbwyuMKI&flwRef=OQOJ9020929056098&orderRef=URF_1645832382783_1398235&paymentPlan=1000&paymentPage=&createdAt=2022-02-25T23%3A39%3A43.000Z&amount=50&charged_amount=50.7&status=successful&IP=105.112.28.98¤cy=NGN&appfee=0.7&merchantfee=0&merchantbearsfee=0&customer%5Bid%5D=340782575&customer%5Bphone%5D=&customer%5BfullName%5D=Jackson%20&customer%5Bcustomertoken%5D=&customer%5Bemail%5D=nosa.osahon%40penpalamerica.com&customer%5BcreatedAt%5D=2022-02-25T23%3A39%3A43.000Z&customer%5BupdatedAt%5D=2022-02-25T23%3A39%3A43.000Z&customer%5BdeletedAt%5D=&customer%5BAccountId%5D=129120&entity%5Bid%5D=16929276&entity%5Bcard6%5D=559432&entity%5Bcard_last4%5D=0112&entity%5Bcard_country_iso%5D=NG&entity%5BcreatedAt%5D=2021-04-23T12%3A25%3A40.000Z&event.type=CARD_TRANSACTION";
$params = explode('&',$body);
//echo "Nosa".$params[19];
foreach ($params as $param) {
if($params[19]==$param){
$name_value = explode('=', $param);
$email = $name_value[1];
//$value = $name_value[1];
}
// ... Collect them yourself.
}
//echo $email;
//exit();
/* It is a good idea to log all events received. Add code *
* here to log the signature and body to db or file */
$query ="insert into penpalflutterwavelogs (body) VALUES ('$body')";
//echo $query;
$queryresponse = updateQuery($query);
if (!$signature) {
// only a post with rave signature header gets our attention
exit();
}
// Store the same signature on your server as an env variable and check against what was sent in the headers
$local_signature = getenv('SECRET_HASH');
// confirm the event's signature
if( $signature !== $local_signature ){
// silently forget this ever happened
exit();
}
http_response_code(200); // PHP 5.4 or greater
// parse event (which is json string) as object
// Give value to your customer but don't give any output
// Remember that this is a call from rave's servers and
// Your customer is not seeing the response here at all
$status =$_POST["status"];
//$email=rawurldecode( $_POST["customer[email]"]);
$amount =$_POST["amount"];
$txtRef =$_POST["txRef"];
$id =$_POST["id"];
$charged_amount =$_POST["charged_amount"];
if ($status == 'successful') {
if (substr($txtRef,0,3)=="ame"){
$domain ="penpalamerica.com";
}
//$body = "$domain $email $txtRef";
//$query ="insert into penpalflutterwavelogs (body) VALUES ('$body')";
if (substr($txtRef,0,3)=="eur"){
$domain ="penpaleurope.com";
}
if (substr($txtRef,0,3)=="asi"){
$domain ="penpalasia.com";
}
if (substr($txtRef,0,3)=="afr"){
$domain ="penpalafrica.com";
}
//update user wallet
$query = "select wallet from penpal where domain ='$domain' and email ='$email'";
$old_wallet = getQuery1($query);
$new_wallet = ($amount*10)+ $old_wallet;
$query = "update penpal set wallet ='$new_wallet' where domain ='$domain' and email ='$email'";
$queryresponse = updateQuery($query);
//update user wallet backup
$query = "select wallet_backup from penpal where domain ='$domain' and email ='$email'";
$old_wallet_backup = getQuery1($query);
$new_wallet_backup = ($amount*10)+ $old_wallet_backup;
$query = "update penpal set wallet_backup ='$new_wallet_backup' where domain ='$domain' and email ='$email'";
$queryresponse = updateQuery($query);
//log the transactions
$query = "insert into flutterwavelogs (id,tx_ref,email,old_wallet,amount,new_wallet,charged_amount,old_wallet_backup,new_wallet_backup,domain) values ('$id','$txtRef','$email','$old_wallet','$amount','$new_wallet','$charged_amount','$old_wallet_backup','$new_wallet_backup','$domain')
";
$queryresponse = updateQuery($query);
}
exit();
?>