Sh3ll
OdayForums


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-19-07-2018/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/html/mmishra/erp-19-07-2018/atom.inc
<?php
class payment_config_test {
	var $Url = "https://paynetzuat.atomtech.in/paynetz/epi/fts";
	var $Login="160";
	var $Password="Test@123";
	//var $MerchantName="ATOM";
	var $MerchantName="NSE";
	var $TxnCurr="INR";
	var $TxnScAmt="0";
}

class payment_config {
	var $Url = "https://payment.atomtech.in/paynetz/epi/fts";
	var $Login="18589";
	var $Password="IIIT@123";
	var $MerchantName="IIIT";
	var $TxnCurr="INR";
	var $TxnScAmt="0";
}

class payment {
	var $url = null;

	function sendInfo($data){
		$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $this->url);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_PORT , 443); 
		//curl_setopt($ch, CURLOPT_SSLVERSION,3);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

		$returnData = curl_exec($ch);

		curl_close($ch);
			return $returnData;
	}
}

class ProcessPayment {
        function __construct() {
               	$this->paymentConfig = new payment_config();
       	}

        function requestMerchant() {
               	$payment 		= new payment();
       	        $datenow 		= date("d/m/Y h:m:s");
                $modifiedDate 	= str_replace(" ", "%20", $datenow);
               	$payment->url 	= $this->paymentConfig->Url;
       	        $postFields  	= "";
                $postFields 	.= "&login=".$this->paymentConfig->Login;
               	$postFields 	.= "&pass=".$this->paymentConfig->Password;
       	        $postFields 	.= "&ttype=".$_POST['TType'];
                $postFields 	.= "&prodid=".$_POST['product'];
               	$postFields 	.= "&amt=".$_POST['amount'];
       	        $postFields 	.= "&txncurr=".$this->paymentConfig->TxnCurr;
                $postFields 	.= "&txnscamt=".$this->paymentConfig->TxnScAmt;
               	$postFields 	.= "&clientcode=".urlencode(base64_encode($_POST['clientcode']));//rollno
       	        $postFields 	.= "&txnid=".rand(0,999999);
                $postFields 	.= "&date=".$modifiedDate;
               	$postFields 	.= "&custacc=".$_POST['AccountNo'];
       	        //$postFields 	.= "&ru=".$_POST['ru'];
       	        $postFields 	.= "&ru=https://ipay.iiita.ac.in/canara/StatusTRAN.php";
       	        $postFields 	.= "&udf1=".$_POST['udf1']; //name
       	        $postFields 	.= "&udf2=".$_POST['udf2']; //email
       	        $postFields 	.= "&udf3=".$_POST['udf3']; //mobile
       	        $postFields 	.= "&udf4=".$_POST['udf4']; //program
       	        $postFields 	.= "&udf5=".$_POST['udf5']; //batch
       	        $postFields 	.= "&udf9=".$_POST['udf9']; //semester
                // Not required for merchant
               	//$postFields 	.= "&bankid=".$_POST['bankid'];

       	        $sendUrl 		= $payment->url."?".substr($postFields,1)."\n";

                $this->writeLog($sendUrl);

               	$returnData 	= $payment->sendInfo($postFields);
       	        $this->writeLog($returnData."\n");
                $xmlObjArray 	= $this->xmltoarray($returnData);

               	$url 			= $xmlObjArray['url'];
       	        $postFields  	= "";
                $postFields 	.= "&ttype=".$_POST['TType'];
               	$postFields 	.= "&tempTxnId=".$xmlObjArray['tempTxnId'];
       	        $postFields 	.= "&token=".$xmlObjArray['token'];
                $postFields 	.= "&txnStage=1";
               	$url 			= $payment->url."?".$postFields;
       	        $this->writeLog($url."\n");

                header("Location: ".$url);
	}

       	function writeLog($data){
               	$fileName = date("Y-m-d").".txt";
               	$fp = fopen("log/".$fileName, 'a+');
               	$data = date("Y-m-d H:i:s")." - ".$data;
               	fwrite($fp,$data);
               	fclose($fp);
       	}

       	function xmltoarray($data){
               	$parser = xml_parser_create('');
               	xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
               	xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
               	xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
               	xml_parse_into_struct($parser, trim($data), $xml_values);
               	xml_parser_free($parser);

               	$returnArray = array();
               	$returnArray['url'] = $xml_values[3]['value'];
               	$returnArray['tempTxnId'] = $xml_values[5]['value'];
               	$returnArray['token'] = $xml_values[6]['value'];

               	return $returnArray;
       	}
}

$processPayment = new ProcessPayment();
$processPayment->requestMerchant();

exit;
?>

<?php

/**
 * 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 . "NBFundTransfer" . $this->productId . $this->transactionId . $this->amount . "INR";
       // echo $str;exit;
        $signature =  hash_hmac("sha512",$str,$this->reqHashKey,false);
        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".date("Y-m-d").".txt";
		$fp = fopen("log/".$fileName, 'a+');
		$data = date("Y-m-d H:i:s")." - ".$data;
		fwrite($fp,$data);
		fclose($fp);
	}
    
}

ZeroDay Forums Mini