Skip to content

Commit 4c7d4e5

Browse files
authored
Merge pull request #20 from lukeholder/patch-1
Redirect response should not return `isSuccessful == true`
2 parents c26abba + bfa642b commit 4c7d4e5

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/Message/RestPurchaseResponse.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* MultiSafepay Rest Api Purchase Response.
44
*/
5+
56
namespace Omnipay\MultiSafepay\Message;
67

78
use Omnipay\Common\Message\RedirectResponseInterface;
@@ -88,6 +89,20 @@
8889
*/
8990
class RestPurchaseResponse extends RestAbstractResponse implements RedirectResponseInterface
9091
{
92+
/**
93+
* Is the response successful?
94+
*
95+
* @return bool
96+
*/
97+
public function isSuccessful()
98+
{
99+
if ($this->isRedirect()) {
100+
return false;
101+
}
102+
103+
return parent::isSuccessful();
104+
}
105+
91106
/**
92107
* {@inheritdoc}
93108
*/
@@ -101,8 +116,8 @@ public function isRedirect()
101116
*/
102117
public function getRedirectUrl()
103118
{
104-
if (! $this->isRedirect()) {
105-
return null;
119+
if (!$this->isRedirect()) {
120+
return;
106121
}
107122

108123
return $this->data['data']['payment_url'];
@@ -121,6 +136,6 @@ public function getRedirectMethod()
121136
*/
122137
public function getRedirectData()
123138
{
124-
return null;
139+
return;
125140
}
126141
}

tests/Message/RestPurchaseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testSendSuccess()
4646

4747
$response = $this->request->send();
4848

49-
$this->assertTrue($response->isSuccessful());
49+
$this->assertFalse($response->isSuccessful());
5050
$this->assertTrue($response->isRedirect());
5151

5252
$this->assertEquals(

0 commit comments

Comments
 (0)