Skip to content

Commit

Permalink
Merge pull request #125 from academe/master
Browse files Browse the repository at this point in the history
Support isSuccessful() in acceptNotification
  • Loading branch information
judgej committed Dec 12, 2018
2 parents a60ee72 + bf55748 commit 97fd7e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/Message/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ class Response extends AbstractResponse implements RedirectResponseInterface, Co
{
use ResponseFieldsTrait;

/**
* @return bool True if the transaction is successful and complete.
*/
public function isSuccessful()
{
return $this->getStatus() === static::SAGEPAY_STATUS_OK
|| $this->getStatus() === static::SAGEPAY_STATUS_OK_REPEATED
|| $this->getStatus() === static::SAGEPAY_STATUS_REGISTERED
|| $this->getStatus() === static::SAGEPAY_STATUS_AUTHENTICATED;
}

/**
* Gateway Reference
*
Expand Down
11 changes: 11 additions & 0 deletions src/Traits/ResponseFieldsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ protected function getDataItem($name, $default = null)
return isset($this->data[$name]) ? $this->data[$name] : $default;
}

/**
* @return bool True if the transaction is successful and complete.
*/
public function isSuccessful()
{
return $this->getStatus() === static::SAGEPAY_STATUS_OK
|| $this->getStatus() === static::SAGEPAY_STATUS_OK_REPEATED
|| $this->getStatus() === static::SAGEPAY_STATUS_REGISTERED
|| $this->getStatus() === static::SAGEPAY_STATUS_AUTHENTICATED;
}

/**
* Get the cardReference generated when creating a card reference
* during an authorisation or payment, or as an explicit request.
Expand Down
6 changes: 6 additions & 0 deletions tests/Message/ServerNotifyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public function testServerNotifyResponseSuccess()
"Status=OK\r\nRedirectUrl=https://www.example.com/\r\nStatusDetail=detail"
);
$this->request->confirm('https://www.example.com/', 'detail');

// Issue https://github.com/thephpleague/omnipay-sagepay/issues/124
// The isSuccessful() method is moved to the trait that shares many
// common response fields with the notification server request.

$this->assertTrue($this->request->isSuccessful());
}

public function testServerNotifyRequestFailure()
Expand Down

0 comments on commit 97fd7e4

Please sign in to comment.