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.