Atom Payment Gateway Integration in php

Atom Payment Gateway Integration we First introduce Atom –

Atom Technologies is provide end to end transaction service provider, headquarter in Mumbai,India. Atom payment gateway service started in 2006.

Atom Payment integration we create a different php Pages –

  1. Config.php – this file content payment_config class and payment_config  class content payment configuration  information.
  2. Payment.php – this file content payment class and payment class content payment data send and port information
  3. conn.php – this file content database connection information and file is optional. if information store in own database.
  4. response.php – this file is payment response file. this file is  inform  payment successfully or not.
  5. submit.php – this file is posted information in payment gateway.
  6. index.php – this file content HTML information. and using index page posted data.

and create a log folder. log folder content text file and this file create automatically  and this file content posted data information.

Atom Demo payment Gateway PHP Code –

  1. config.php –                                                                                                                                          <?php
    class payment_config{
    var $Url = “https://paynetzuat.atomtech.in/paynetz/epi/fts&#8221;;
    var $Login=”160″;
    var $Password=”Test@123″;
    var $MerchantName=”ATOM”;
    var $TxnCurr=”INR”;
    var $TxnScAmt=”0″;
    }
    ?>

 

2. Payment.php –

<?php

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;
}
}
?>

3.submit.php –

<?php
include “config.php”;
include “payment.php”;

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’]));
$postFields .= “&txnid=”.rand(0,999999);
$postFields .= “&date=”.$modifiedDate;
$postFields .= “&custacc=”.$_POST[‘AccountNo’];
$postFields .= “&ru=”.$_POST[‘ru’];
// 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();
?>

4. index.php –  this is a demo html page.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> Payment </TITLE>
</HEAD>

<BODY>
<form action=”submit.php” method=”post”>
/// hidden field are compulsory
<INPUT TYPE=”hidden” NAME=”product” value=”NSE”>
<INPUT TYPE=”hidden” NAME=”TType” value=”NBFundTransfer”>

<INPUT TYPE=”hidden” NAME=”clientcode” value=”007″>
<INPUT TYPE=”hidden” NAME=”AccountNo” value=”1234567890″>
// this is a response page url – ru
<INPUT TYPE=”hidden” NAME=”ru” value=”http://203.114.240.183/paynetzclient/ResponseParam.jsp”&gt;
<input type=”hidden” name=”bookingid” value=”100001″/>

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>* Name</td>
<td>:</td>
<td><input name=”udf1″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Client Name is mandatory.</span></td>

</tr>
<tr>
<td>* Email ID</td>
<td>:</td>
<td><input name=”udf2″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Email is mandatory.</span></td>
</tr>
<tr>

<td>* Mobile No</td>
<td>:</td>
<td><input name=”udf3″ type=”text” value=”” /></td>
<td><span style=”color:Red;visibility:hidden;”>Mobile No</span></td>
</tr>
<tr>
<td>* Billing Address</td>
<td>:</td>

<td><input name=”udf4″ type=”text” value=””  /></td>
<td><span style=”color:Red;visibility:hidden;”>Billing Address is mandatory.</span></td>
</tr>
<!–  <tr>
<td>* Bank Name</td>
<td>:</td>
<td><input name=”udf5″ type=”text” value=”bank1″ /></td>
<td><span style=”color:Red;visibility:hidden;”>Bank Name is mandatory.</span></td>

</tr> –>

<tr>
<td>
Amount
</td>
<td>:</td>
<td>
<input type=”text” name=”amount” value=”” />
</td>
</tr>

<tr>
<td>
</td>
<td></td>
<td>
<input type=”submit” name=”Submit” value=”Submit” />
</td>
</tr>
</table>
</form>
</BODY>
</HTML>

5. response.php –

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> Payment </TITLE>
</HEAD>

<BODY>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>
<?php if($_POST[‘f_code’]==”Ok”){ ?>
Success : Your Transaction is been processed.
<?php } else { ?>
Failure : Your Transaction couldnot be processed.
<?php } ?>
</td>
</tr>
</table>
</BODY>
</HTML>

6. create a log folder.