Payment agents Automation in Javascript and PHP

Am in need of a script that can initiate paymentagent_transfer on a button click in either Javascript or PHP or Both.
So far the code below is what I have, Help make it perfect.

  <script type = "text/javascript">
     function WebSocketTest() {

        if ("WebSocket" in window) {
           alert("WebSocket is supported by your Browser!");

           // Let us open a web socket
           var ws = new WebSocket("wss://");

           ws.onopen = function() {
              // Web Socket is connected, send data using send()
              //Authorize request
              ws.send(JSON.stringify({ "authorize": "--Token---" }));
              alert("Message is sent...");

           ws.onmessage = function (evt) { 
              var received_msg =;
              var data = JSON.parse(received_msg);
              alert("Message is received..." + received_msg);

              //Initiate payment Transfer
                   "paymentagent_transfer": 1,
                   "amount": 100,
                   "currency": "USD",
                   "transfer_to": "-----CRXXXXXXX----"

              alert("Message is sent...");


           ws.onclose = function() { 

              // websocket is closed.
              alert("Connection is closed..."); 
        } else {

           // The browser doesn't support WebSocket
           alert("WebSocket NOT supported by your Browser!");


Sign In or Register to comment.