The WalletOne service after successful payment makes a POST request to the specified url and sends the payment data. I need, after payment, to be able to call Javascript code (to add information to Yandex Metrics e-commerce), but it doesn’t work with a PHP request.

Is it possible somehow with PHP to send a request to JS and wait for a response?

Thanks in advance.

    1 answer 1

    Your code for Yandex metrics is most likely to be executed on the client (in the user's browser). And PHP is executed on the server. You can spit js-script into the user's browser as an answer, which will be executed by the browser, if the action does not require one hundred percent reliability. If you need to send a request to the metric directly at the time of payment on the server - in the end, the js-code of the metric sends some request to the Yandex server. You can dig out the API and try to execute the same query with CURL.

    PS Answering directly to your question: you can call the JS code from the PHP code and wait until it is executed. To do this, you need a server compiler for JS - Node, but the Yandex.metric code is not written for it and most likely it will not work. And in general, you do not need it.

    • Thanks for the answer. I tried to try through the API, there you can add counters, targets, etc., but the goods seem impossible. - Miqayel