Public Class RemotePost
Private Inputs As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection
Public Url As String = ""
Public Method As String = "post"
Public FormName As String = "form1"
Public Sub Add ( ByVal name As String , ByVal value As String )
Inputs.Add (name, value)
End sub
Public Sub Post ()
System.Web.HttpContext.Current.Response.Clear ()
System.Web.HttpContext.Current.Response.Write ( "<html> <head>" )
System.Web.HttpContext.Current.Response.Write ( String .Format ( "</ head> <body onload =" "document. {0} .submit ()" ">" , FormName))
System.Web.HttpContext.Current.Response.Write ( String .Format ( "<form name =" "{0}" "method =" "{1}" "action =" "{2}" ">" , FormName , Method, Url))
Dim i As Integer = 0
Do While i <Inputs.Keys.Count
System.Web.HttpContext.Current.Response.Write ( String .Format ( "<input name =" "{0}" "type =" "hidden" "value =" "{1}" ">" , Inputs.Keys (i) Inputs (Inputs. Keys (i))))
i + = 1
Loop
System.Web.HttpContext.Current.Response.Write ( "</ form>" )
System.Web.HttpContext.Current.Response.Write ( "</ body> </ html>" )
System.Web.HttpContext.Current.Response. End ()
End sub
End class
Dim myremotepost As RemotePost = New RemotePost ()
myremotepost.Add ( "out_summ" , txtPay.Text)
'how much the user gives
myremotepost.Add ( "mrh" , "mylogin" )
'id prodovtsa in robocase
Dim temp As Integer = pay.Add (txtPay. Text, Membership. GetUser.UserName, Now)
'pay class - means of interaction with the pay table
'(fields: pay - payment amount, user - name of the paying user, date - payment date,
'id - identifier, status - “OK”, when the payment was completed).
'Pay.add - fills in all fields, returns id.
myremotepost.Add ( "inv_id" , temp)
'payment id
myremotepost.Add ( "inv_desc" , "blah blah blah" )
'payment description, displayed in robokassa
myremotepost.Add ( "crc" , md5.MD5Hash ( "mylogin:" & txtPay.Text.Trim & ":" & temp & ": secret_1" ))
'MD5 checksum - a string representing a 32-bit number
'in hexadecimal form and in any case (32 characters total 0-9, AF).
'Generated by a string containing all required parameters,
'separated': ', with the addition of Password # 1
myremotepost.Url = " www.roboxchange.com/ssl/calc.asp "
'sent a request
myremotepost.Post ()
Protected Sub Page_Load ( ByVal sender As Object , ByVal e As System.EventArgs) Handles Me .Load
Dim str As String = ""
Dim h As String = ""
Dim id As String = ""
If Not (Request.Form ( "out_summ" ) Is Nothing ) Then
str + = (Request.Form ( "out_summ" )) & ":"
End if
If Not (Request.Form ( "inv_id" ) Is Nothing ) Then
str + = (Request.Form ( "inv_id" )) & ":"
id = (Request.Form ( "inv_id" ))
End if
If Not (Request.Form ( "crc" ) Is Nothing ) Then
h + = (Request.Form ( "crc" ))
End if
str + = "secret_2"
'Password # 2
If md5.MD5Hash (str) = h Then
pay.ok (id)
'pay.ok - by id finds the payment, puts its status as “ok”
'and adds the payment amount to the user.
Response.Write ( "OK" & id)
'answered by the robokassa that the request was processed
End if
End sub
Public Class md5
Shared Function MD5Hash ( ByVal instr As String ) As String
Dim strHash As String = String .Empty
For Each b As Byte In New System.Security.Cryptography.MD5CryptoServiceProvider (). ComputeHash (Encoding. [ Default ] .GetBytes (instr))
strHash + = b.ToString ( "X2" )
Next
Return strHash
End function
Source: https://habr.com/ru/post/39187/
All Articles