Last active
June 2, 2017 06:11
-
-
Save olyjosh/e942d6322cfc2949957d64dcd1396e17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'remita_constants.php'; | |
require 'server/conn.php'; | |
$json = file_get_contents('php://input'); | |
//die($json); | |
$arr = json_decode($json, true); | |
try { | |
if ($arr != null) { | |
foreach ($arr as $key => $value) { | |
$orderRef = $value['orderRef']; | |
//Confirm transaction Status to be sure it is coming from Remita | |
$response = remita_transaction_details($orderRef); | |
$response_code = $response['status']; | |
$response_reason = $response['message']; | |
$rrr = $response['RRR']; | |
$orderId = $response['orderId']; | |
//die($response_reason); | |
if ($response_code == '01' || $response_code == '00') { | |
//Payment Successful, You can Update Status to Paid here on Database; | |
updateDatabase($orderRef, $response_code, $rrr, $conn); | |
} | |
} | |
exit('OK'); | |
} | |
} catch (Exception $e) { | |
exit('Not OK'); | |
} | |
function remita_transaction_details($orderId) | |
{ | |
$mert = ""; | |
$api_key = ""; | |
$mode = "Test"; | |
$hash_string = $orderId . $api_key . $mert; | |
$hash = hash('sha512', $hash_string); | |
if ($mode == 'Test') { | |
$query_url = 'http://www.remitademo.net/remita/ecomm'; | |
} else if ($mode == 'Live') { | |
$query_url = 'https://login.remita.net/remita/ecomm'; | |
} | |
$url = $query_url . '/' . $mert . '/' . $orderId . '/' . $hash . '/' . 'orderstatus.reg'; | |
$result = file_get_contents($url); | |
$response = json_decode($result, true); | |
return $response; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment