Current File : /home/inlingua/public_html/icentex/inlingua_payment/initiatePayment.php |
<?php session_start();
include("../dbConnection.php");
use PaymentHandler\APIException;
require_once ("./PaymentHandler.php");
use PaymentHandler\PaymentHandler;
$paymentHandler = new PaymentHandler("resources/config.json");
$queryP="update ingl_payment_gateway set Name='".$_REQUEST['Name']."',
address='".$_REQUEST['address']."',email='".$_REQUEST['email']."',payment_details='".$_REQUEST['payment_details']."' where recNo='".$conn->real_escape_string($_POST['MTrackid'])."'
";
$resultP=$conn->query($queryP) or die("Error");
$queryU="select * from ingl_payment_gateway where recNo='".$_SESSION['pid']."'";
$resultU=$conn->query($queryU);
$numU=$resultU->fetch_assoc();
$queryL="select location from timesheet_location where recNo='".$numU['centre']."'";
$resultL=$conn->query($queryL);
$numL=$resultL->fetch_assoc();
$queryA="select name from timesheet_user where recNo='".$numU['created_by']."'";
$resultA=$conn->query($queryA);
$numA=$resultA->fetch_assoc();
$amount=$numU['amount_to_pay'];
$orderId=$numU['recNo'];
$customerId = $numU['Student_id'];
// block:start:session-function
$email=$numU['email'];
$mobile=$numU['mobile'];
$url="https://inlinguanewdelhi.in/icentex/inlingua_payment/payment/handlePaymentResponse.php";
$params = json_decode("{"customer_email\":\"$email\",\n\"customer_phone\":\"$mobile\",\n\"first_name\":\"$fname\",\n\"last_name\":\"$lname\",\n\"amount\":\"$amount\",\n\"order_id\":\"$orderId\",\n\"customer_id\":\"$customerId\",\n\"action\":\"paymentPage\",\n\"return_url\": \"$url\"\n}", true);
try {
$session = $paymentHandler->orderSession($params);
// block:end:session-function
$redirect = $session["payment_links"]["web"];
header("Location: {$redirect}");
exit;
} catch (APIException $e ) {
http_response_code(500);
$error = json_encode(["message" => $e->getErrorMessage(), "error_code" => $e->getErrorCode(), "http_response_code" => $e->getHttpResponseCode()]);
echo "<p> Payment server threw a non-2xx error. Error message: {$error} </p>";
exit;
} catch (Exception $e) {
http_response_code(500);
echo " <p> Unexpected error occurred, Error message: {$e->getMessage()} </p>";
exit;
}
?>