public static string CreateJasonRequest(IPGData iPGData) { RequestClass requestClass = new RequestClass(); requestClass.Request.CmsPreservationId = iPGData.CmsPreservationId; requestClass.Request.AcceptorId = iPGData.AcceptorId; requestClass.Request.amount = iPGData.Amount; requestClass.Request.BillInfo = iPGData.BillInfo; requestClass.Request.multiplexParameters = iPGData.MultiplexParameters; requestClass.Request.PaymentId = iPGData.PaymentId; requestClass.Request.RequestId = iPGData.RequestId; requestClass.Request.RevertUri = iPGData.RevertURL; requestClass.Request.terminalId = iPGData.TreminalId; requestClass.Request.RequestTimestamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; requestClass.Request.transactionType = iPGData.TransactionType; CreateAESCoding(requestClass, iPGData.RsaPublicKey, iPGData.PassPhrase, requestClass.Request.multiplexParameters == null ? false : true); try { } catch (Exception ex) { } return(JsonConvert.SerializeObject(requestClass));; }
protected void getToken_onclick(object sender, EventArgs e) { try { WebHelper webHelper = new WebHelper(); XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("DataXmlFile.xml")); string paymetId = new Random().Next().ToString(); string requestId = new Random().Next().ToString(); string request = string.Empty; IPGData iPGData = new IPGData(); iPGData.TreminalId = txtTerminalId.Text; iPGData.AcceptorId = txtAcceptorID.Text; iPGData.PassPhrase = txtPassPhrase.Text; iPGData.RevertURL = doc.SelectNodes("DocumentElement/IPGData")[0].SelectNodes("URL")[0].InnerText; iPGData.Amount = long.Parse(txtAmount.Text); iPGData.PaymentId = paymetId; iPGData.RequestId = requestId; iPGData.CmsPreservationId = "989206006206"; iPGData.TransactionType = TransactionType.Purchase; iPGData.BillInfo = null; iPGData.RsaPublicKey = doc.SelectNodes("DocumentElement/IPGData/RSAPublicKey")[0].InnerXml.ToString(); if (false) { // پرداخت تسهیمی MultiplexParameter account1 = new MultiplexParameter(); List <MultiplexParameter> multiplexParameters = new List <MultiplexParameter>(); account1.Amount = int.Parse(txtAmount.Text); account1.Iban = "IR Your Iban"; multiplexParameters.Add(account1); iPGData.MultiplexParameters = multiplexParameters; request = CreateJsonRequest.CreateJasonRequest(iPGData); } if (false) { // :) پرداخت معمولی نقی request = CreateJsonRequest.CreateJasonRequest(iPGData); } Uri url = new Uri(string.Format(@"https://ikc.shaparak.ir/api/v3/tokenization/make")); string jresponse = webHelper.Post(url, request); if (jresponse != null) { TokenResult jResult = JsonConvert.DeserializeObject <TokenResult>(jresponse); //Handle your reponse here txtToken.Text = jResult.result.token; if (jResult.status) { // tblForm.Visible = true; Literal2.Text = string.Format("<input id='token' type='hidden' name='tokenIdentity' value='{0}' runat='server'/>", txtToken.Text); } } } catch (Exception exe) { txtToken.Text = exe.Message; } }
private bool GenrateToken() { try { WebHelper webHelper = new WebHelper(); XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("DataXmlFile.xml")); string paymetId = new Random().Next().ToString(); string requestId = new Random().Next().ToString(); string request = string.Empty; IPGData iPGData = new IPGData(); iPGData.TreminalId = txtTerminalId.Text; iPGData.AcceptorId = txtAcceptorID.Text; iPGData.PassPhrase = doc.SelectNodes("DocumentElement/IPGData")[0].SelectNodes("PassPhrase")[0].InnerText; iPGData.RevertURL = doc.SelectNodes("DocumentElement/IPGData")[0].SelectNodes("URL")[0].InnerText; iPGData.Amount = long.Parse(txtAmount.Text); iPGData.PaymentId = null; iPGData.RequestId = requestId; iPGData.CmsPreservationId = "989206006206"; iPGData.TransactionType = TransactionType.Bill; iPGData.MultiplexParameters = null; iPGData.RsaPublicKey = doc.SelectNodes("DocumentElement/IPGData/RSAPublicKey")[0].InnerXml.ToString();; BillInfo billInfo = new BillInfo(); billInfo.BillId = txtBillId.Text; billInfo.billPaymentId = txtPaymentId.Text; iPGData.BillInfo = billInfo; request = CreateJsonRequest.CreateJasonRequest(iPGData); Uri url = new Uri(string.Format(@"https://ikc.shaparak.ir/api/v3/tokenization/make")); string jresponse = webHelper.Post(url, request); if (jresponse != null) { TokenResult jResult = JsonConvert.DeserializeObject <TokenResult>(jresponse); txtToken.Text = jResult.result.token; return(jResult.status); } return(false); } catch (Exception ex) { return(false); } }
protected void getToken_Click(object sender, EventArgs e) { try { WebHelper webHelper = new WebHelper(); string paymetId = new Random().Next().ToString(); string requestId = new Random().Next().ToString(); string request = string.Empty; int totalAmount = 0; XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("DataXmlFile.xml")); IPGData iPGData = new IPGData(); iPGData.TreminalId = txtTerminalId.Text; iPGData.AcceptorId = txtAcceptorID.Text; iPGData.PassPhrase = txtPassPhrase.Text; iPGData.RevertURL = doc.SelectNodes("DocumentElement/IPGData")[0].SelectNodes("URL")[0].InnerText; iPGData.PaymentId = paymetId; iPGData.RequestId = requestId; iPGData.CmsPreservationId = "989127980595"; iPGData.TransactionType = TransactionType.Purchase; iPGData.BillInfo = null; List <MultiplexParameter> multiplexParameters = new List <MultiplexParameter>(); if (!string.IsNullOrEmpty(txtAmount1.Text)) { MultiplexParameter account1 = new MultiplexParameter(); account1.Amount = int.Parse(txtAmount1.Text); account1.Iban = DropDownList0.SelectedItem.Text; multiplexParameters.Add(account1); totalAmount += int.Parse(txtAmount1.Text); } if (!string.IsNullOrEmpty(txtAmount2.Text)) { MultiplexParameter account1 = new MultiplexParameter(); account1.Amount = int.Parse(txtAmount2.Text); account1.Iban = DropDownList1.SelectedItem.Text; multiplexParameters.Add(account1); totalAmount += int.Parse(txtAmount2.Text); } iPGData.MultiplexParameters = multiplexParameters; txtAmount.Text = totalAmount.ToString(); iPGData.Amount = long.Parse(txtAmount.Text); iPGData.RsaPublicKey = doc.SelectNodes("DocumentElement/IPGData/RSAPublicKey")[0].InnerXml.ToString(); request = CreateJsonRequest.CreateJasonRequest(iPGData); Uri url = new Uri(string.Format(@"https://ikc.shaparak.ir/api/v3/tokenization/make")); string jresponse = webHelper.Post(url, request); if (jresponse != null) { TokenResult jResult = JsonConvert.DeserializeObject <TokenResult>(jresponse); //Handle your reponse here txtToken.Text = jResult.result.token; } Literal2.Text = string.Format("<input id='token' type='hidden' name='tokenIdentity' value='{0}' runat='server' />", txtToken.Text); } catch (Exception exe) { Response.Redirect("VerifyPage.aspx"); } }