diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 4ce6e4a..529f7c6 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -26,7 +26,7 @@ protected function sendRequest($method, $endpoint, $data = null) */ $response = $event['response']; - if ($response->isClientError()) { + if ($response->isError()) { $event->stopPropagation(); } }); diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index f659c9c..7a980d1 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -79,4 +79,32 @@ public function testSendFailure() $this->assertNull($response->getRedirectData()); $this->assertSame("The issuer is invalid", $response->getMessage()); } + + public function testIssuerFailure() + { + $this->setMockHttpResponse('PurchaseIssuerFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\Mollie\Message\PurchaseResponse', $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertNull($response->getRedirectUrl()); + $this->assertNull($response->getRedirectData()); + $this->assertSame("Issuer failure", $response->getMessage()); + } + + public function testSystemFailure() + { + $this->setMockHttpResponse('PurchaseSystemFailure.txt'); + $response = $this->request->send(); + + $this->assertInstanceOf('Omnipay\Mollie\Message\PurchaseResponse', $response); + $this->assertFalse($response->isSuccessful()); + $this->assertFalse($response->isRedirect()); + $this->assertNull($response->getTransactionReference()); + $this->assertNull($response->getRedirectUrl()); + $this->assertNull($response->getRedirectData()); + $this->assertSame("Payment platform for this payment method temporarily not available", $response->getMessage()); + } } diff --git a/tests/Mock/PurchaseIssuerFailure.txt b/tests/Mock/PurchaseIssuerFailure.txt new file mode 100644 index 0000000..4c34eeb --- /dev/null +++ b/tests/Mock/PurchaseIssuerFailure.txt @@ -0,0 +1,19 @@ +HTTP/1.1 503 Service Temporarily Unavailable +Server: nginx/1.4.4 +Date: Mon, 20 Jan 2014 10:19:39 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error":{ + "type":"system", + "message":"Issuer failure", + "field":"issuer" + } +} diff --git a/tests/Mock/PurchaseSystemFailure.txt b/tests/Mock/PurchaseSystemFailure.txt new file mode 100644 index 0000000..3de75a8 --- /dev/null +++ b/tests/Mock/PurchaseSystemFailure.txt @@ -0,0 +1,18 @@ +HTTP/1.1 503 Service Temporarily Unavailable +Server: nginx/1.4.4 +Date: Mon, 20 Jan 2014 10:19:39 GMT +Content-Type: application/json; charset=utf-8 +Content-Length: 101 +Connection: keep-alive +Access-Control-Allow-Credentials: true +Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS, DELETE +Access-Control-Max-Age: 300 +Cache-Control: no-cache, no-store +Strict-Transport-Security: max-age=31556926; includeSubDomains + +{ + "error":{ + "type":"system", + "message":"Payment platform for this payment method temporarily not available" + } +}