views:

46

answers:

2

I had to take over a project where someone quit and need help understanding about how a type of gateway might work. It would be easy if I knew what gateway was used, but unfortunately we are unaware of what the plan was.

Can someone help me figure out how this actually communicates with a gateway? It seems to me like the code is sending itself the request?? Does this mean that the server is configured to handle the gateway request? With other gateways, like paypal, I'm used to just sending an HTTP request to their servers directly.

Are there types of gateways that reside on the host machine? Really confused here.

$payClientIP = "127.0.0.1";
$payClientPort = "9050";
$payClientSocket = -1;
$payClientTimeout = 5;

$payClientSocket = fsockopen($payClientIP, $payClientPort, $errno, $errstr, $payClientTimeout);        

function sendCommand($payClientSocket, $command) {

            global $payClientTimeout;
            socket_set_timeout($payClientSocket, $payClientTimeout);

            $buf = $command . "\n";
            $response = fputs($payClientSocket, $buf) == strlen($buf);    


        }

 sendCommand($payClientSocket, "7,CardSecurityCode,$cscValue");
 sendCommand($payClientSocket, "7,CardNum,$cardNumber");
 sendCommand($payClientSocket, "7,CardExp,$cardExpiry");
 sendCommand($payClientSocket,"6,$orderInfo,$merchantID,$amount,$locale");

What I'm trying to locate is the command to physically send the request, but I cannot find one. The code actually works and debits the card.

+1  A: 

Something's running on port 9050 on your local machine. It'd be hard to figure out what that is doing with just the information you've provided. It could be a gateway, or it could just be some sort of logging proxy that's passing the request onto a remote gateway somewhere.

ceejayoz
+1  A: 

You should probably check for a service application running with a listener on the local machine that's actually doing the real work behind the scenes. There was a particular application that my team worked with once that required a similar setup, and we introduced a web service that turned around and fired the credit info to the vendor's service.

However, I wouldn't see the advantage of this setup in the case of the service being hosted on the same machine as the calling web page.

md5sum