Commit 460f3c6c authored by David Weston's avatar David Weston

okay, this is now safer

parent 24069bf0
...@@ -87,7 +87,7 @@ class RequestHandler ...@@ -87,7 +87,7 @@ class RequestHandler
curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request->getRequestXML()); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request->getRequestXML($method));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
...@@ -96,9 +96,6 @@ class RequestHandler ...@@ -96,9 +96,6 @@ class RequestHandler
curl_close($ch); curl_close($ch);
if($status) return new Response($output);
return new Response($request, $output);
return false;
} }
} }
\ No newline at end of file
...@@ -11,9 +11,10 @@ namespace OUTRAGElib\Payment\STPP; ...@@ -11,9 +11,10 @@ namespace OUTRAGElib\Payment\STPP;
use \OUTRAGElib\Payment\STPP\Request; use \OUTRAGElib\Payment\STPP\Request;
use \SimpleXMLElement; use \SimpleXMLElement;
use \Serializable;
class Response class Response implements Serializable
{ {
/** /**
* Store the XML response somewhere... * Store the XML response somewhere...
...@@ -21,34 +22,17 @@ class Response ...@@ -21,34 +22,17 @@ class Response
private $feed = null; private $feed = null;
/**
* The request?
*/
private $request = null;
/** /**
* Called when the response has been constructed. * Called when the response has been constructed.
*/ */
public function __construct(Request $request, $response) public function __construct($response)
{ {
$this->feed = simplexml_load_string($response); $this->feed = simplexml_load_string($response);
$this->request = $request;
return true; return true;
} }
/**
* Retrieves a cleansed version of the request - where this means
* all credit card information is removed.
*/
public function getRequest()
{
return $this->request;
}
/** /**
* Retrieves the XML object that was sent back from SecureTrading. * Retrieves the XML object that was sent back from SecureTrading.
*/ */
...@@ -144,4 +128,31 @@ class Response ...@@ -144,4 +128,31 @@ class Response
return (integer) $this->feed->response->live === 1; return (integer) $this->feed->response->live === 1;
} }
/**
* Called to serialize an object
*/
public function serialize()
{
$vars = get_object_vars($this);
$vars["feed"] = $this->feed->asXML();
return serialize($vars);
}
/**
* Called to unserialize an object
*/
public function unserialize($input)
{
$vars = unserialize($input);
$vars["feed"] = simplexml_load_string($vars["feed"]);
foreach($vars as $key => $value)
$this->{$key} = $value;
return true;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment