using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Security.Cryptography; public partial class quick_payment : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtOrderId.Text = GenerateID(); } } private string createToken(string message, string secret) { secret = secret ?? ""; var encoding = new System.Text.ASCIIEncoding(); byte[] keyBytes = encoding.GetBytes(secret); byte[] messageBytes = encoding.GetBytes(message); using (var hmacsha256 = new HMACSHA256(keyBytes)) { byte[] hashmessage = hmacsha256.ComputeHash(messageBytes); return (Convert.ToBase64String(hashmessage)); } } protected void btnpay_Click(object sender, EventArgs e) { string secretKey = instituteConfiguration.SecretKey; string appId = instituteConfiguration.AppId; string data = ""; SortedDictionary formParams = new SortedDictionary(); formParams.Add("appId", appId); formParams.Add("orderId", txtOrderId.Text); formParams.Add("orderAmount", txtOrderAmount.Text); formParams.Add("customerName", txtCustomerName.Text); formParams.Add("customerPhone", txtCustomerPhone.Text); formParams.Add("customerEmail", txtCustomerEmail.Text); formParams.Add("returnUrl", "https://dicsindia.in/transaction-status.aspx"); foreach (var kvp in formParams) { data = data + kvp.Key + kvp.Value; } string signature = createToken(data, secretKey); Console.Write(signature); string outputHTML = ""; outputHTML += ""; outputHTML += ""; outputHTML += "Merchant Checkout Page"; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += "

Please do not refresh this page.....

"; outputHTML += "
"; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; outputHTML += ""; foreach (string keys in formParams.Keys) { outputHTML += ""; } outputHTML += ""; outputHTML += "
"; outputHTML += ""; outputHTML += "
"; outputHTML += ""; outputHTML += ""; Response.Write(outputHTML); } protected string GenerateID() { //string alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //string small_alphabets = "abcdefghijklmnopqrstuvwxyz"; string numbers = "1234567890"; string characters = numbers; //characters += alphabets + small_alphabets + numbers; //int length = int.Parse(ddlLength.SelectedItem.Value); int length = 8; string id = string.Empty; for (int i = 0; i < length; i++) { string character = string.Empty; do { int index = new Random().Next(0, characters.Length); character = characters.ToCharArray()[index].ToString(); } while (id.IndexOf(character) != -1); id += character; } return (id); } }