EasyPay - ICICI payment gateway implimentation
Request:
Payment.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Payment.aspx.vb" Inherits="Payment" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Payment information</h1>
<asp:Label ID="lblid" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Payment.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Payment.aspx.vb" Inherits="Payment" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Payment information</h1>
<asp:Label ID="lblid" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Payment.aspx.vb
Imports System.Security.Cryptography
Partial Class Payment
Inherits System.Web.UI.Page
Dim a As New Aidni()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("id") IsNot Nothing Then
Dim rnd As New Random()
Dim refNo As String = Session("id").Trim
'Dim refNo As String = "65478"
'Dim phone As String = a.returnValue("select phone from adminid where cid='" & Session("id").ToString() & "'")
Dim phone As String = a.returnValue("select rtrim(LTRIM(phone)) as 'phone' from adminid where cid='" & Session("id").ToString() & "'")
Dim strName As String = a.returnValue("select vname from adminid where cid='" & Session("id").ToString() & "'")
Dim MerchantId As String
MerchantId = "225979"
Dim ASEKEY As String
ASEKEY = "2227121459701000"
Dim amount As String
amount = "150"
Session("strAMT") = amount
Dim subMerchantId As String
subMerchantId = Session("id").Remove(0, 2).Trim
'subMerchantId = "987654"
Dim MandatoryField As String
MandatoryField = refNo.ToString() + "|" + subMerchantId + "|" + amount
Dim optionalfields As String
'optionalfields = "8584062656|111|TUHIN|BCA"
optionalfields = "" + phone.Trim + "|111|" + strName + "|UG"
Dim returnurl As String
'returnurl = "http://onlinedgc.org/SLIP.ASPX"
returnurl = "HTTP://ONLINEDGC.ORG/SLIP.ASPX"
Dim paymode As String
paymode = "9"
'---------------------------------------------------------
Dim refNo1 As String
refNo1 = encryptfile(refNo, ASEKEY)
Dim amount1 As String
amount1 = encryptfile(amount, ASEKEY)
Dim subMerchantId1 As String
subMerchantId1 = encryptfile(subMerchantId, ASEKEY)
Dim returnurl1 As String
returnurl1 = encryptfile(returnurl, ASEKEY)
Dim paymode1 As String
paymode1 = encryptfile(paymode, ASEKEY)
Dim MandatoryField1 As String
MandatoryField1 = encryptfile(MandatoryField, ASEKEY)
Dim optionalfields1 As String
optionalfields1 = encryptfile(optionalfields, ASEKEY)
Response.Redirect("https://eazypay.icicibank.com/EazyPG?merchantid=" + MerchantId + "&mandatory fields=" + MandatoryField1 + "&optional fields=" + optionalfields1 + "&returnurl=" + returnurl1 + "&Reference No=" + refNo1 + "&submerchantid=" + subMerchantId1 + "&transaction amount=" + amount1 + "&paymode=" + paymode1 + "")
Else
Response.Redirect("Default.aspx")
End If
End Sub
Public Function encryptfile(ByVal texttoencrypt As Object, ByVal key As Object) As String
Dim rijndaelcipher As RijndaelManaged = New RijndaelManaged()
rijndaelcipher.Mode = CipherMode.ECB
rijndaelcipher.Padding = PaddingMode.PKCS7
rijndaelcipher.KeySize = &H80
rijndaelcipher.BlockSize = &H80
Dim pwdbytes As [Byte]() = Encoding.UTF8.GetBytes(key)
Dim keybytes As [Byte]() = New Byte(15) {}
Dim len As Integer = pwdbytes.Length
If (len > keybytes.Length) Then
len = keybytes.Length
End If
Array.Copy(pwdbytes, keybytes, len)
rijndaelcipher.Key = keybytes
rijndaelcipher.IV = keybytes
Dim transform As ICryptoTransform = rijndaelcipher.CreateEncryptor()
Dim plaintext() As Byte = Encoding.UTF8.GetBytes(texttoencrypt)
Return Convert.ToBase64String(transform.TransformFinalBlock(plaintext, 0, plaintext.Length))
End Function
End Class
Response:
SLIP.ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="SLIP.ASPX.VB" Inherits="SLIP" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<style type="text/css" >
.wrapper{
width:800px;
margin:0px auto;
}
body{
font: 12px Arial, Helvetica, sans-serif;
line-height: 19px;
}
.b_col3 h1 { color:#900;}
.b_col3 h2 { color:#333;}
.b_col3 {
width:600px;
float: left;
margin-left: 27px;
text-align:center;
border-radius:5px;
border:1px #333 solid;
}
.xyz {
width:150px;
float:left;
text-align:left;
color:black;
padding: 5px 0px 0px 0px;}
.dot {
float:left;
width:50px;
text-align:left;
color:black;
padding-left:50px;}
.pqr {
width:200px;
float:left;
text-align:left;
color:black;
font-size: large;
}
</style>
<style type="text/css" >
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #cf866c;
-webkit-box-shadow:inset 0px 1px 0px 0px #cf866c;
box-shadow:inset 0px 1px 0px 0px #cf866c;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d0451b), color-stop(1, #bc3315));
background:-moz-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-webkit-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-o-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:-ms-linear-gradient(top, #d0451b 5%, #bc3315 100%);
background:linear-gradient(to bottom, #d0451b 5%, #bc3315 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0451b', endColorstr='#bc3315',GradientType=0);
background-color:#d0451b;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #942911;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:arial;
font-size:13px;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #854629;
width:100px;
text-align:center;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bc3315), color-stop(1, #d0451b));
background:-moz-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-webkit-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-o-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:-ms-linear-gradient(top, #bc3315 5%, #d0451b 100%);
background:linear-gradient(to bottom, #bc3315 5%, #d0451b 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bc3315', endColorstr='#d0451b',GradientType=0);
background-color:#bc3315;
}
.myButton:active {
position:relative;
top:1px;
}
.auto-style1
{
font-size: large;
}
</style>
<script type="text/javascript">
// Popup window code
function newPopup(url) {
popupWindow = window.open(
url, 'popUpWindow', 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table align="center" width="1024px" style="border: 1px solid; color:Gray;">
<tr>
<td>
<table align="center" width="1024px">
<tr>
<td colspan="2">
<img src="img/header-part1.gif" style="width: 1056px; height: 168px" />
</td>
</tr>
</table>
<div class="wrapper" id="div_print">
<div class="b_col3" id="first" runat="server">
<h2 style="color:Black;">DOMKAL GIRLS' COLLEGE</h2>
<h1>Online Payment Slip</h1>
<asp:HiddenField ID="hdnmsg" runat="server" />
<asp:Label ID="lblStatus" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="#000000" style="font-size: large" ></asp:Label>
<div style="height:15px"></div>
<div style="height:30px;"><label class="xyz"> <b style="font-size: large">Transaction ID</b></label><label class="dot"> :</label><asp:Label ID="Transaction" CssClass="pqr" runat="server" Font-Bold="True" ForeColor="#000000"
></asp:Label></div><div style="height:5px"></div>
<div style="height:30px;"><label class="xyz"> <b style="font-size: large">Candidate ID</b></label><label class="dot"> :</label><asp:Label ID="studentid" runat="server" CssClass="pqr" Font-Bold="True" ForeColor="#000000"
></asp:Label></div><div style="height:5px"></div>
<div id="divAdmissionCode" runat="server" style="height:30px;display:none;"><label class="xyz"> <b style="font-size: large">Admission Code</b></label><label class="dot"> :</label><asp:Label ID="lblAdmissionCode" runat="server" CssClass="pqr" Font-Bold="True" ForeColor="#000000"
></asp:Label></div><div style="height:5px"></div>
<div id="divvSid" runat="server" style="height:30px;display:none;"><label class="xyz"> <b style="font-size: large">Student Id</b></label><label class="dot"> :</label><asp:Label ID="lblvSid" runat="server" CssClass="pqr" Font-Bold="True" ForeColor="#000000"
></asp:Label></div><div style="height:5px"></div>
<div id="divRollNo" runat="server" style="height:30px;display:none;"><label class="xyz"> <b style="font-size: large">Roll No</b></label><label class="dot"> :</label><asp:Label ID="lblRollNo" runat="server" CssClass="pqr" Font-Bold="True" ForeColor="#000000"
></asp:Label></div><div style="height:5px"></div>
<div style="height:30px;"><label class="xyz"> <b style="font-size: large">Name</b></label><label class="dot"> :</label><asp:Label ID="Name" runat="server" Font-Bold="True" CssClass="pqr" ForeColor="#000000"></asp:Label></div><div style="height:5px"></div>
<div style="height:30px;"><label class="xyz"> <b>Am<span class="auto-style1">o</span>unt</b></label><label class="dot"> :</label><asp:Label ID="Amount" runat="server" Font-Bold="True" CssClass="pqr" ForeColor="#000000"></asp:Label></div>
<div style="height:30px;"><label class="xyz"> <b style="font-size: large">Date</b></label><label class="dot"> :</label><asp:Label ID="txtDate" runat="server" Font-Bold="True" CssClass="pqr" ForeColor="#000000"></asp:Label></div>
<div style="height:30px;"><label class="xyz"> <b style="font-size: large">Payment Mode</b></label><label class="dot"> :</label><asp:Label ID="txtPaymentMode" runat="server" Font-Bold="True" CssClass="pqr" ForeColor="#000000"></asp:Label></div>
</div>
</div>
<a href="javascript:void(0)" onclick="printnow('div_print');" class="myButton" style="margin-bottom:10px;">Print Slip</a>
<asp:LinkButton ID="printfrm" runat="server" class="myButton" style="margin-bottom:10px;">Print Form</asp:LinkButton>
<a href="<%=strURL%>Default.aspx" class="myButton" style="margin-bottom:10px;">Exit</a>
</td>
</tr>
</table>
<script>
function printnow(dvid) {
var headstr = "<html><head><title>Invoice</title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(dvid).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr + newstr + footstr;
document.title = "Invoice Receipt";
window.print();
document.body.innerHTML = oldstr;
// return false;
}
</script>
</form>
</body>
</html>
SLIP.ASPX.VB
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
'Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Text
Imports System.Security.Cryptography
Partial Class SLIP
Inherits System.Web.UI.Page
Public Shared strURL As String = ConfigurationManager.AppSettings("WC_SiteURL").ToString()
Dim a As New Aidni()
Dim bdt As String = ""
Dim Paymentsts As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If Session("id") IsNot Nothing Then
studentid.Text = Session("id").ToString()
Dim strName As String = a.returnValue("select vname from adminid where cid='" & Session("id").ToString() & "'")
Dim strStream As String = ""
Dim strCourseType As String = ""
Dim table As New DataTable()
table = a.getDataTable("select vstream,honstype from multimerit where StudentId='" & Session("id").ToString() & "'")
If (table.Rows.Count > 0) Then
For Each dtRow As DataRow In table.Rows
For Each dtCol As DataColumn In table.Columns
strStream = (dtRow("vstream").ToString())
strCourseType = (dtRow("honstype").ToString())
Next
Next
End If
'Dim str As String = a.returnValue("select honstype from admnmpnt where cid='" & Session("id").ToString() & "'")
If (strStream <> "B.Sc" And strCourseType = "Honours") Then
studentid.Text = Session("id").ToString()
printfrm.Attributes.Add("onclick", "newPopup('" & strURL & "frmForm.aspx');")
End If
If (strStream <> "B.Sc" And strCourseType = "General") Then
studentid.Text = Session("id").ToString()
printfrm.Attributes.Add("onclick", "newPopup('" & strURL & "frmgen.aspx');")
End If
If (strStream = "B.Sc" And strCourseType = "Honours") Then
studentid.Text = Session("id").ToString()
printfrm.Attributes.Add("onclick", "newPopup('" & strURL & "frmForm_sem.aspx');")
End If
Try
Transaction.Text = Request.Form("Unique Ref Number").ToString()
txtDate.Text = Request.Form("Transaction Date").ToString()
txtPaymentMode.Text = Request.Form("Payment Mode").ToString()
If (Request.Form("Response Code").ToString() = "E000") Then
Amount.Text = Session("strAMT")
lblStatus.Text = "Transaction Successfully"
Else
Amount.Text = "0"
lblStatus.Text = "Transaction Failed"
End If
Name.Text = strName.ToString
Catch ex As Exception
End Try
Else
first.Visible = False
End If
'----------------------------------------------------------------
End If
Dim ErrorDescription As String = ""
If (Session("IsEcounselling") IsNot Nothing And Session("IsEcounselling") = "True") Then
Session.Remove("IsEcounselling")
divAdmissionCode.Attributes("style") = "height:30px;"
divvSid.Attributes("style") = "height:30px;"
divRollNo.Attributes("style") = "height:30px;"
'========================
Dim Category As String = ""
'Dim ph As String = ""
Dim adm_srl_no As String = "1"
Dim meritId As String = ""
If Session("honstype") IsNot Nothing AndAlso Session("cat") IsNot Nothing AndAlso Session("ph") IsNot Nothing AndAlso Session("stream") IsNot Nothing AndAlso Session("honssub") IsNot Nothing AndAlso Session("id") IsNot Nothing AndAlso Session("meritId") IsNot Nothing And Session("AdmissionCode") IsNot Nothing Then
studentid.Text = Session("id")
Category = Session("cat")
' ph = Session("ph")
meritId = Session("meritId")
studentid.Text = Session("id")
lblAdmissionCode.Text = Session("AdmissionCode")
Else
lblStatus.Text = "Session Timeout!!"
Return
End If
'=======================
Try
If (Transaction.Text <> "") Then
Dim honstype As String = Session("honstype")
Dim cat As String = Session("cat")
Dim ph As String = Session("ph")
Dim stream As String = Session("stream")
Dim honssub As String = Session("honssub")
Dim strcon As SqlConnection = a.CallSqlconnection()
Dim cmd As New SqlCommand("Insert Into TransitionDetail (StudentId,TransitionId,StudentName,Amount,TransDate,TransStatus,BankName,stream,honstype,cat,ph,IsEcounselling,honssub,AdmissionCode) values(@StudentId,@TransitionId,@StudentName,@Amount,@TransDate,@TransStatus,@BankName,@stream,@honstype,@cat,@ph,@IsEcounselling,@honssub,@AdmissionCode)", strcon)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add(New SqlParameter("@StudentId", (studentid.Text)))
cmd.Parameters.Add(New SqlParameter("@TransitionId", (Transaction.Text)))
cmd.Parameters.Add(New SqlParameter("@StudentName", (Name.Text)))
cmd.Parameters.Add(New SqlParameter("@Amount", (Amount.Text)))
cmd.Parameters.Add(New SqlParameter("@TransDate", (txtDate.Text)))
cmd.Parameters.Add(New SqlParameter("@TransStatus", (lblStatus.Text)))
cmd.Parameters.Add(New SqlParameter("@BankName", ("ICICI Bank")))
cmd.Parameters.Add(New SqlParameter("@stream", (stream)))
cmd.Parameters.Add(New SqlParameter("@honstype", (honstype)))
cmd.Parameters.Add(New SqlParameter("@honssub", (honssub)))
cmd.Parameters.Add(New SqlParameter("@cat", (cat)))
cmd.Parameters.Add(New SqlParameter("@ph", (ph)))
cmd.Parameters.Add(New SqlParameter("@IsEcounselling", ("True")))
cmd.Parameters.Add(New SqlParameter("@AdmissionCode", (lblAdmissionCode.Text)))
cmd.ExecuteNonQuery()
If (lblStatus.Text = "Transaction Successfully") Then
a.executeQuery("update multimerit set admsnfee=1,admsnfeedt='" & DateTime.Now.ToString("MM/dd/yyyy") & "',admitted_category='" & Category & "',ph='" & ph & "',Admission_serial_no='" & adm_srl_no.ToString() & "' where Id=" & meritId & " and approved=1 and admsnfeedt is null and AdmissionCode='" & lblAdmissionCode.Text & "'")
Dim newClassSlip As ClassSlip = New ClassSlip()
Dim dtvSid As DataTable = newClassSlip.GenerateStudentId(stream, "2019-20", honstype, studentid.Text, Name.Text, lblAdmissionCode.Text)
If dtvSid IsNot Nothing And dtvSid.Rows.Count > 0 Then
lblvSid.Text = dtvSid.Rows(0)("studentid")
lblRollNo.Text = dtvSid.Rows(0)("iroll")
'============================if sms features ===============
Dim newClassConfig As ClassConfig = New ClassConfig()
Dim dtconfig As DataTable = newClassConfig.GetConfigValue("SMS")
If dtconfig IsNot Nothing And dtconfig.Rows.Count > 0 Then
If (dtconfig.Rows(0)("Value") = "Yes") Then
Dim dtPhoneno As DataTable = a.getDataTable("select phone from adminid where cid='" + studentid.Text + "'")
sms.Send(RTrim(LTrim(dtPhoneno.Rows(0)("phone").ToString().Trim())), "Your admission in this college completed successfully with student id " + dtvSid.Rows(0)("studentid") + " and form no. " + studentid.Text)
End If
End If
'============================
End If
End If
'Session.Remove("honstype")
'Session.Remove("cat")
'Session.Remove("ph")
'Session.Remove("stream")
'Session.Remove("honssub")
Session.Remove("IsEcounselling")
End If
Catch ex As Exception
Session.Remove("IsEcounselling")
End Try
Else
Try
If (Transaction.Text <> "") Then
Dim strcon As SqlConnection = a.CallSqlconnection()
Dim cmd As New SqlCommand("Insert Into TransitionDetail (StudentId,TransitionId,StudentName,Amount,TransDate,TransStatus,BankName) values(@StudentId,@TransitionId,@StudentName,@Amount,@TransDate,@TransStatus,@BankName)", strcon)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add(New SqlParameter("@StudentId", (studentid.Text)))
cmd.Parameters.Add(New SqlParameter("@TransitionId", (Transaction.Text)))
cmd.Parameters.Add(New SqlParameter("@StudentName", (Name.Text)))
cmd.Parameters.Add(New SqlParameter("@Amount", (Amount.Text)))
cmd.Parameters.Add(New SqlParameter("@TransDate", (txtDate.Text)))
cmd.Parameters.Add(New SqlParameter("@TransStatus", (lblStatus.Text)))
cmd.Parameters.Add(New SqlParameter("@BankName", ("ICICI Bank")))
cmd.ExecuteNonQuery()
End If
If (Transaction.Text <> "") Then
Dim mprm As String = System.DateTime.Now.ToString("dd/MM/yyyy")
Dim amdt As String = "#" + mprm.Trim.Substring(3, 2) + "/" + Strings.Left(mprm.Trim, 2) + "/" + Strings.Right(mprm.Trim, 4) + "#"
If IsDate(amdt) Then
bdt = Strings.Right(mprm.Trim, 4) + mprm.Trim.Substring(3, 2) + Strings.Left(mprm.Trim, 2)
End If
Dim strcon As SqlConnection = a.CallSqlconnection()
Dim cmd As New SqlCommand("Update admnmpnt set paid=@paid,paiddt=@paiddt where cid='" & studentid.Text.Trim() & "'", strcon)
cmd.CommandType = CommandType.Text
If (Request.Form("Response Code").ToString() = "E000") Then
cmd.Parameters.Add(New SqlParameter("@paid", (True)))
Else
cmd.Parameters.Add(New SqlParameter("@paid", (False)))
End If
cmd.Parameters.Add(New SqlParameter("@paiddt", (bdt)))
cmd.ExecuteNonQuery()
End If
Catch ex As Exception
End Try
End If
End Sub
Public Sub send_sms(ByVal stu_id As String)
Dim msg As String = ""
Dim strMobile As String = ""
Dim dob As String = ""
Dim dt_sms As New DataTable()
dt_sms = a.getDataTable("select phone,dateofbirth from adminid where cid='" & stu_id.ToString().Trim() & "'")
If dt_sms.Rows.Count > 0 Then
strMobile = (dt_sms.Rows(0)("phone").ToString())
dob = dt_sms.Rows(0)("dateofbirth").ToString().Substring(0, 10)
End If
msg = "Your Online Application is Successfully Submitted... User Id=" & stu_id & " and Password=" & dob.ToString() & " from DOMKAL GIRLS' COLLEGE"
sms.Send(strMobile, msg.ToString())
End Sub
Public Sub send_failed_sms(ByVal stu_id As String)
Dim msg As String = ""
Dim strMobile As String = ""
Dim dob As String = ""
Dim dt_sms As New DataTable()
dt_sms = a.getDataTable("select phone,dateofbirth from adminid where cid='" & stu_id.ToString().Trim() & "'")
If dt_sms.Rows.Count > 0 Then
strMobile = (dt_sms.Rows(0)("phone").ToString())
dob = dt_sms.Rows(0)("dateofbirth").ToString().Substring(0, 10)
End If
msg = "Your Online Transaction is failed... User Id=" & stu_id & " and Password=" & dob.ToString() & " from DOMKAL GIRLS' COLLEGE"
sms.Send(strMobile, msg.ToString())
End Sub
End Class