-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding getters to Response object, Adding request send/faulre tests f…
…or authorize, purchase, adding tests for Response.
- Loading branch information
Showing
8 changed files
with
295 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Omnipay\Beanstream\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class ResponseTest extends TestCase | ||
{ | ||
public function testPurchaseSuccess() | ||
{ | ||
$httpResponse = $this->getMockHttpResponse('PurchaseSuccess.txt'); | ||
$response = new Response($this->getMockRequest(), $httpResponse->json()); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame('1000001', $response->getTransactionReference()); | ||
$this->assertSame('1', $response->getOrderNumber()); | ||
$this->assertSame('Approved', $response->getMessage()); | ||
$this->assertSame('1', $response->getMessageId()); | ||
$this->assertSame('TEST', $response->getAuthCode()); | ||
$this->assertSame('P', $response->getType()); | ||
$this->assertNull($response->getCode()); | ||
$responseCard = $response->getCard(); | ||
$this->assertNotEmpty($responseCard); | ||
$this->assertSame('VI', $responseCard['card_type']); | ||
$this->assertSame('1234', $responseCard['last_four']); | ||
$this->assertSame(0, $responseCard['cvd_match']); | ||
$this->assertSame(0, $responseCard['address_match']); | ||
$this->assertSame(0, $responseCard['postal_result']); | ||
} | ||
|
||
public function testPurchaseFailure() | ||
{ | ||
$httpResponse = $this->getMockHttpResponse('PurchaseFailure.txt'); | ||
$response = new Response($this->getMockRequest(), $httpResponse->json()); | ||
$this->assertSame(49, $response->getCode()); | ||
$this->assertSame(3, $response->getCategory()); | ||
$this->assertSame('Invalid transaction request string', $response->getMessage()); | ||
$this->assertSame('https://www.beanstream.com/docs/errors#49', $response->getReference()); | ||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertNull($response->getTransactionReference()); | ||
$this->assertNull($response->getOrderNumber()); | ||
$this->assertNull($response->getType()); | ||
$this->assertNull($response->getMessageId()); | ||
$this->assertNull($response->getAuthCode()); | ||
$responseCard = $response->getCard(); | ||
$this->assertEmpty($responseCard); | ||
} | ||
|
||
public function testAuthorizeSuccess() | ||
{ | ||
$httpResponse = $this->getMockHttpResponse('AuthorizeSuccess.txt'); | ||
$response = new Response($this->getMockRequest(), $httpResponse->json()); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame('1000001', $response->getTransactionReference()); | ||
$this->assertSame('1', $response->getOrderNumber()); | ||
$this->assertSame('Approved', $response->getMessage()); | ||
$this->assertSame('1', $response->getMessageId()); | ||
$this->assertSame('TEST', $response->getAuthCode()); | ||
$this->assertSame('PA', $response->getType()); | ||
$this->assertNull($response->getCode()); | ||
$responseCard = $response->getCard(); | ||
$this->assertNotEmpty($responseCard); | ||
$this->assertSame('VI', $responseCard['card_type']); | ||
$this->assertSame('1234', $responseCard['last_four']); | ||
$this->assertSame(0, $responseCard['cvd_match']); | ||
$this->assertSame(0, $responseCard['address_match']); | ||
$this->assertSame(0, $responseCard['postal_result']); | ||
} | ||
|
||
public function testAuthorizeFailure() | ||
{ | ||
$httpResponse = $this->getMockHttpResponse('AuthorizeFailure.txt'); | ||
$response = new Response($this->getMockRequest(), $httpResponse->json()); | ||
$this->assertSame(49, $response->getCode()); | ||
$this->assertSame(3, $response->getCategory()); | ||
$this->assertSame('Invalid transaction request string', $response->getMessage()); | ||
$this->assertSame('https://www.beanstream.com/docs/errors#49', $response->getReference()); | ||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertNull($response->getTransactionReference()); | ||
$this->assertNull($response->getOrderNumber()); | ||
$this->assertNull($response->getType()); | ||
$this->assertNull($response->getMessageId()); | ||
$this->assertNull($response->getAuthCode()); | ||
$responseCard = $response->getCard(); | ||
$this->assertEmpty($responseCard); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"code":49, | ||
"category":3, | ||
"message":"Invalid transaction request string", | ||
"reference":"https://www.beanstream.com/docs/errors#49" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
HTTP/1.1 200 OK | ||
Access-Control-Allow-Headers: accept, origin, content-type | ||
Access-Control-Allow-Origin: * | ||
Cache-Control: no-cache | ||
Content-Length: 477 | ||
Content-Type: application/json; charset=utf-8 | ||
Date: Thu, 24 Mar 2016 18:04:30 GMT | ||
Expires: -1 | ||
Pragma: no-cache | ||
Server: Microsoft-IIS/8.5 | ||
X-AspNet-Version: 4.0.30319 | ||
X-Powered-By: ASP.NET | ||
|
||
{ | ||
"id": "1000001", | ||
"approved": "1", | ||
"message_id": "1", | ||
"message": "Approved", | ||
"auth_code": "TEST", | ||
"created": "2016-03-24T11:04:30", | ||
"order_number": "1", | ||
"type": "PA", | ||
"payment_method": "CC", | ||
"card": { | ||
"card_type": "VI", | ||
"last_four": "1234", | ||
"cvd_match": 0, | ||
"address_match": 0, | ||
"postal_result": 0 | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "complete", | ||
"href": "https://www.beanstream.com/api/v1/payments/1000001/completions", | ||
"method": "POST" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
HTTP/1.1 400 Bad Request | ||
Content-Type: application/json | ||
|
||
{ | ||
"code":49, | ||
"category":3, | ||
"message":"Invalid transaction request string", | ||
"reference":"https://www.beanstream.com/docs/errors#49" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
HTTP/1.1 200 OK | ||
Access-Control-Allow-Headers: accept, origin, content-type | ||
Access-Control-Allow-Origin: * | ||
Cache-Control: no-cache | ||
Content-Length: 477 | ||
Content-Type: application/json; charset=utf-8 | ||
Date: Thu, 24 Mar 2016 18:04:30 GMT | ||
Expires: -1 | ||
Pragma: no-cache | ||
Server: Microsoft-IIS/8.5 | ||
X-AspNet-Version: 4.0.30319 | ||
X-Powered-By: ASP.NET | ||
|
||
{ | ||
"id": "1000001", | ||
"approved": "1", | ||
"message_id": "1", | ||
"message": "Approved", | ||
"auth_code": "TEST", | ||
"created": "2016-03-24T11:04:30", | ||
"order_number": "1", | ||
"type": "P", | ||
"payment_method": "CC", | ||
"card": { | ||
"card_type": "VI", | ||
"last_four": "1234", | ||
"cvd_match": 0, | ||
"address_match": 0, | ||
"postal_result": 0 | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "void", | ||
"href": "https://www.beanstream.com/api/v1/payments/1000001/void", | ||
"method": "POST" | ||
}, | ||
{ | ||
"rel": "return", | ||
"href": "https://www.beanstream.com/api/v1/payments/1000001/returns", | ||
"method": "POST" | ||
} | ||
] | ||
} |