Skip to content

Commit 97fd7e4

Browse files
authored
Merge pull request #125 from academe/master
Support isSuccessful() in acceptNotification
2 parents a60ee72 + bf55748 commit 97fd7e4

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/Message/Response.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ class Response extends AbstractResponse implements RedirectResponseInterface, Co
1515
{
1616
use ResponseFieldsTrait;
1717

18-
/**
19-
* @return bool True if the transaction is successful and complete.
20-
*/
21-
public function isSuccessful()
22-
{
23-
return $this->getStatus() === static::SAGEPAY_STATUS_OK
24-
|| $this->getStatus() === static::SAGEPAY_STATUS_OK_REPEATED
25-
|| $this->getStatus() === static::SAGEPAY_STATUS_REGISTERED
26-
|| $this->getStatus() === static::SAGEPAY_STATUS_AUTHENTICATED;
27-
}
28-
2918
/**
3019
* Gateway Reference
3120
*

src/Traits/ResponseFieldsTrait.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ protected function getDataItem($name, $default = null)
2323
return isset($this->data[$name]) ? $this->data[$name] : $default;
2424
}
2525

26+
/**
27+
* @return bool True if the transaction is successful and complete.
28+
*/
29+
public function isSuccessful()
30+
{
31+
return $this->getStatus() === static::SAGEPAY_STATUS_OK
32+
|| $this->getStatus() === static::SAGEPAY_STATUS_OK_REPEATED
33+
|| $this->getStatus() === static::SAGEPAY_STATUS_REGISTERED
34+
|| $this->getStatus() === static::SAGEPAY_STATUS_AUTHENTICATED;
35+
}
36+
2637
/**
2738
* Get the cardReference generated when creating a card reference
2839
* during an authorisation or payment, or as an explicit request.

tests/Message/ServerNotifyRequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ public function testServerNotifyResponseSuccess()
100100
"Status=OK\r\nRedirectUrl=https://www.example.com/\r\nStatusDetail=detail"
101101
);
102102
$this->request->confirm('https://www.example.com/', 'detail');
103+
104+
// Issue https://github.com/thephpleague/omnipay-sagepay/issues/124
105+
// The isSuccessful() method is moved to the trait that shares many
106+
// common response fields with the notification server request.
107+
108+
$this->assertTrue($this->request->isSuccessful());
103109
}
104110

105111
public function testServerNotifyRequestFailure()

0 commit comments

Comments
 (0)