From 82e0a83716fa70181c8c2520993a65fc7b9eb1ad Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Wed, 2 Dec 2015 12:14:01 +1300 Subject: [PATCH] Added getDetailsArray() to return the response XML as array --- src/Message/Response.php | 16 +++++++++++++++- tests/Message/ResponseTest.php | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Message/Response.php b/src/Message/Response.php index 24c017d..87b4b5f 100644 --- a/src/Message/Response.php +++ b/src/Message/Response.php @@ -14,6 +14,7 @@ class Response extends AbstractResponse private $cardReference; private $message; private $responsexml; /* Response XML from Gateway */ + private $details; /** @@ -28,7 +29,7 @@ public function __construct($request, $data) $this->response = $data; $this->processResponse($this->response); } - + /** * * Process the response @@ -141,4 +142,17 @@ public function getCardReference() ? $this->cardReference : null; } + /** + * + * Return the transaction details as (array) from the gateway + * + * @returns array $this->responsexml + */ + public function getDetailsArray() + { + + return isset($this->responsexml) + ? $this->responsexml + : null; + } } diff --git a/tests/Message/ResponseTest.php b/tests/Message/ResponseTest.php index 2d409c2..f76e89b 100644 --- a/tests/Message/ResponseTest.php +++ b/tests/Message/ResponseTest.php @@ -38,6 +38,8 @@ public function testPurchaseSuccess() $this->assertTrue($response->isSuccessful()); $this->assertEquals('P1511W0005042864', $response->getTransactionId()); $this->assertEquals('Transaction Successful', $response->getMessage()); + $txnDetails = $response->getDetailsArray(); + $this->assertEquals('Transaction Successful', $txnDetails['Message']); } public function testPurchaseByTokenSuccess()