forked from thephpleague/omnipay-firstdata
/
PayeezyPurchaseResponseTest.php
58 lines (50 loc) · 2 KB
/
PayeezyPurchaseResponseTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Omnipay\FirstData\Message;
use Omnipay\Tests\TestCase;
use Omnipay\FirstData\Message\PayeezyPurchaseRequest;
class PayeezyPurchaseResponseTest extends TestCase
{
public function testPurchaseSuccess()
{
$response = new PayeezyResponse($this->getMockRequest(), json_encode(array(
'amount' => 1000,
'exact_resp_code' => 00,
'exact_message' => 'Transaction Normal',
'reference_no' => 'abc123',
'authorization_num' => 'auth1234',
'transaction_approved' => 1,
)));
$this->assertTrue($response->isSuccessful());
$this->assertEquals('auth1234::', $response->getTransactionReference());
$this->assertSame('Transaction Normal', $response->getMessage());
$this->assertEquals('00', $response->getCode());
}
public function testPurchaseError()
{
$response = new PayeezyResponse($this->getMockRequest(), json_encode(array(
'amount' => 1000,
'exact_resp_code' => 22,
'exact_message' => 'Invalid Credit Card Number',
'reference_no' => 'abc123',
'authorization_num' => 'auth1234',
'transaction_approved' => 0,
)));
$this->assertFalse($response->isSuccessful());
$this->assertEquals('auth1234::', $response->getTransactionReference());
$this->assertSame('Invalid Credit Card Number', $response->getMessage());
$this->assertEquals('22', $response->getCode());
}
public function testBankError()
{
$response = new PayeezyResponse($this->getMockRequest(), json_encode(array(
'amount' => 1000,
'exact_resp_code' => 00,
'reference_no' => 'abc123',
'authorization_num' => '',
'transaction_approved' => 0,
)));
$this->assertFalse($response->isSuccessful());
$this->assertEquals('::', $response->getTransactionReference());
$this->assertEquals('00', $response->getCode());
}
}