Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp-21-08-2019/ |
<?php
date_default_timezone_set('Asia/Calcutta');
$datenow = date("d/m/Y h:m:s");
$transactionDate = str_replace(" ", "%20", $datenow);
$transactionId = rand(1, 1000000);
$transactionRequest = new TransactionRequest();
//Setting all values here
$transactionRequest->setMode("live");
$transactionRequest->setLogin("18589");
$transactionRequest->setPassword("IIIT@123");
$transactionRequest->setProductId("IIIT");
$transactionRequest->setAmount($_REQUEST['amount']);
$transactionRequest->setTransactionCurrency("INR");
$transactionRequest->setTransactionAmount(0);
$transactionRequest->setReturnUrl("https://erp.iiita.ac.in/outer/aaa/PGResponse/online/" .$_REQUEST['udf6']. "/ATOM/1");//http://localhost/~work/Atompay/response.php");
$transactionRequest->setClientCode($_REQUEST['clientcode']);
$transactionRequest->setTransactionId($transactionId);
$transactionRequest->setTransactionDate($transactionDate);
$transactionRequest->setCustomerName($_REQUEST['udf1']); // name
$transactionRequest->setCustomerEmailId($_REQUEST['udf2']); // email
$transactionRequest->setCustomerMobile($_REQUEST['udf3']); // mobile
$transactionRequest->setCustomerBillingAddress($_REQUEST['udf4']);
$transactionRequest->setCustomerAccount("0627101019766");
$transactionRequest->setReqHashKey("b4b3b1beaed5817480"); //resHashKey=1099e2845456d822a3
$url = $transactionRequest->getPGUrl();
//foreach (explode('&', $url) as $u) {
// echo $u. '<br>';
//}
header("Location: $url");
/*** Version 1.0 */
class TransactionRequest {
private $login;
private $password;
private $transactionType;
private $productID;
private $amount;
private $transactionCurrency;
private $transactionAmount;
private $clientCode;
private $transactionID;
private $transactionDate;
private $customerAccount;
private $customerName;
private $customerEmailID;
private $customerMobile;
private $customerBillingAddress;
private $returnUrl;
private $mode = "test";
private $transactionUrl;
private $nbType = "NBFundTransfer";
private $ccType = "CCFundTransfer";
private $reqHashKey = "";
/*** @return string */
public function getReqHashKey() {
return $this->reqHashKey;
}
/*** @param string $reqHashKey */
public function setReqHashKey($reqHashKey) {
$this->reqHashKey = $reqHashKey;
}
/*** @return string */
public function getRespHashKey() {
return $this->respHashKey;
}
/*** @param string $respHashKey */
public function setRespHashKey($respHashKey) {
$this->respHashKey = $respHashKey;
}
/*** @return the $login */
public function getLogin() {
return $this->login;
}
/*** @param string $login */
public function setLogin($login) {
$this->login = $login;
}
/*** @return the $password */
public function getPassword() {
return $this->password;
}
/*** @param string $password */
public function setPassword($password) {
$this->password = $password;
}
/*** @return the $transactionType */
public function getTransactionType() {
return $this->transactionType;
}
/*** @param string $transactionType */
public function setTransactionType($transactionType) {
$this->transactionType = $transactionType;
}
/*** @return the $productID */
public function getProductID() {
return $this->productID;
}
/*** @param string $productID*/
public function setProductID($productID) {
$this->productID = $productID;
}
/*** @return the $amount*/
public function getAmount() {
return $this->amount;
}
/*** @param string $amount */
public function setAmount($amount) {
$this->amount = $amount;
}
/*** @return the $transactionCurrency */
public function getTransactionCurrency() {
return $this->transactionCurrency;
}
/*** @param string $transactionCurrency */
public function setTransactionCurrency($transactionCurrency) {
$this->transactionCurrency = $transactionCurrency;
}
/*** @return the $transactionAmount */
public function getTransactionAmount() {
return $this->transactionAmount;
}
/*** @param string $transactionAmount */
public function setTransactionAmount($transactionAmount) {
$this->transactionAmount = $transactionAmount;
}
/*** @return the $transactionID */
public function getTransactionID() {
return $this->transactionID;
}
/*** @param string $transactionID */
public function setTransactionID($transactionID) {
$this->transactionID = $transactionID;
}
/*** @return the $transactionDate */
public function getTransactionDate() {
return $this->transactionDate;
}
/*** @param string $transactionDate */
public function setTransactionDate($transactionDate) {
$this->transactionDate = $transactionDate;
}
/*** @return the $customerAccount */
public function getCustomerAccount() {
return $this->customerAccount;
}
/*** @param string $customerAccount */
public function setCustomerAccount($customerAccount) {
$this->customerAccount = $customerAccount;
}
/*** @return the $customerName */
public function getCustomerName() {
return $this->customerName;
}
/*** @param string $customerName */
public function setCustomerName($customerName) {
$this->customerName = $customerName;
}
/*** @return the $customerEmailID */
public function getCustomerEmailID() {
return $this->customerEmailID;
}
/*** @param string $customerEmailID */
public function setCustomerEmailID($customerEmailID) {
$this->customerEmailID = $customerEmailID;
}
/*** @return the $customerMobile */
public function getCustomerMobile() {
return $this->customerMobile;
}
/*** @param string $customerMobile */
public function setCustomerMobile($customerMobile) {
$this->customerMobile = $customerMobile;
}
/*** @return the $customerBillingAddress */
public function getCustomerBillingAddress(){
return $this->customerBillingAddress;
}
/*** @param string $customerBillingAddress */
public function setCustomerBillingAddress($customerBillingAddress) {
$this->customerBillingAddress = $customerBillingAddress;
}
/*** @return the $returnUrl */
public function getReturnUrl() {
return $this->returnUrl;
}
/*** @param string $returnUrl */
public function setReturnUrl($returnUrl) {
$this->returnUrl = $returnUrl;
}
/*** @return the $mode */
public function getMode() {
return $this->mode;
}
/*** @param string $mode */
public function setMode($mode) {
$this->mode = $mode;
}
/*** @return the $transactionUrl */
public function getTransactionUrl() {
return $this->transactionUrl;
}
/*** @param string $transactionUrl */
public function setTransactionUrl($transactionUrl) {
$this->transactionUrl = $transactionUrl;
}
public function getnbType() {
return $this->nbType;
}
public function getccType() {
return $this->ccType;
}
private function setUrl() {
$port = 443;
if($this->getMode() == "live"){
$url = "https://payment.atomtech.in/paynetz/epi/fts";
} else {
$url = "https://paynetzuat.atomtech.in/paynetz/epi/fts";
}
$this->setTransactionUrl($url);
$this->setPort($port);
}
public function setClientCode($clientCode) {
if($clientCode == NULL || $clientCode == ""){
$this->clientCode = urlencode(base64_encode(123));
} else {
$this->clientCode = urlencode(base64_encode($clientCode));
}
}
private function getClientCode() {
return $this->clientCode;
}
private function setPort($port) {
$this->port = $port;
}
private function getPort() {
return $this->port;
}
public function getChecksum(){
$str = $this->login .$this->password .$this->nbType .$this->productID .$this->transactionID .$this->amount .$this->transactionCurrency;
$signature = hash_hmac("sha512", $str, $this->reqHashKey, false);
//echo $str.'<br>signature='.$signature.'<br>';
return $signature;
}
private function getData(){
$strReqst = "";
$strReqst .= "login=".$this->getLogin();
$strReqst .= "&pass=".$this->getPassword();
//$txnType = $this->getTransactionType();
//if($txnType== 'NB'){
$strReqst .= "&ttype=NBFundTransfer";
//}else{
//$strReqst .= "&ttype=".$this->getccType();
//}
$strReqst .= "&prodid=".$this->getProductID();
$strReqst .= "&amt=".$this->getAmount();
$strReqst .= "&txncurr=".$this->getTransactionCurrency();
$strReqst .= "&txnscamt=".$this->getTransactionAmount();
$strReqst .= "&ru=".$this->getReturnUrl();
$strReqst .= "&clientcode=".$this->getClientCode();
$strReqst .= "&txnid=".$this->getTransactionID();
$strReqst .= "&date=".$this->getTransactionDate();
$strReqst .= "&udf1=".$this->getCustomerName();
$strReqst .= "&udf2=".$this->getCustomerEmailID();
$strReqst .= "&udf3=".$this->getCustomerMobile();
$strReqst .= "&udf4=".$this->getCustomerBillingAddress();
$strReqst .= "&custacc=".$this->getCustomerAccount();
$strReqst .= "&signature=".$this->getChecksum();
return $strReqst;
}
/**
* This function returns transaction token url
* @return string
*/
public function getPGUrl(){
if ($this->mode != null && $this->mode != "") {
try {
$this->setUrl();
$data = $this->getData();
$this->writeLog($data);
return $this->transactionUrl . "?" .$data;
} catch ( Exception $ex ) {
echo "Error while getting transaction token : " . $ex->getMessage();
return;
}
} else {
return "Please set mode live or test.";
}
}
private function writeLog($data){
$fileName = date("Y-m-d"). ".txt";
$fp = fopen("log/" .$fileName, 'a+');
$data = date("Y-m-d H:i:s"). " - " .$data. PHP_EOL;
fwrite($fp, $data);
fclose($fp);
}
}
?>