This is to send request to payment gateway server
ASEKEY & merchantid will be provided by BANK after submitting return URL to bank
string redirecturl = ""; // this is to check what url is coming before encryption
string encryptredirecturl = "";
string ASEKEY = "xxxxxxxxxxxxxxxxxxxx";
string Reference_no, sub_merchant_id, pgamount, Mobile_No, city, name;
Reference_no ="your value";
sub_merchant_id ="your value";
pgamount = 000;
Mobile_No = "your value";;
city ="your value";
name = "your value";
redirecturl += "https://eazypay.icicibank.com/EazyPG?";
redirecturl += "merchantid=xxxxx";
redirecturl += "&mandatory fields=" + Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456";
redirecturl += "&optional fields=" + city + "|" + name;
redirecturl += "&returnurl=http://yourwebsite.com/eazypayreturn.aspx";
redirecturl += "&Reference No=" + Reference_no;
redirecturl += "&submerchantid=" + sub_merchant_id;
redirecturl += "&transaction amount=" + pgamount;
redirecturl += "&paymode=9";
encryptredirecturl += "https://eazypay.icicibank.com/EazyPG?";
encryptredirecturl += "merchantid=xxxxx";
encryptredirecturl += "&mandatory fields=" + encryptFile(Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456", ASEKEY);
encryptredirecturl += "&optional fields=" + encryptFile(city + "|" + name, ASEKEY);
encryptredirecturl += "&returnurl=" + encryptFile("http://yourwebsite.com/eazypayreturn.aspx", ASEKEY);
encryptredirecturl += "&Reference No=" + encryptFile(Reference_no, ASEKEY);
encryptredirecturl += "&submerchantid=" + encryptFile(sub_merchant_id, ASEKEY);
encryptredirecturl += "&transaction amount=" + encryptFile(pgamount, ASEKEY);
encryptredirecturl += "&paymode=" + encryptFile("9", ASEKEY);
Response.Redirect(encryptredirecturl);
-----------------------------------------------------------------------------------------
public static string encryptFile(string textToEncrypt, string key)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = CipherMode.ECB;
rijndaelCipher.Padding = PaddingMode.PKCS7;
rijndaelCipher.KeySize = 0x80;
rijndaelCipher.BlockSize = 0x80;
byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
byte[] keyBytes = new byte[0x10];
int len = pwdBytes.Length;
if (len > keyBytes.Length)
{
len = keyBytes.Length;
}
Array.Copy(pwdBytes, keyBytes, len);
rijndaelCipher.Key = keyBytes;
rijndaelCipher.IV = keyBytes;
ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
return Convert.ToBase64String(transform.TransformFinalBlock(plainText,
0, plainText.Length));
}
************************************************************
ASEKEY & merchantid will be provided by BANK after submitting return URL to bank
string redirecturl = ""; // this is to check what url is coming before encryption
string encryptredirecturl = "";
string ASEKEY = "xxxxxxxxxxxxxxxxxxxx";
string Reference_no, sub_merchant_id, pgamount, Mobile_No, city, name;
Reference_no ="your value";
sub_merchant_id ="your value";
pgamount = 000;
Mobile_No = "your value";;
city ="your value";
name = "your value";
redirecturl += "https://eazypay.icicibank.com/EazyPG?";
redirecturl += "merchantid=xxxxx";
redirecturl += "&mandatory fields=" + Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456";
redirecturl += "&optional fields=" + city + "|" + name;
redirecturl += "&returnurl=http://yourwebsite.com/eazypayreturn.aspx";
redirecturl += "&Reference No=" + Reference_no;
redirecturl += "&submerchantid=" + sub_merchant_id;
redirecturl += "&transaction amount=" + pgamount;
redirecturl += "&paymode=9";
encryptredirecturl += "https://eazypay.icicibank.com/EazyPG?";
encryptredirecturl += "merchantid=xxxxx";
encryptredirecturl += "&mandatory fields=" + encryptFile(Reference_no + "|" + sub_merchant_id + "|" + pgamount + "|" + Mobile_No + "|456", ASEKEY);
encryptredirecturl += "&optional fields=" + encryptFile(city + "|" + name, ASEKEY);
encryptredirecturl += "&returnurl=" + encryptFile("http://yourwebsite.com/eazypayreturn.aspx", ASEKEY);
encryptredirecturl += "&Reference No=" + encryptFile(Reference_no, ASEKEY);
encryptredirecturl += "&submerchantid=" + encryptFile(sub_merchant_id, ASEKEY);
encryptredirecturl += "&transaction amount=" + encryptFile(pgamount, ASEKEY);
encryptredirecturl += "&paymode=" + encryptFile("9", ASEKEY);
Response.Redirect(encryptredirecturl);
-----------------------------------------------------------------------------------------
public static string encryptFile(string textToEncrypt, string key)
{
RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = CipherMode.ECB;
rijndaelCipher.Padding = PaddingMode.PKCS7;
rijndaelCipher.KeySize = 0x80;
rijndaelCipher.BlockSize = 0x80;
byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
byte[] keyBytes = new byte[0x10];
int len = pwdBytes.Length;
if (len > keyBytes.Length)
{
len = keyBytes.Length;
}
Array.Copy(pwdBytes, keyBytes, len);
rijndaelCipher.Key = keyBytes;
rijndaelCipher.IV = keyBytes;
ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
return Convert.ToBase64String(transform.TransformFinalBlock(plainText,
0, plainText.Length));
}
************************************************************
After coming back to return url , get response parameters and their vales
foreach (string key in HttpContext.Current.Request.Form.AllKeys)
{
string value = HttpContext.Current.Request.Form[key];
if (value == "E000")
{
//Success
}
else
{
//Error
}
}
very helpful code! Thanks for sharing information.
ReplyDeletePayment Gateway Integration
Thank you Israr for the very helpful code. its working. Can you please help how to validate the response in the payment confirmation page? Thanks in advance.
ReplyDeleteIm getting session time out exception in https://eazypay.icicibank.com/ClickOnNextToAcctAction page after click on proceed button in eazypay,if I go back from this error page its returning back to my application and showing transaction already paid error message.It is returning E006 error and sometimes it is returning E0038 response code
ReplyDeleteCan you please help me to fix this E006 error
ReplyDeletecan you please help me its redirecting to return url not the payment gateway
ReplyDeletei am also having the same issue
DeleteI am also get same issue.....Please any one help me...
DeleteHow to test my payment getway url, any test api is there
ReplyDeletehow to use their verify status api
ReplyDeleteThis blog is so informative for providing a valuable information about send c# sms gateway integration. Get ready to use integrated Bulk SMS API and easily integrate it into your software to Send SMS in a single click.
ReplyDeletei have implement the eazypay paymentgetway but it's return the "Your Session has expired"
ReplyDelete, i have implement the your given above code using asp.net mvc4
please provide me suggestion what to do
Is there any api to verfiy broken payment has been done.
ReplyDeleteThanks for sharing plz check
ReplyDeletec# sms gateway integration
please provide a integration source code for asp.net mvc 4
ReplyDeleteThanks 4 help
ReplyDeleteFor all those who get a session expired error - do not copy paste the URL in the browser; rather create a page that redirects to this URL; I think the system checks for referrer variable.
ReplyDelete