
Integration with Robokassa (ASP.NET)
Task: Organize the reception of electronic money.
There was a certain project, which involved taking money from users for certain services. A robocash desk was chosen as a weaning tool - a serious, convenient, developing resource (recently they screwed up payment with SMS, there is, but is not yet active, payment by credit cards).
So, register .
After registration, we indicate some data for interacting with the cash desk:

Site idea: Each user registers, replenishes his balance on the site, and, in fact, spends this money on services.
User has registered.
Top up the balance: for this you need to send a peculiarly generated request to the URL of the robocash desk. To send a request, I use the following class:
We form a request:
After that, the cash desk works, if everything is ok, then you will be returned a request for “Success URL”.
We catch him:
Actually, everything, the user received money in his account, can spend =)
_________________________
Class md5
Description of Interfaces / Examples for both ASP.NET and other languages:
www.robokassa.ru/Doc/Ru/Interface.aspx
Beautiful brackets on the conscience of Source Code Highlighter
There was a certain project, which involved taking money from users for certain services. A robocash desk was chosen as a weaning tool - a serious, convenient, developing resource (recently they screwed up payment with SMS, there is, but is not yet active, payment by credit cards).
So, register .
After registration, we indicate some data for interacting with the cash desk:

Site idea: Each user registers, replenishes his balance on the site, and, in fact, spends this money on services.
User has registered.
Top up the balance: for this you need to send a peculiarly generated request to the URL of the robocash desk. To send a request, I use the following class:
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 (" ")
System.Web.HttpContext.Current.Response.Write (String.Format (" ", FormName))
System.Web.HttpContext.Current.Response.Write (String.Format ("")
System.Web.HttpContext.Current.Response.Write (" ")
System.Web.HttpContext.Current.Response.End ()
End Sub
End Class
We form a request:
Dim myremotepost As RemotePost = New RemotePost ()
myremotepost.Add ("out_summ", txtPay.Text)
'how much the user gives
myremotepost.Add ("mrh", "mylogin")
' seller id in the cash register
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 has passed).
'Pay.add - fills all the fields, returns id.
myremotepost.Add ("inv_id", temp)
'payment id
myremotepost.Add ("inv_desc", "blah blah blah")
' payment description, is displayed in the cash register
myremotepost.Add ("crc", md5.MD5Hash ("mylogin:" & txtPay.Text.Trim & ":" & temp & ": secret_1"))
'MD5 checksum is a 32-bit string
' at 16 -Richny form and in any case (total 32 characters 0-9, AF).
'It is formed on a line containing all the required parameters,
' separated ':', with the addition of Password # 1
myremotepost.Url = “ www.roboxchange.com/ssl/calc.asp ”
'sent a request to
myremotepost.Post ()
After that, the cash desk works, if everything is ok, then you will be returned a request for “Success URL”.
We catch him:
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, sets its status as “ok”
' and adds the payment amount to the user.
Response.Write (“OK” & id)
'answered the cash desk that the request was processed
End If
End Sub
Actually, everything, the user received money in his account, can spend =)
_________________________
Class md5
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
Description of Interfaces / Examples for both ASP.NET and other languages:
www.robokassa.ru/Doc/Ru/Interface.aspx
Beautiful brackets on the conscience of Source Code Highlighter