M
M
mars1302020-07-21 23:47:35
PHP
mars130, 2020-07-21 23:47:35

How to generate a signature in robcheks?

Colleagues, welcome, please tell me how to correctly generate a signature for robots, the whole brain has already boiled, I can’t find a solution.

There is documentation: https://docs.robokassa.ru/ru/#6865
I work on a server with PHP 5.6

Here is what support writes to me:

test:1::%7B%22items%22:%5B%7B%22name%22:%22%D0%A3%D1%81%D0%BB%D1%83%D0%B3%D0%B0%22,%22quantity%22:1,%22sum%22:1,%22tax%22:%22none%22%7D%5D%7D:test:[email protected]
// JSON array must be necessarily URL encoded

Signature after hashing in md5:
498da474bfa68b50045302f01c7c199a

And I'm trying to reproduce the same thing through the code, but I can't achieve the same signature after hashing. Tell me good people what is my problem? Here is the code:

<?

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

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

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

// описание заказа
// order description
$inv_desc = "ROBOKASSA Advanced User Guide";

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

// тип товара
// code of goods
$shp_item = "[email protected]";

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

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

// кодировка
// encoding
$encoding = "utf-8";

$array= Array(
    "items" => Array(
        Array(
            "name" => "Услуга",
            "quantity" => "1",
            "sum" => $out_summ,
            "tax" => "none"
        )
    )
);

$receipt = rawurlencode(json_encode($array));

// формирование подписи
// generate signature

$crc  = md5("$mrh_login:$inv_id::$receipt:$mrh_pass1:shp_item=$shp_item");

// HTML-страница с кассой
// ROBOKASSA HTML-page
print "<html><script language=JavaScript ".
      "src='https://auth.robokassa.ru/Merchant/PaymentForm/FormV.js?".
"MerchantLogin=$mrh_login&OutSum=$out_summ&Shp_item=$shp_item&Receipt=$receipt".
      "&Description=$inv_desc&SignatureValue=$crc'></script></html>";
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question