E
E
Elizaveta Cezurk2020-12-21 21:42:51
PHP
Elizaveta Cezurk, 2020-12-21 21:42:51

How to connect unitpay widget?

Good evening, I wanted to try unitpay as a payment system on the site.
I took everything from the site, signature generation

function getFormSignature($account, $currency, $desc, $sum, $secretKey) {
    $hashStr = $account.'{up}'.$currency.'{up}'.$desc.'{up}'.$sum.'{up}'.$secretKey;
    return hash('sha256', $hashStr);
}

I insert it into js in this way
<script type="text/javascript">
  this.pay = function() {
      var payment = new UnitPay();
      payment.createWidget({
        publicKey: "А тут публичный ключ",
        sum: 1,
        account: "demo",
        domainName: "unitpay.money",
        signature: "<?=getFormSignature(2, 'RUB', 'Пробник', 1, 'Ну тут мой ключ приватный'); ?>",
        desc: "Описание платежа",
        locale: "ru",
      });
      payment.success(function (params) {
        console.log('Успешный платеж');
      });
      payment.error(function (message, params) {
        console.log(message);
      });
      return false;
  };
</script>

Generated, everything is fine
But when I try to pay for the service, I get the error "Request signature is not correct"...
I don't know where I'm wrong, if someone has encountered such a problem and knows how to solve it, please help me
Thank you in advance! :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
T3R3AND, 2020-12-22
@semechki

There is a good lib on the git, use: unitpay/php-sdk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question