Answer the question
In order to leave comments, you need to log in
Error 400. Request signature not correct UnitPay, how to solve?
I just can’t understand what is the error in the formation of the link and the signature, can anyone come across this problem with this payment system?
Here is the code for generating a link and a signature (I did not add keys from my account).
private function getUrl($sum, $user_id, $order_id)
{
$account = $user_id;
$secretKey = 'Ключ для подписи';
$desc = 'Оплата заказа ' . $order_id;
$currency = 'RUB';
$hashStr = hash('sha256', $account.'{up}'.$currency.'{up}'.$desc.'{up}'.$sum.'{up}'.$secretKey);
return 'https://unitpay.ru/pay/111111-11111/card?sum=' . $sum . '&account=' . $account . '&desc=' . $desc . '&signature=' . $hashStr;
}
Answer the question
In order to leave comments, you need to log in
In general, I was compiling and digging, in the end I solved my problem, there were still a lot of errors, but I sort of fixed it.
It was 1. Due to the fact that RUB was indicated in the link and not in the key.
2. Order of adding parameters.
3. Description of the order, # <- the symbol did not skip this payment, I had to replace it with #. I tried to encrypt, but it did not work with the first character.
That's it, here's the working code:
private function getUrl($sum, $user_id, $order_id)
{
$desc = 'Оплата заказа №' . $order_id;
$hashStr = hash('sha256', $order_id.'{up}'.$desc.'{up}'.$sum.'{up}'.Config::SECRET_KEY);
return 'https://unitpay.ru/pay/'.Config::PUBLIC_KEY.'/card?account=' . $order_id . '&desc=' . $desc . '&sum=' . $sum . '&signature=' . $hashStr;
}
Я тут вывожу ссылку на форму, вы можете по своему переделать.
I don’t know about this system specifically, but when generating a request signature, the order of the arguments is usually important (in alphabetical order).
In addition, a 400 error may be due to the fact that the request is sent by the wrong method (GET instead of POST)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question