Skip to content

Commit

Permalink
Issue #12 support getTransactionId in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Feb 16, 2019
1 parent db8b136 commit 0be233f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
9 changes: 0 additions & 9 deletions src/Message/Checkout/Page/CompleteResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
11 changes: 11 additions & 0 deletions src/Message/HandlesNotificationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*
*/

use Omnipay\Wirecard\Message\Checkout\AbstractRequest as MessageAbstractRequest;

trait HandlesNotificationTrait
{
/**
Expand Down Expand Up @@ -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.
*
Expand Down
8 changes: 4 additions & 4 deletions tests/Message/NotificationServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 0be233f

Please sign in to comment.