📜 ⬆️ ⬇️

About Robokassa clearly

Last night I added an interface with Robokassa to my CMS.

Briefly about the payment system


Robokassa - an integrator of payment systems. It allows you to organize the reception of payments in favor of the store through many well-known electronic currencies (Webmoney, VKontakte, Yandex, Money, Money Mail. Ru, RBK Money and others), through payment terminals EleksNet, and, most importantly, via SMS.

There are two connection options available - for legal entities and individual entrepreneurs, with the withdrawal of money from the system to the current account and for individuals with the option of output to electronic currencies.

check in


Registration is quite simple. Go to https://www.roboxchange.com/Environment/Partners/Login/Login.aspx?reg=Merchant and carefully fill in all the required fields. After completing registration, wait a while (about 5 minutes) and log in.
')
Initially, your account will have the status “Inactive”, this allows you to set up and test the store before switching to real mode.

Actually code - sending payment


Robokassa receives parameters from the store via a GET or POST request. You will need to create on the payment page something like this (this is the minimum option):
< form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  1. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  2. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  3. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  4. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  5. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  6. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  7. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  8. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
  9. < form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .
< form method ="post" action ="http://test.robokassa.ru/Index.aspx" > <!-- action "https://merchant.roboxchange.com/Index.aspx" --> < input type ="hidden" name ="MrchLogin" value ="-- --" /> < input type ="hidden" name ="OutSum" value ="-- , - --" /> < input type ="hidden" name ="InvId" value ="-- -- " /> < input type ="hidden" name ="Desc" value ="-- , : -- " /> < input type ="hidden" name ="SignatureValue" value ="{SIGNATURE}" /> < input type ="submit" value ="" /> </ form > * This source code was highlighted with Source Code Highlighter .


There is a field in the form, which I designated {SIGNATURE}. This is a specially formed signature of your store, we will return to it later.

In order to process the response of Robokassa to the payment attempt, it is necessary in the personal account of the system at https://www.roboxchange.com/Environment/Partners/Login/Merchant/Administration.aspx to enter data on the three pages that will process this answer .


and choose for each address a parameter transfer method - GET or POST. I personally chose POST.

In addition, you must fill in two passwords, # 1 and # 2. We will need them for the formation of signatures. The first is for sending Robokassa data, the second is for checking data coming from it.

Now back to the {SIGNATURE} field in our form. It is calculated as follows:
$login = " " ;
$amount = floatval(__); // floatval , "99.00" "99"
$id = ____;
$pwd1 = "__#1" ;
$signature = md5($login . ":" . $amount . ":" . $id . ":" . $pwd1);


* This source code was highlighted with Source Code Highlighter .


Each time you make a payment request form, you must calculate this signature and submit it in the form.

Actually code - payment processing


At the Result URL, you need to place the Robokassa response handler.
I will cite immediately the code:
$id = intval($_POST[ 'InvId' ]); //
$pwd2 = "__#2" ;
$sum = ________;

/*
.
- "ERR"
*/

if ( $sum != floatval($_POST[ 'OutSum' ]) ) {
//
echo "ERR: invalid amount" ;
exit();
}

if ( strtolower($_POST[ 'SignatureValue' ]) != strtolower(md5($_POST[ 'OutSum' ] . ":" . $id . ":" . $pwd2)) ) {
//
echo "ERR: invalid signature" ;
exit();
}

// :
// , ,
//
echo "OK" . $id;
exit();


* This source code was highlighted with Source Code Highlighter .


Activation


Test your store. Try to make a test payment and you will get on a special form of checking the interface. There you can check the response of your Result URL, see what is being transmitted from you to Robokassa, check the operation of the Success URL and the Fail URL.

When you successfully complete the testing - submit an application for account activation . After a positive response, do not forget to change the action in the form of payment.

Good luck!

PS A detailed description of the Robokassa interface can be found here: http://www.robokassa.ru/Doc/Ru/Interface.aspx

Source: https://habr.com/ru/post/82998/


All Articles