protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Random rnd = new Random(); string s = string.Empty; for (int i = 0; i < 10; i++) { s = string.Concat(s, rnd.Next(10).ToString()); } string strHash = new CitrusCommunication().Generatehash512(s + DateTime.Now); txtMerchantTxnId.Text = strHash.ToString().Substring(0, 20); } }
protected void btnRefund_Click(object sender, EventArgs e) { try { string UrlRequest = ConfigurationManager.AppSettings["sandboxadmin"].ToString() + "/api/v2/txn/refund"; //data to send //NameValueCollection myData = new NameValueCollection(); //myData.Add("merchantTxnId", txtMerchantTxnID.Text); //myData.Add("pgTxnId", txtPgTxnId.Text); //myData.Add("rrn", txtRrn.Text); //myData.Add("authIdCode", txtAuthIdCode.Text); //myData.Add("currencyCode",txtCurrCode.Text); //myData.Add("amount",txtAmount.Text); //myData.Add("txnType", "Refund"); TransactionRefund tRefund = new TransactionRefund(); tRefund.merchantTxnId = txtMerchantTxnID.Text; tRefund.pgTxnId = txtPgTxnId.Text; tRefund.rrn = txtRrn.Text; tRefund.authIdCode = txtAuthIdCode.Text; tRefund.currencyCode = txtCurrCode.Text; tRefund.amount = txtAmount.Text; tRefund.txnType = "Refund"; string dataZ = "merchantAccessKey=" + ConfigurationManager.AppSettings["access_key"].ToString() + "&transactionId=" + txtMerchantTxnID.Text + "&amount=" + txtAmount.Text; string secSignature = new CitrusCommunication().generateSignature(ConfigurationManager.AppSettings["secret_key"].ToString(), dataZ); var DataToSend = new JavaScriptSerializer().Serialize(tRefund); using (WebClient client = new WebClient()) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; client.Headers["access_key"] = ConfigurationManager.AppSettings["access_key"].ToString(); client.Headers["signature"] = secSignature; client.Headers["Content-Type"] = "application/json"; client.Headers["Accept"] = "application/json"; string strResponse = client.UploadString(UrlRequest, "POST", DataToSend); JObject obj = JObject.Parse(strResponse); lblRespCode.Text = (string)obj["respCode"]; lblRespMsg.Text = (string)obj["respMsg"]; lblTxnId.Text = (string)obj["merchantTxnId"]; lblPgTxnId.Text = (string)obj["pgTxnId"]; lblAuthIdCode.Text = (string)obj["authIdCode"]; lblRRN.Text = (string)obj["rrn"]; lblAmount.Text = (string)obj["amount"]; } } catch (Exception ex) { } }
protected void btnMakePayment_Click(object sender, EventArgs e) { try { string merchantURLPart = ConfigurationManager.AppSettings["merchantURLPart"].ToString(); string vanityURLPart = ""; if (merchantURLPart.LastIndexOf("/") != -1) { vanityURLPart = merchantURLPart.Substring(merchantURLPart.LastIndexOf("/") + 1); } string merchantTxnId = ""; string orderAmount = ""; string currency = ""; string firstName = ""; string lastName = ""; string email = ""; string addressStreet1 = ""; string addressCity = ""; string addressZip = ""; string addressState = ""; string phoneNumber = ""; string returnUrl = ""; string secSignature = ""; string reqtime = ""; merchantTxnId = txtMerchantTxnId.Text; orderAmount = String.Format("{0:0.00}", Convert.ToDecimal(txtOrderAmount.Text)); currency = txtCurrency.Text; firstName = txtFirstName.Text; lastName = txtLastName.Text; email = txtEmail.Text; addressStreet1 = txtAddressStreet1.Text; addressCity = txtAddressCity.Text; addressZip = txtAddressZip.Text; addressState = txtAddressState.Text; phoneNumber = txtPhoneNumber.Text; returnUrl = hdnReturnUrl.Value; string dataZ = vanityURLPart + orderAmount + merchantTxnId + currency; secSignature = new CitrusCommunication().generateSignature(ConfigurationManager.AppSettings["secret_key"].ToString(), dataZ); reqtime = (DateTime.Now.Ticks / 10000).ToString(); Hashtable data = new Hashtable(); // adding values in hash table for data post data.Add("key", ConfigurationManager.AppSettings["secret_key"].ToString()); data.Add("merchantURLPart", merchantURLPart); data.Add("merchantTxnId", merchantTxnId); data.Add("orderAmount", orderAmount); data.Add("currency", currency); data.Add("firstName", firstName); data.Add("lastName", lastName); data.Add("email", email); data.Add("addressStreet1", addressStreet1); data.Add("addressCity", addressCity); data.Add("addressZip", addressZip); data.Add("addressState", addressState); data.Add("phoneNumber", phoneNumber); data.Add("returnUrl", returnUrl); data.Add("secSignature", secSignature); data.Add("reqtime", reqtime); string strForm = new CitrusCommunication().PostFormSeamless(merchantURLPart, data); Page.Controls.Add(new LiteralControl(strForm)); } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string key = ConfigurationManager.AppSettings["secret_key"].ToString(); string data = ""; string txnId = Request["TxId"]; string txnStatus = Request["TxStatus"]; string amount = Request["amount"]; string pgTxnId = Request["pgTxnNo"]; string issuerRefNo = Request["issuerRefNo"]; string authIdCode = Request["authIdCode"]; string firstName = Request["firstName"]; string lastName = Request["lastName"]; string pgRespCode = Request["pgRespCode"]; string zipCode = Request["addressZip"]; string reqSignature = Request["signature"]; string signature = string.Empty; if (Request["TxId"] != null) { data += txnId; } if (Request["TxStatus"] != null) { data += txnStatus; } if (Request["amount"] != null) { data += amount; } if (Request["pgTxnNo"] != null) { data += pgTxnId; } if (Request["issuerRefNo"] != null) { data += issuerRefNo; } if (Request["authIdCode"] != null) { data += authIdCode; } if (Request["firstName"] != null) { data += firstName; } if (Request["lastName"] != null) { data += lastName; } if (Request["pgRespCode"] != null) { data += pgRespCode; } if (Request["addressZip"] != null) { data += zipCode; } signature = new CitrusCommunication().generateSignature(key, data); if (reqSignature.Equals(signature)) { //true lblMsg.Text = "Signature Matched TxnId=" + txnId + " , Status=" + txnStatus + " , issuerRefNo=" + issuerRefNo; } else { //false; lblMsg.Text = "Signature Match Fail TxnId=" + txnId + " , Status=" + txnStatus + " , issuerRefNo=" + issuerRefNo; } } }