R
R
realnin2018-11-11 01:54:14
PHP
realnin, 2018-11-11 01:54:14

How to send a field from a form to Robokassa?

Task: take the data from the form and send it to the robokassa.
There is a Robokassa handler

<?

// 2.
// Оплата заданной суммы с выбором валюты на сайте ROBOKASSA
// Payment of the set sum with a choice of currency on site ROBOKASSA

// регистрационная информация (логин, пароль #1)
// registration info (login, password #1)
$mrh_login = "log";
$mrh_pass1 = "pass";

// номер заказа
// number of order
$inv_id = 0;

// описание заказа
// order description
$inv_desc = "VIP 2 пакет";

// сумма заказа
// sum of order
$out_summ = "4999";

// предлагаемая валюта платежа
// default payment e-currency
$in_curr = "";

// язык
// language
$culture = "ru";

   $shp_item= htmlspecialchars($_POST["Shp_item"]);   

// формирование подписи
// generate signature
$crc  = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1:Shp_item=$shp_item");

// форма оплаты товара
// payment form
print "<html>".
      "<form action='https://merchant.roboxchange.com/Index.aspx' method=POST>".
      "<input type=hidden name=MrchLogin value=$mrh_login>".
      "<input type=hidden name=OutSum value=$out_summ>".
      "<input type=hidden name=InvId value=$inv_id>".
      "<input type='text' name='Shp_item' required>".   
      "<input type=hidden name=Desc value='$inv_desc'>".
      "<input type=hidden name=SignatureValue value=$crc>".
      "<input type=hidden name=IncCurrLabel value=$in_curr>".
      "<input type=hidden name=Culture value=$culture>".
      "<input type=submit  value='ОПЛАТИТЬ'>".
      "</form></html>";
?>

The question is next. How can I get this field
"<input type='text' name='Shp_item' required>".
along with the robokassa response?
I can’t figure out how exactly I should push this dynamic field here
$crc  = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1:Shp_item=$shp_item");

tried It doesn't work, because the field needs to be received before submitting the form . Whatever I do, the Shp_item field always comes empty..
$shp_item= htmlspecialchars($_POST["Shp_item"]);
Получена оплата:
Цена: 4999.00
inv_id: 10060
Метод оплаты: BankCard
Shp_item=

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2018-11-11
@Adamos

When submitting a form, you access your site via ajax to get a signature, substitute it, and only then submit the form. At the same time, you check the validity of what the user entered (so that he does not substitute a fee of 1 ruble for an order worth 100 rubles, for example).
The signature, in fact, is used for this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question