Skip to content

Redirect response should not return isSuccessful == true #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/Message/RestPurchaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* MultiSafepay Rest Api Purchase Response.
*/

namespace Omnipay\MultiSafepay\Message;

use Omnipay\Common\Message\RedirectResponseInterface;
Expand Down Expand Up @@ -88,6 +89,20 @@
*/
class RestPurchaseResponse extends RestAbstractResponse implements RedirectResponseInterface
{
/**
* Is the response successful?
*
* @return bool
*/
public function isSuccessful()
{
if ($this->isRedirect()) {
return false;
}

return parent::isSuccessful();
}

/**
* {@inheritdoc}
*/
Expand All @@ -101,8 +116,8 @@ public function isRedirect()
*/
public function getRedirectUrl()
{
if (! $this->isRedirect()) {
return null;
if (!$this->isRedirect()) {
return;
}

return $this->data['data']['payment_url'];
Expand All @@ -121,6 +136,6 @@ public function getRedirectMethod()
*/
public function getRedirectData()
{
return null;
return;
}
}
2 changes: 1 addition & 1 deletion tests/Message/RestPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testSendSuccess()

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

$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isSuccessful());
$this->assertTrue($response->isRedirect());

$this->assertEquals(
Expand Down