V
V
vlog2021-12-24 21:01:05
API
vlog, 2021-12-24 21:01:05

Why does the VKPay button in the bot not work?

The essence of the problem itself is that it is not possible to send money to a group through a button like vkpay. If I just send it through attachments, then everything will work out.
Through the button on the computer, a payment window opens, a pin code is requested, and then the message "Unable to complete the operation. Please try again later." When you click on the button from mobile devices, an endless download occurs.

In the request, the array with buttons looks like this:

array('keyboard' => json_encode(array(
            'one_time' => true,
            'buttons' => [array (
                [
                    'action' => array(
                        'type' => 'vkpay',
                        'hash' => "action=pay-to-group&amount{$summ}&description=Тема&group_id=2097****9&aid=2097****9",
                    ),
                ]
            ),
                array(
                    [
                        'action' => array(
                            'type' => 'callback',
                            'label' => ' Позвать оператора',
                            'payload' => "{\"button\": \"confirm\"}",
                        ),
                        'color' => 'secondary',

                    ]
                ),
                array(
                    [
                        'action' => array(
                            'type' => 'callback',
                            'label' => ' Списать '.$bonus.' бонусов',
                            'payload' => "{\"button\": \"bonus\", \"ord\": \"".$id."\"}",
                        ),
                        'color' => 'positive',

                    ]
                ),
            ],
        ), JSON_UNESCAPED_UNICODE))


What we managed to find out:
  1. If I paste the hash directly into the browser in the form https://vk.com/vkpay#{hash}then it will take me to the payment form which will work
  2. In the payment form, which opens at the click of a button, the comment looks like this: ?4??4??4??6?. Perhaps the encoding is just the reason why the form does not work. But I don't know how to fix it... There were no such problems with other queries.
  3. This is how the request looks like when the payment window is opened through the button:
    https://vk.com/im?sel=-2097****9&w=app6217559_-0%2523action%253Dpay-to-group%2526amount%253D12%2526description%253D%25253F4%25253F%25253F4%25253F%25253F4%25253F%25253F6%25253F%2526group_id%253D2097****9%2526aid%253D2097****9



Sending via PHP SDK VKontakte.

API documentation links:
Keyboard
hash parameters

Please help. I can’t understand at what stage something goes wrong... Probably the problem is not on the VKPay side, but everything is in order in the array with buttons itself, since it opens when directly inserted through the browser.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vlog, 2022-02-13
@vlog

The button did not work due to an error on the VK side. Wrote in support, corrected after a while.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question