From 0be233fde969e7768332e7fcb81b3559c62c862a Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Sat, 16 Feb 2019 17:18:45 +0000 Subject: [PATCH] Issue #12 support getTransactionId in notification --- src/Message/Checkout/Page/CompleteResponse.php | 9 --------- src/Message/HandlesNotificationTrait.php | 11 +++++++++++ tests/Message/NotificationServerTest.php | 8 ++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Message/Checkout/Page/CompleteResponse.php b/src/Message/Checkout/Page/CompleteResponse.php index 37fd4f3..3cfcc5a 100644 --- a/src/Message/Checkout/Page/CompleteResponse.php +++ b/src/Message/Checkout/Page/CompleteResponse.php @@ -62,15 +62,6 @@ public function getOriginalTransactionId() return $this->originalTransactionId; } - /** - * We put the transaction ID into a custom field, which will be passed - * through by the gateway to the notification data. - */ - public function getTransactionId() - { - return $this->getDataValue(AbstractRequest::CUSTOM_FIELD_NAME_TRANSACTION_ID); - } - /** * @inherit */ diff --git a/src/Message/HandlesNotificationTrait.php b/src/Message/HandlesNotificationTrait.php index fdeafad..28f83e5 100644 --- a/src/Message/HandlesNotificationTrait.php +++ b/src/Message/HandlesNotificationTrait.php @@ -6,6 +6,8 @@ * */ +use Omnipay\Wirecard\Message\Checkout\AbstractRequest as MessageAbstractRequest; + trait HandlesNotificationTrait { /** @@ -295,6 +297,15 @@ public function getCode() return null; } + /** + * We put the transaction ID into a custom field, which will be passed + * through by the gateway to the notification data. + */ + public function getTransactionId() + { + return $this->getDataValue(MessageAbstractRequest::CUSTOM_FIELD_NAME_TRANSACTION_ID); + } + /** * Checks if the expected transactionId is in the gateway request or response. * diff --git a/tests/Message/NotificationServerTest.php b/tests/Message/NotificationServerTest.php index 22322fb..9be813b 100644 --- a/tests/Message/NotificationServerTest.php +++ b/tests/Message/NotificationServerTest.php @@ -50,12 +50,12 @@ public function testSuccesful() // This secret is needed to validate the transaction. $request->setSecret('DP4TMTPQQWFJW34647RM798E9A5X7E8ATP462Z4VGZK53YEJ3JWXS98B9P4F'); - $request->setTransactionId('WC92281976'); + // Will be successful and valid even without an expected transactionId set + // since this is an unsolicited notification and not a complete* message. - //$response = $request->send(); - - //var_dump($response->getMessage()); $this->assertTrue($request->isValid()); $this->assertTrue($request->isSuccessful()); + + $this->assertSame('WC92281976', $request->getTransactionId()); } }