我希望将支付网关集成到我的网络应用程序中,并发现他们的集成需要一个前端表单来提交值 - 在应用程序中,我目前没有支付前端,只需要一个负载结束VB.NET代码,收集信息并将其传递到类似支付网关的URL。
由于网关依赖于发布的表单,我需要找到一种方法来仅使用后端代码来模拟这个,所以我对这一切的最大问题是,是否可以提交(POST)表单而不用用户点击按钮?
前端所需的表格是:
<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>
如果在没有按钮的情况下提交表单失败,那么一旦所有隐藏字段都到位后重新定向到动作网址,它是否会产生相同的效果?
答案 0 :(得分:1)
使用System.Net.WebClient是最简单的方法。
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