Click here to Skip to main content
15,883,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need to setup transactions between our customers and a bank for payments. The overall scheme is to have the customers click on a button on our site that will initiate the HTTP POST to the bank site. After the initial connection, there will be a response from the bank then a response from us, then finally the customer will be on the bank site to complete the transaction.

The initial connection is to mimic this example:

<form action="https://hostname/path" method="post">
<input type="hidden" name="app_id" value="0">
<input type="hidden" name="mess_ver" value="1.1">
</form>

So, my fist question is: how to I do the above in ASP.NET/VB?

Thank you in advance.
Posted
Comments
PhilLenoir 13-Aug-14 11:10am    
I don't understand the problem. That code should be just fine in an aspx. Does your question relate to using ASPX server controls instead of HTML ones?
Geof3 14-Aug-14 11:35am    
The example I am giving is the html way...how would I go about doing the same thing in asp.net?
PhilLenoir 14-Aug-14 11:54am    
If you create a blank ASPX page and replace the form tag and its contents with your HTML form it will work exactly the same. ASPX is contstructed from XHTML which is simply HTML with more tags. I assume that you must use the above field names for the bank? Do you want to get the values on your server side?
Geof3 14-Aug-14 12:46pm    
The fields names are some of the names that must be used. Once the above code is run, there will be a response from the destination server, which I will then have to accept and respond to. Then their server will take over and process a payment and finally come back to our server. Its the transmission back and forth that I am getting confused with. The above code is the starting point from our end.

Create an ASPX page in a new web project and use this for the form code:

<form id="form1" action="https://hostname/path" method="post" runat="server">
<asp:hiddenfield id="hidApp_id" name="app_id" value="0" runat="server"/>
<asp:hiddenfield id="hidMess_ver" name="mess_ver" value="1.1" "runat="server" />
</form>

From your VB you can now:

hidApp_id.Value = x
hidMess_ver.Value= y
 
Share this answer
 
v3
Comments
Geof3 15-Aug-14 11:22am    
Thank you for your suggestions....but how do I accept the responses from the bank side?
PhilLenoir 15-Aug-14 11:28am    
Geoff, how do they reply to the request. My eCommerce provider uses an iFrame that contains a page that posts to them. They then redirect to a page I provide and I pick up their returned values there. Refer to your provider's documentation. Does the end user interact with this page? If not, another mechanism is to send the Post request using an HTTP object and receive the request directly (no browser).
Geof3 15-Aug-14 15:17pm    
They are suppose to be posting to a page I provided - but after I initiate the session, that page is never accessed. This is the code I have as of now. I am posting to them their fields, but nothing happens after that.

Sub ConnectBankHTTP(url As String, postData As String)

Dim myWebRequest As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
myWebRequest.Method = "POST"

Dim byteArray As Byte() = System.Text.Encoding.[Default].GetBytes(postData)
myWebRequest.ContentType = "application/x-www-form-urlencoded"
myWebRequest.ContentLength = byteArray.Length

Dim dataStream As System.IO.Stream = myWebRequest.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()


Dim myWebResponse As HttpWebResponse = CType(myWebRequest.GetResponse(), HttpWebResponse)
dataStream = myWebResponse.GetResponseStream()

Dim reader As New System.IO.StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
Response.Write(responseFromServer + ":")
' TextBox1.Text = responseFromServer
'Response.Redirect(responseFromServer)
reader.Close()
dataStream.Close()
myWebResponse.Close()

End Sub
Geof3 15-Aug-14 15:37pm    
I am getting something in return. If I display the value of responseFromServer, it is the HTML markup of an error page generated by the bank.
PhilLenoir 20-Aug-14 9:38am    
I think that you are going to have to use their support function. You might try sending the request to a debugging page on your own server to examine the source that you are rendering. I would expect their error response to have some code/information returned explaining the error (that you might need to refer to their documentation to explain) They should also be logging the errors at their end, so they should be able to tell what the issue is.
Use the server side control and use the value property to get the value from that control.

else you can use the sync java hit to using any other server side control like a asp:button and serve the same purpose.

Regards,
Dattatray Gaonkar
 
Share this answer
 
Comments
Geof3 15-Aug-14 11:22am    
Thank you for your suggestions....but how do I accept the responses from the bank side?

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