-
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.
- Loading branch information
Showing
4 changed files
with
128 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Omnipay\CheckoutCom\Message; | ||
|
||
use Omnipay\Tests\TestCase; | ||
|
||
class CaptureRequestTest extends TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->request = new CaptureRequest($this->getHttpClient(), $this->getHttpRequest()); | ||
$this->request->setTransactionReference('foo'); | ||
} | ||
|
||
public function testEndpoint() | ||
{ | ||
$this->assertSame('https://api2.checkout.com/v2/charges/foo', $this->request->getEndpoint()); | ||
} | ||
|
||
public function testAmount() | ||
{ | ||
// defualt is no amount | ||
$this->assertArrayNotHasKey('amount', $this->request->getData()); | ||
|
||
$this->request->setAmount('10.00'); | ||
|
||
$data = $this->request->getData(); | ||
$this->assertSame(1000, $data['amount']); | ||
} | ||
|
||
public function testSendSuccess() | ||
{ | ||
$this->setMockHttpResponse('CaptureSuccess.txt'); | ||
$response = $this->request->send(); | ||
|
||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertSame('ch_1lvgjcQgrNWUuZ', $response->getTransactionReference()); | ||
$this->assertNull($response->getCardReference()); | ||
$this->assertNull($response->getMessage()); | ||
} | ||
|
||
public function testSendError() | ||
{ | ||
$this->setMockHttpResponse('CaptureFailure.txt'); | ||
$response = $this->request->send(); | ||
|
||
$this->assertFalse($response->isSuccessful()); | ||
$this->assertFalse($response->isRedirect()); | ||
$this->assertNull($response->getTransactionReference()); | ||
$this->assertNull($response->getCardReference()); | ||
$this->assertSame('Charge ch_1lvgjcQgrNWUuZ has already been captured.', $response->getMessage()); | ||
} | ||
} |
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,16 @@ | ||
HTTP/1.1 400 Bad Request | ||
Server: nginx | ||
Date: Sun, 05 May 2013 08:52:09 GMT | ||
Content-Type: application/json;charset=utf-8 | ||
Content-Length: 127 | ||
Connection: keep-alive | ||
Cache-Control: no-cache, no-store | ||
Access-Control-Max-Age: 300 | ||
Access-Control-Allow-Credentials: true | ||
|
||
{ | ||
"error": { | ||
"type": "invalid_request_error", | ||
"message": "Charge ch_1lvgjcQgrNWUuZ has already been captured." | ||
} | ||
} |
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,57 @@ | ||
HTTP/1.1 200 OK | ||
Server: nginx | ||
Date: Sun, 05 May 2013 08:51:15 GMT | ||
Content-Type: application/json;charset=utf-8 | ||
Content-Length: 997 | ||
Connection: keep-alive | ||
Cache-Control: no-cache, no-store | ||
Access-Control-Max-Age: 300 | ||
Access-Control-Allow-Credentials: true | ||
|
||
{ | ||
"id": "ch_1lvgjcQgrNWUuZ", | ||
"object": "charge", | ||
"created": 1367743707, | ||
"livemode": false, | ||
"paid": true, | ||
"amount": 1000, | ||
"currency": "usd", | ||
"refunded": false, | ||
"fee": 59, | ||
"fee_details": [ | ||
{ | ||
"amount": 59, | ||
"currency": "usd", | ||
"type": "stripe_fee", | ||
"description": "Stripe processing fees", | ||
"application": null, | ||
"amount_refunded": 0 | ||
} | ||
], | ||
"card": { | ||
"object": "card", | ||
"last4": "4242", | ||
"type": "Visa", | ||
"exp_month": 9, | ||
"exp_year": 2015, | ||
"fingerprint": "dfB0t0avO0bWr9eY", | ||
"country": "US", | ||
"name": "fdsa asdf", | ||
"address_line1": "", | ||
"address_line2": "", | ||
"address_city": "", | ||
"address_state": "", | ||
"address_zip": "", | ||
"address_country": "", | ||
"cvc_check": "pass", | ||
"address_line1_check": "pass", | ||
"address_zip_check": "pass" | ||
}, | ||
"captured": true, | ||
"failure_message": null, | ||
"amount_refunded": 0, | ||
"customer": null, | ||
"invoice": null, | ||
"description": "", | ||
"dispute": null | ||
} |