5
5
6
6
class DirectPostGatewayTest extends GatewayTestCase
7
7
{
8
- protected $ successOptions ;
9
- protected $ failureOptions ;
8
+ protected $ purchaseOptions ;
9
+ protected $ captureOptions ;
10
+ protected $ voidOptions ;
11
+ protected $ refundOptions ;
10
12
11
13
public function setUp ()
12
14
{
13
15
parent ::setUp ();
14
16
15
17
$ this ->gateway = new DirectPostGateway ($ this ->getHttpClient (), $ this ->getHttpRequest ());
16
18
17
- $ this ->successOptions = array (
19
+ $ this ->purchaseOptions = array (
18
20
'amount ' => '10.00 ' ,
19
21
'card ' => $ this ->getValidCard ()
20
22
);
21
23
22
- $ this ->failureOptions = array (
23
- 'amount ' => '0.00 ' ,
24
- 'card ' => $ this ->getValidCard ()
24
+ $ this ->captureOptions = array (
25
+ 'amount ' => '10.00 ' ,
26
+ 'transactionReference ' => '2577708057 '
27
+ );
28
+
29
+ $ this ->voidOptions = array (
30
+ 'transactionReference ' => '2577708057 '
31
+ );
32
+
33
+ $ this ->refundOptions = array (
34
+ 'transactionReference ' => '2577725848 '
25
35
);
26
36
}
27
37
28
38
public function testAuthorizeSuccess ()
29
39
{
30
40
$ this ->setMockHttpResponse ('DirectPostAuthSuccess.txt ' );
31
41
32
- $ response = $ this ->gateway ->authorize ($ this ->successOptions )->send ();
42
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
33
43
$ this ->assertTrue ($ response ->isSuccessful ());
34
44
$ this ->assertSame ('2577708057 ' , $ response ->getTransactionReference ());
35
45
$ this ->assertSame ('SUCCESS ' , $ response ->getMessage ());
@@ -39,70 +49,116 @@ public function testAuthorizeFailure()
39
49
{
40
50
$ this ->setMockHttpResponse ('DirectPostAuthFailure.txt ' );
41
51
42
- $ response = $ this ->gateway ->authorize ($ this ->failureOptions )->send ();
52
+ $ this ->purchaseOptions ['amount ' ] = '0.00 ' ;
53
+
54
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
43
55
$ this ->assertFalse ($ response ->isSuccessful ());
44
56
$ this ->assertSame ('2577711599 ' , $ response ->getTransactionReference ());
45
57
$ this ->assertSame ('DECLINE ' , $ response ->getMessage ());
46
58
}
47
59
48
- public function testSaleSuccess ()
60
+ public function testPurchaseSuccess ()
49
61
{
62
+ $ this ->setMockHttpResponse ('DirectPostSaleSuccess.txt ' );
50
63
64
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
65
+ $ this ->assertTrue ($ response ->isSuccessful ());
66
+ $ this ->assertSame ('2577715564 ' , $ response ->getTransactionReference ());
67
+ $ this ->assertSame ('SUCCESS ' , $ response ->getMessage ());
51
68
}
52
69
53
- public function testSaleFailure ()
70
+ public function testPurchaseFailure ()
54
71
{
72
+ $ this ->setMockHttpResponse ('DirectPostSaleFailure.txt ' );
55
73
74
+ $ this ->purchaseOptions ['amount ' ] = '0.00 ' ;
75
+
76
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
77
+ $ this ->assertFalse ($ response ->isSuccessful ());
78
+ $ this ->assertSame ('2577715978 ' , $ response ->getTransactionReference ());
79
+ $ this ->assertSame ('DECLINE ' , $ response ->getMessage ());
56
80
}
57
81
58
82
public function testCaptureSuccess ()
59
83
{
84
+ $ this ->setMockHttpResponse ('DirectPostCaptureSuccess.txt ' );
60
85
86
+ $ response = $ this ->gateway ->capture ($ this ->captureOptions )->send ();
87
+ $ this ->assertTrue ($ response ->isSuccessful ());
88
+ $ this ->assertSame ('2577708057 ' , $ response ->getTransactionReference ());
89
+ $ this ->assertSame ('SUCCESS ' , $ response ->getMessage ());
61
90
}
62
91
63
92
public function testCaptureFailure ()
64
93
{
94
+ $ this ->setMockHttpResponse ('DirectPostCaptureFailure.txt ' );
65
95
96
+ $ response = $ this ->gateway ->capture ($ this ->captureOptions )->send ();
97
+ $ this ->assertFalse ($ response ->isSuccessful ());
98
+ $ this ->assertSame ('2577708057 ' , $ response ->getTransactionReference ());
99
+ $ this ->assertSame ('A capture requires that the existing transaction be an AUTH REFID:143498124 ' , $ response ->getMessage ());
66
100
}
67
101
68
102
public function testVoidSuccess ()
69
103
{
104
+ $ this ->setMockHttpResponse ('DirectPostVoidSuccess.txt ' );
70
105
106
+ $ response = $ this ->gateway ->void ($ this ->voidOptions )->send ();
107
+ $ this ->assertTrue ($ response ->isSuccessful ());
108
+ $ this ->assertSame ('2577708057 ' , $ response ->getTransactionReference ());
109
+ $ this ->assertSame ('Transaction Void Successful ' , $ response ->getMessage ());
71
110
}
72
111
73
112
public function testVoidFailure ()
74
113
{
114
+ $ this ->setMockHttpResponse ('DirectPostVoidFailure.txt ' );
75
115
116
+ $ response = $ this ->gateway ->void ($ this ->voidOptions )->send ();
117
+ $ this ->assertFalse ($ response ->isSuccessful ());
118
+ $ this ->assertSame ('2577708057 ' , $ response ->getTransactionReference ());
119
+ $ this ->assertSame ('Only transactions pending settlement can be voided REFID:143498494 ' , $ response ->getMessage ());
76
120
}
77
121
78
122
public function testRefundSuccess ()
79
123
{
124
+ $ this ->setMockHttpResponse ('DirectPostRefundSuccess.txt ' );
80
125
126
+ $ response = $ this ->gateway ->void ($ this ->refundOptions )->send ();
127
+ $ this ->assertTrue ($ response ->isSuccessful ());
128
+ $ this ->assertSame ('2577725848 ' , $ response ->getTransactionReference ());
129
+ $ this ->assertSame ('SUCCESS ' , $ response ->getMessage ());
81
130
}
82
131
83
132
public function testRefundFailure ()
84
133
{
134
+ $ this ->setMockHttpResponse ('DirectPostRefundFailure.txt ' );
85
135
136
+ $ response = $ this ->gateway ->void ($ this ->refundOptions )->send ();
137
+ $ this ->assertFalse ($ response ->isSuccessful ());
138
+ $ this ->assertSame ('2577725848 ' , $ response ->getTransactionReference ());
139
+ $ this ->assertSame ('Refund amount may not exceed the transaction balance REFID:143498703 ' , $ response ->getMessage ());
86
140
}
87
141
88
142
public function testCreditSuccess ()
89
143
{
144
+ $ this ->setMockHttpResponse ('DirectPostCreditSuccess.txt ' );
90
145
146
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
147
+ $ this ->assertTrue ($ response ->isSuccessful ());
148
+ $ this ->assertSame ('2577728141 ' , $ response ->getTransactionReference ());
149
+ $ this ->assertSame ('SUCCESS ' , $ response ->getMessage ());
91
150
}
92
151
93
152
public function testCreditFailure ()
94
153
{
154
+ $ this ->setMockHttpResponse ('DirectPostCreditFailure.txt ' );
95
155
96
- }
97
-
98
- public function testValidateSuccess ()
99
- {
100
-
101
- }
102
-
103
- public function testValidateFailure ()
104
- {
156
+ $ this ->purchaseOptions ['amount ' ] = '0.00 ' ;
105
157
158
+ $ response = $ this ->gateway ->authorize ($ this ->purchaseOptions )->send ();
159
+ $ this ->assertFalse ($ response ->isSuccessful ());
160
+ $ this ->assertSame ('' , $ response ->getTransactionReference ());
161
+ $ this ->assertSame ('Invalid amount REFID:143498834 ' , $ response ->getMessage ());
106
162
}
107
163
108
164
}
0 commit comments