0

We have a PHP checkout script, which posts information to a third-party payment gateway using XML.

The problem is, we used to POST using regular port 80, but they have now changed URLs and are now SSL.

We can post the data no problem to their server, the problem is loading and checking this information back into our database.

After the XML vars definition, we have:

if (((int)$_SESSION['value_dollars']+(int)$_SESSION['value_cents']) != 0){
$response = openSocket($host, $vars);

$xmlres = array();
$xmlres = makeXMLTree ($response);

if (trim($xmlres[SecurePayMessage][Payment][TxnList][Txn][approved]) == 'Yes'){

The problem is that it does not seem to load any $xmlres into the system, so when we check for approved = yes, it always reverts to the error page.

Since they have changed to SSL etc how can we rewrite this section to be accurate?

Palemo
  • 217
  • 1
  • 5
  • 19
  • This could help: http://stackoverflow.com/questions/1757957/how-do-i-get-ssl-working-in-fsockopen – René Höhle Apr 26 '13 at 08:23
  • I did see that. Given that I could use: if ( $fp = fsockopen('ssl://' . $host, 443, $errno, $errstr, 30) ) for example, not sure how we can rewrite the above re xmlres – Palemo Apr 26 '13 at 08:26

1 Answers1

0

Have you checked your php.ini to check if SSL is enabled?

Sometimes unix systems are installed without SSL support for PHP and you must email your webmaster and ask them to change the php configuration, unless you are able to do this on your own.

try placing the folliwong code in a new file called phpinfo.php and visit it on your website. Make sure there is a part that says that SSL is enabled on your webserver!

<?php
    phpinfo(INFO_MODULES);
?>
Dom
  • 7,135
  • 1
  • 11
  • 13
  • It is indeed enabled, by what we can see. We have no problem sending the data via SSL to the payment gateway, it is just checking on the XML that comes back re approval etc – Palemo Apr 26 '13 at 08:29
  • Would the function `openSocket()` be a custom one? Might be useful to see what it consists of.. – Dom Apr 26 '13 at 08:31
  • function openSocket($host,$query){ // Break the URL into usable parts $path = explode('/',$host); $host = $path[0]; unset($path[0]); $path = '/'.(implode('/',$path)); – Palemo Apr 26 '13 at 08:33
  • Do you use `fsockopen()` at all in your function? As you might need to define the port as 443. – Dom Apr 26 '13 at 08:35
  • I do - am basically using the script from: http://www.daniweb.com/web-development/php/threads/185031/php-to-read-xml-and-write-into-mysql- – Palemo Apr 26 '13 at 08:39
  • Yeah, not a fan of copy/pasted code, but anyways - try changing `$h = fsockopen("ssl://".$host, 443, $errno, $errstr);` to `$h = fsockopen("https://".$host, 443, $errno, $errstr);`? Also, are you getting an error message of some sort as it looks like that script has some sort of error return. – Dom Apr 26 '13 at 08:43
  • Changing to https:// returns with a server error. I need to use the ssl:// Always getting an error (on our site) whether the payment gateway returns success or error - so if (trim($xmlres[SecurePayMessage][Payment][TxnList][Txn][approved]) == 'Yes') never seems to be true – Palemo Apr 26 '13 at 08:45
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/28958/discussion-between-dom-and-palemo) – Dom Apr 26 '13 at 08:46