Reputation: 6346
I want integrate a payment gateway into my web app and found that thier integration required a front end form to submit the values across - In the app I don't current have a front end for the payment, just a load of back end VB.NET code that collects the info and passes it into a url for a similar payment gateway.
Being as the gateway relies on a form being posted I need to find a way to simulate this using only back end code, so my biggest question in regards to all this is, is it possible to submit (POST) a form without the user clicking a button?
The form required in the front end is:
<form method="post" action="https://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp / orderstandard_utf8.asp" id=form1 name=form1>
<!-- general parameters: see Form parameters -->
<input type="hidden" name="PSPID" value="">
<input type="hidden" name="ORDERID" value="">
<input type="hidden" name="AMOUNT" value="">
<input type="hidden" name="CURRENCY" value="">
<input type="hidden" name="LANGUAGE" value="">
<input type="hidden" name="CN" value="">
<input type="hidden" name="EMAIL" value="">
<input type="hidden" name="OWNERZIP" value="">
<input type="hidden" name="OWNERADDRESS" value="">
<input type="hidden" name="OWNERCTY" value="">
<input type="hidden" name="OWNERTOWN" value="">
<input type="hidden" name="OWNERTELNO" value="">
<!-- check before the payment: see Security: Check before the payment -->
<input type="hidden" name="SHASIGN" value="">
<!-- layout information: see Look and feel of the payment page -->
<input type="hidden" name="TITLE" value="">
<input type="hidden" name="BGCOLOR" value="">
<input type="hidden" name="TXTCOLOR" value="">
<input type="hidden" name="TBLBGCOLOR" value="">
<input type="hidden" name="TBLTXTCOLOR" value="">
<input type="hidden" name="BUTTONBGCOLOR" value="">
<input type="hidden" name="BUTTONTXTCOLOR" value="">
<input type="hidden" name="LOGO" value="">
<input type="hidden" name="FONTTYPE" value="">
<!-- post payment redirection: see Transaction feedback to the customer -->
<input type="hidden" name="ACCEPTURL" value="">
<input type="hidden" name="DECLINEURL" value="">
<input type="hidden" name="EXCEPTIONURL" value="">
<input type="hidden" name="CANCELURL" value="">
<input type="submit" value="" id=submit2 name=submit2>
</form>
Failing submitting the form without a button, would it then have the same effect if i re-directed to the action url once all the hidden fields were in place?
Upvotes: 0
Views: 354
Reputation: 4710
Using System.Net.WebClient is the easiest way to go.
Dim Url As String = "https://mdepayments.epdq.co.uk/ncol/test/orderstandard.asp"
Using Client As New WebClient
Dim Params As New Specialized.NameValueCollection
With Params
.Add("PSPID", "")
.Add("ORDERID", "")
'......
End With
Dim Response As Byte() = Client.UploadValues(Url, "POST", Params)
Dim ResponseText As String = (New Text.UTF8Encoding).GetString(Response)
End Using
Upvotes: 1