From 1f98ef36521eda06c16228730c5ea11941b48d4d Mon Sep 17 00:00:00 2001 From: Jurian Sluiman Date: Thu, 29 Aug 2013 09:20:51 +0200 Subject: [PATCH] Add consumer and transaction info only for success The tags consumerName, consumerIBAN, consumerBIC, amount, currency are only enabled in the status response when the status is success. Check the status prior to setting this information in the model. --- src/SlmIdealPayment/Client/StandardClient.php | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/SlmIdealPayment/Client/StandardClient.php b/src/SlmIdealPayment/Client/StandardClient.php index 8d9c98a..2b4f31f 100644 --- a/src/SlmIdealPayment/Client/StandardClient.php +++ b/src/SlmIdealPayment/Client/StandardClient.php @@ -187,19 +187,25 @@ public function sendStatusRequest(Request\StatusRequest $request) throw new Exception\IdealRequestException('Expecting AcquirerStatusRes as root element in response'); } + $status = $this->getTag($response, 'status'); $transaction = new Model\Transaction(); $transaction->setTransactionId($this->getTag($response, 'transactionID')); - $transaction->setStatus($this->getTag($response, 'status')); - // @todo add statusDateTimestamp + $transaction->setStatus($status); - $consumer = new Model\Consumer(); - $consumer->setName($this->getTag($response, 'consumerName')); - $consumer->setAccountIBAN($this->getTag($response, 'consumerIBAN')); - $consumer->setAccountBIC($this->getTag($response, 'consumerBIC')); + if ($status !== Model\Transaction::STATUS_OPEN) { + // @todo add statusDateTimestamp + } + + if ($status === Model\Transaction::STATUS_SUCCESS) { + $consumer = new Model\Consumer(); + $consumer->setName($this->getTag($response, 'consumerName')); + $consumer->setAccountIBAN($this->getTag($response, 'consumerIBAN')); + $consumer->setAccountBIC($this->getTag($response, 'consumerBIC')); - $transaction->setAmount($this->getTag($response, 'amount')); - $transaction->setCurrency($this->getTag($response, 'currency')); - $transaction->setConsumer($consumer); + $transaction->setAmount($this->getTag($response, 'amount')); + $transaction->setCurrency($this->getTag($response, 'currency')); + $transaction->setConsumer($consumer); + } $response = new Response\TransactionResponse(); $response->setTransaction($transaction);