-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
240 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,159 +1,100 @@ | ||
<?php | ||
# Required File Includes | ||
include("../../../init.php"); | ||
include("../../../includes/functions.php"); | ||
include("../../../includes/gatewayfunctions.php"); | ||
include("../../../includes/invoicefunctions.php"); | ||
|
||
$gatewaymodule = "sslcommerz"; # Enter your gateway module name here replacing template | ||
|
||
|
||
$GATEWAY = getGatewayVariables($gatewaymodule); | ||
|
||
if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback | ||
if (!isset($_POST)) die("No Post Data To Validate!"); | ||
|
||
$invoiceid = $_POST["tran_id"]; | ||
$transid = $_POST["tran_id"]; | ||
|
||
$store_id = $GATEWAY["store_id"]; | ||
$store_passwd = $GATEWAY["store_password"]; | ||
$systemurl = $GATEWAY['systemurl']; | ||
$url_last_slash = substr($systemurl, strrpos($systemurl, '/') + 0); | ||
|
||
if($_POST['status']=='VALID' && (isset($_POST['val_id']) && $_POST['val_id'] != "") && (isset($_POST['tran_id']) && $_POST['tran_id'] != "")) | ||
{ | ||
if ($GATEWAY["testmode"] == "on") | ||
{ | ||
$requested_url = ("https://sandbox.sslcommerz.com/validator/api/validationserverAPI.php?val_id=".$val_id."&Store_Id=".$store_id."&Store_Passwd=".$store_passwd."&v=1&format=json"); | ||
} | ||
else | ||
{ | ||
$requested_url = ("https://securepay.sslcommerz.com/validator/api/validationserverAPI.php?val_id=".$val_id."&Store_Id=".$store_id."&Store_Passwd=".$store_passwd."&v=1&format=json"); | ||
} | ||
|
||
$orderData = mysql_fetch_assoc(select_query('tblinvoices', 'total', array("id" => $invoiceid))); | ||
|
||
$order_amount = $orderData['total']; | ||
|
||
$handle = curl_init(); | ||
curl_setopt($handle, CURLOPT_URL, $requested_url); | ||
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false); | ||
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); | ||
$results = curl_exec($handle); | ||
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE); | ||
|
||
if($code == 200 && !( curl_errno($handle))) | ||
{ | ||
$result = json_decode($results); | ||
|
||
$status = $result->status; | ||
$tran_date = $result->tran_date; | ||
$tran_id = $result->tran_id; | ||
$val_id = $result->val_id; | ||
$amount = intval($result->amount); | ||
$store_amount = $result->store_amount; | ||
$amount = intval($result->amount); | ||
$bank_tran_id = $result->bank_tran_id; | ||
$card_type = $result->card_type; | ||
$base_amount = $result->currency_amount; | ||
$risk_level = $result->risk_level; | ||
$base_fair=$result->base_fair; | ||
$value_total=$result->value_b; | ||
|
||
if(($status=='VALID' || $status=='VALIDATED') && ($order_amount == $base_amount) && $risk_level == 0) | ||
{ | ||
$status = 'success'; | ||
} | ||
else | ||
{ | ||
$status = 'failed'; | ||
} | ||
} | ||
$invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing | ||
|
||
$orderStatus = mysql_fetch_assoc(select_query('tblinvoices', 'status', array("id" => $invoiceid))); | ||
|
||
if($orderStatus['status'] == "Paid") | ||
{ | ||
logTransaction($GATEWAY["name"], array("Gateway Response" => $_POST, "Validation Response" => json_decode($results, true), "Response" => "Already Succeed By IPN"), "Successful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
exit(); | ||
} | ||
|
||
checkCbTransID($transid); # Checks transaction number isn't already in the database and ends processing if it does | ||
|
||
if ($status=="success") { | ||
$fee = 0; | ||
addInvoicePayment($invoiceid, $transid, $base_amount, $fee, $gatewaymodule); | ||
logTransaction($GATEWAY["name"], $_POST, "Successful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
exit(); | ||
|
||
} | ||
else { | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
exit(); | ||
} | ||
# Required File Includes | ||
include("../../../init.php"); | ||
include("../../../includes/functions.php"); | ||
include("../../../includes/gatewayfunctions.php"); | ||
include("../../../includes/invoicefunctions.php"); | ||
|
||
$gatewaymodule = "sslcommerz"; # Enter your gateway module name here replacing template | ||
|
||
|
||
$GATEWAY = getGatewayVariables($gatewaymodule); | ||
|
||
if (!$GATEWAY["type"]) | ||
die("Module Not Activated"); # Checks gateway module is active before accepting callback | ||
if (!isset($_POST)) | ||
die("No Post Data To Validate!"); | ||
|
||
$invoiceid = $_POST["value_c"]; | ||
$tran_id = $_POST["tran_id"]; | ||
$val_id = $_POST["val_id"]; | ||
|
||
|
||
$store_id = $GATEWAY["store_id"]; | ||
$store_passwd = $GATEWAY["store_password"]; | ||
$systemurl = rtrim($GATEWAY['systemurl'], '/'); | ||
|
||
if ($_POST['status'] == 'VALID' && !empty($_POST['val_id']) && !empty($_POST['tran_id'])) { | ||
if ($GATEWAY["testmode"] == "on") { | ||
$validation_url = "https://sandbox.sslcommerz.com/validator/api/validationserverAPI.php?val_id=" . $val_id . "&store_id=" . $store_id . "&store_passwd=" . $store_passwd . "&v=1&format=json"; | ||
} else { | ||
$validation_url = "https://securepay.sslcommerz.com/validator/api/validationserverAPI.php?val_id=" . $val_id . "&store_id=" . $store_id . "&store_passwd=" . $store_passwd . "&v=1&format=json"; | ||
} | ||
else if($_POST['status']=='FAILED' && (isset($_POST['tran_id']) && $_POST['tran_id'] != "")) | ||
{ | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
exit(); | ||
|
||
$handle = curl_init(); | ||
curl_setopt_array($handle, [ | ||
CURLOPT_URL => $validation_url, | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_SSL_VERIFYHOST => true, | ||
CURLOPT_SSL_VERIFYPEER => true, | ||
]); | ||
$results = curl_exec($handle); | ||
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE); | ||
|
||
if ($code == 200 && !(curl_errno($handle))) { | ||
$result = json_decode($results); | ||
|
||
$status = $result->status; | ||
$tran_date = $result->tran_date; | ||
$tran_id = $result->tran_id; | ||
$val_id = $result->val_id; | ||
$amount = $result->amount; | ||
$store_amount = $result->store_amount; | ||
$bank_tran_id = $result->bank_tran_id; | ||
$card_type = $result->card_type; | ||
$base_amount = $result->currency_amount; | ||
$risk_level = $result->risk_level; | ||
$base_fair = $result->base_fair; | ||
$value_total = $result->value_b; | ||
|
||
if (($status == 'VALID' || $status == 'VALIDATED') && $risk_level == 0) { | ||
$status = 'success'; | ||
} else { | ||
$status = 'failed'; | ||
} | ||
} else { | ||
$status = 'failed'; | ||
} | ||
else if($_POST['status']=='CANCELLED') | ||
{ | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."viewinvoice.php?id=" . $invoiceid); | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/viewinvoice.php?id=" . $invoiceid); | ||
} | ||
|
||
checkCbInvoiceID($invoiceid, $GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing | ||
checkCbTransID($tran_id); | ||
|
||
if ($status == "success") { | ||
logTransaction($GATEWAY["name"], array("Gateway Response" => $_POST, "Validation Response" => json_decode($results, true), "Response" => "Already Succeed By IPN"), "Successful"); # Save to Gateway Log: name, data array, status | ||
header("Location: " . $systemurl . "/clientarea.php?action=services"); /* Redirect browser */ | ||
exit(); | ||
} | ||
else | ||
{ | ||
|
||
checkCbTransID($tran_id); # Checks transaction number isn't already in the database and ends processing if it does | ||
|
||
if ($status == "success") { | ||
$fee = 0; | ||
addInvoicePayment($invoiceid, $tran_id, $base_amount, $fee, $gatewaymodule); | ||
logTransaction($GATEWAY["name"], $_POST, "Successful"); # Save to Gateway Log: name, data array, status | ||
header("Location: " . $systemurl . "/clientarea.php?action=services"); /* Redirect browser */ | ||
exit(); | ||
|
||
} else { | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
if($url_last_slash == "/") | ||
{ | ||
header("Location: ".$systemurl."clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
else{ | ||
header("Location: ".$systemurl."/clientarea.php?action=services"); /* Redirect browser */ | ||
} | ||
exit(); | ||
header("Location: " . $systemurl . "/clientarea.php?action=services"); /* Redirect browser */ | ||
exit(); | ||
} | ||
|
||
|
||
?> | ||
} else if (in_array($_POST['status'], ['FAILED', 'CANCELLED', 'UNATTEMPTED', 'EXPIRED']) && !empty($_POST['tran_id']) && !empty($_POST['value_c'])) { | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
header("Location: " . $systemurl . "/clientarea.php?action=services"); /* Redirect browser */ | ||
exit(); | ||
} else { | ||
logTransaction($GATEWAY["name"], $_POST, "Unsuccessful"); # Save to Gateway Log: name, data array, status | ||
header("Location: " . $systemurl . "/clientarea.php?action=services"); /* Redirect browser */ | ||
exit(); | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.