The translation was generated automatically and may contain mistakes

How to create an application signature

This section is intended for developers who have already connected VK Pay.

If you want to connect and start accepting payments through VK Pay, write to vkpay_solutions@vk.team .

More about the service - in the section About VK Pay .

Subscribe to Apps sign is passed as a parameter in a JSON object params and ensures that the payment form parameters have not been changed on the client side.

sign is an MD5 hash from string concatenation with payment form and secure key parameters app secure key which is unique to each application.

You can find the protected application key in the settings of your applications :

  1. 1.
    Press on Settings in front of your mini-app.
  2. 2.
    In the section Development choose Access keys .
  3. 3.
    In the field The Protected Key The importance is app secure key . To see the value of the key, press Show me and confirm the action with a push message or SMS on your mobile device.

Important! In order not to compromise the private key, you need to form an application signature on the side of the backend of your application.

To form the app’s signature:

  1. 1.
  2. 2.
  3. 3.

Step 1. Collect the JSON string from the payment form parameters

A JSON parameter string is a pair concatenation "параметр":"значение" .

At the same time, the following rules must be observed:

  1. 1.
    Names of parameters in params should be sorted alphabetically, including the parameter names inside the JSON object data . If data It contains a field cashback , the fields inside that object must also be sorted alphabetically.
  2. 2.
    From the line, we need to delete the parameter action .
  3. 3.
    String values must be passed without quotation marks.

Example of a JSON parameter string for signing an application

'''JSON amount=1.5data={"currency":"RUB","merchant_data":"eyJvcmRlcl9pZCI6IjI1NTMxIiwidHMiOiIxNTM5MzI5NzcwIiwiYW1vdW50IjoxLjUsImN1cnJlbmN5IjoiUlVCIn0=","merchant_sign":"63d5dce9d2c9d29198ba12ba3f8e270e6606a221","order_id":"25531","ts":"1539329770"}description=Test Paymentmerchant_id=617001version=2

:::note **?1?’ажно!** Скорее всего, вам не нужно реализовывать свой алгоритм сериализации для canonical JSON. Для многи?1?… языков уже есть соответствующие инструменты. ::: ## Шаг 2. Сконкатенируйте полученную строку с защищённым ключом вашего приложения `app secure key` ?1?’ примере `app secure key` = `2ug3CQvCkfRyI6svLVpC`. **Пример конкатенации JSON-строки и защищённого ключа** ```JSON amount=1.5data={"currency":"RUB","merchant_data":"eyJvcmRlcl9pZCI6IjI1NTMxIiwidHMiOiIxNTM5MzI5NzcwIiwiYW1vdW50IjoxLjUsImN1cnJlbmN5IjoiUlVCIn0=","merchant_sign":"63d5dce9d2c9d29198ba12ba3f8e270e6606a221","order_id":"25531","ts":"1539329770"}description=Test Paymentmerchant_id=617001version=2ug3CQvCkfRyI6svLVpC

Step 3. Encode the result of concatenation using the MD5 hash algorithm

818964335a550e39d9a1dd0d752e60ab

Done! Use the received value in sending a Request in the parameter params.sign Among others payment window parameters .