Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys I have a problem.

Now, I try to implement payment module within my project.

So they send samples for implements like this.

HTML
<%

      String hashstr = clientId + oid + amount + okUrl + failUrl + islemtipi + taksit + rnd + storekey;
      System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
      byte[] hashbytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(hashstr);
      byte[] inputbytes = sha.ComputeHash(hashbytes);

      String hash = Convert.ToBase64String(inputbytes);


  %>
  <form action="xxxxx" method="POST">
         <input type="hidden" name="clientid" value="<%=clientId%>">
              <input type="hidden" name="amount" value="<%=amount%>">

              <input type="hidden" name="oid" value="<%=oid%>">
              <input type="hidden" name="okUrl" value="<%=okUrl%>" >
              <input type="hidden" name="failUrl" value="<%=failUrl%>" >
              <input type="hidden" name="rnd" value="<%=rnd%>" >
              <input type="hidden" name="hash" value="<%=hash%>" >

              <input type="hidden" name="storetype" value="3d_pay_hosting" >
      <input type="submit" name="submit" value="Send">
  </form>

So this code run very well when I press the button my page direct to bank page and than in there customer charges the money after that it return my okUrl.

But my problem I have to use this code in page which under the master page and there are many button in this web page. How can I perform this scenario very well.

Some code samples that I search on the internet says you have to use WebRequest like this.

C#
StringBuilder builderValues = new StringBuilder();
             builderValues.Append("&okUrl=" + "http://xxx.com/Payment/" + oid);

           builderValues.Append("&failUrl=" + "http://xxx.com/Failed/" + oid);

           builderValues.Append("&storetype=3d_pay_hosting");
           ASCIIEncoding encoding = new ASCIIEncoding();
           string postData = builderValues.ToString();
           // Prepare web request...
           byte[] data = new ASCIIEncoding().GetBytes(postData);
           HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("xxx");
           httpWebRequest.Method = "POST";
           httpWebRequest.ContentType = "application/x-www-form-urlencoded";
           httpWebRequest.ContentLength = data.Length;
           Stream dataStream = httpWebRequest.GetRequestStream();
           dataStream.Write(data, 0, data.Length);
           HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();
           StreamReader reader = new StreamReader(response.GetResponseStream());
           String responseString = reader.ReadToEnd();
           dataStream.Close();


But that time my page would not redirect to bank page for charges cost.

Can you give some help or suggestion please.

Thanks.
Posted
Comments
Are you sure it is not redirecting when you use Master Page?
ammoti 16-May-14 10:39am    
yes :S

1 solution

Guys this code worked. But now there is another problem

C#
streamIn.Close();

            Session["deneme"] = strResponse;
            Response.Write(strResponse);


this strResponse return HTML code for payment but I don know how I use this. because I have to open another page this html.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900