-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgResponse.php
More file actions
51 lines (47 loc) · 2.21 KB
/
pgResponse.php
File metadata and controls
51 lines (47 loc) · 2.21 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
include "functions/function.php";
// following files need to be included
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
// session_start();
$paytmChecksum = "";
$paramList = array();
$isValidChecksum = "FALSE";
$paramList = $_POST;
$paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
//Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your application�s MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
$isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
if($isValidChecksum == "TRUE") {
// print_r($_POST);die();
if($_POST["STATUS"] == "TXN_SUCCESS") {
// print_r($_POST);die();
$oid=$_POST['ORDERID'];
$txnid=$_POST['TXNID'];
$getOrderById=getOrderById($oid);
$orderemail=orderemail($getOrderById['cus_name'],$getOrderById['total_amount'],$oid);
$get_txn=mysqli_query($conn,"update orders set payment_id='$txnid' , payment_status='success' where order_id='$oid'");
// smtp_mailer($getOrderById['cus_email'],"Order Placed Successfully",$orderemail);
echo '<script>window.open("thankyou.php?oid='.$oid.'","_self");</script>';
}
else {
$oid=$_POST['ORDERID'];
$txnid=989898989;
$getOrderById=getOrderById($oid);
$orderemail=orderemail($getOrderById['cus_name'],$getOrderById['total_amount'],$oid);
// echo "update orders set payment_id='$txnid' and payment_status='failed' where order_id='$oid'";die();
$get_txn=mysqli_query($conn,"update orders set payment_id='$txnid' and payment_status='failed' where order_id='$oid'");
echo '<script>window.open("error.php?oid='.$oid.'","_self");</script>';
}
}
else {
$oid=$_POST['ORDERID'];
$txnid=$_POST['TXNID'];
$getOrderById=getOrderById($oid);
$orderemail=orderemail($getOrderById['cus_name'],$total_amount,$oid);
$get_txn=mysqli_query($conn,"update orders set payment_id='$txnid' and payment_status='failed' where order_id='$oid'");die();
echo '<script>window.open("error.php?oid='.$oid.'","_self");</script>';
}
?>