hypercharge-schema 1.24.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +7 -0
  6. data/Gemfile.lock +33 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +73 -0
  9. data/Rakefile +14 -0
  10. data/composer.json +17 -0
  11. data/hypercharge-schema.gemspec +27 -0
  12. data/json/MobilePayment.json +73 -0
  13. data/json/WpfPayment.json +99 -0
  14. data/json/authorize.json +77 -0
  15. data/json/authorize3d.json +173 -0
  16. data/json/capture.json +42 -0
  17. data/json/debit_sale.json +73 -0
  18. data/json/direct_pay24_sale.json +85 -0
  19. data/json/giro_pay_sale.json +85 -0
  20. data/json/ideal_sale.json +87 -0
  21. data/json/init_recurring_authorize.json +81 -0
  22. data/json/init_recurring_debit_authorize.json +77 -0
  23. data/json/init_recurring_debit_sale.json +77 -0
  24. data/json/init_recurring_sale.json +81 -0
  25. data/json/pay_in_advance.json +61 -0
  26. data/json/pay_pal.json +65 -0
  27. data/json/pay_safe_card_sale.json +69 -0
  28. data/json/payment_on_delivery.json +57 -0
  29. data/json/purchase_on_account.json +61 -0
  30. data/json/reconcile.json +20 -0
  31. data/json/recurring_debit_sale.json +45 -0
  32. data/json/recurring_sale.json +45 -0
  33. data/json/referenced_fund_transfer.json +46 -0
  34. data/json/refund.json +42 -0
  35. data/json/sale.json +77 -0
  36. data/json/sale3d.json +173 -0
  37. data/json/scheduler_create.json +46 -0
  38. data/json/scheduler_index.json +34 -0
  39. data/json/scheduler_update.json +35 -0
  40. data/json/types.json +385 -0
  41. data/json/void.json +33 -0
  42. data/lib/php/JsonSchemaFixture.php +12 -0
  43. data/lib/php/JsonSchemaValidator.php +47 -0
  44. data/lib/ruby/hypercharge/schema.rb +31 -0
  45. data/lib/ruby/hypercharge/schema/fixture.rb +30 -0
  46. data/lib/ruby/hypercharge/schema/version.rb +7 -0
  47. data/package.json +27 -0
  48. data/test/fixtures/notifications/PaymentNotification_echo.xml +4 -0
  49. data/test/fixtures/notifications/TransactionNotification_echo.xml +4 -0
  50. data/test/fixtures/notifications/recurring_event.json +13 -0
  51. data/test/fixtures/notifications/scheduler.json +7 -0
  52. data/test/fixtures/requests/MobilePayment.json +35 -0
  53. data/test/fixtures/requests/MobilePayment.xml +34 -0
  54. data/test/fixtures/requests/WpfPayment.json +40 -0
  55. data/test/fixtures/requests/WpfPayment.xml +39 -0
  56. data/test/fixtures/requests/WpfPayment_cancel.xml +4 -0
  57. data/test/fixtures/requests/WpfPayment_capture.xml +4 -0
  58. data/test/fixtures/requests/WpfPayment_refund.xml +4 -0
  59. data/test/fixtures/requests/WpfPayment_void.xml +4 -0
  60. data/test/fixtures/requests/authorize.json +29 -0
  61. data/test/fixtures/requests/authorize.xml +28 -0
  62. data/test/fixtures/requests/authorize3d_async.json +32 -0
  63. data/test/fixtures/requests/authorize3d_async.xml +31 -0
  64. data/test/fixtures/requests/authorize3d_sync.json +34 -0
  65. data/test/fixtures/requests/authorize3d_sync.xml +33 -0
  66. data/test/fixtures/requests/capture.json +10 -0
  67. data/test/fixtures/requests/capture.xml +9 -0
  68. data/test/fixtures/requests/debit_sale.json +28 -0
  69. data/test/fixtures/requests/debit_sale.xml +27 -0
  70. data/test/fixtures/requests/direct_pay24_sale.json +31 -0
  71. data/test/fixtures/requests/direct_pay24_sale.xml +30 -0
  72. data/test/fixtures/requests/giro_pay_sale.json +31 -0
  73. data/test/fixtures/requests/giro_pay_sale.xml +30 -0
  74. data/test/fixtures/requests/ideal_sale.json +31 -0
  75. data/test/fixtures/requests/ideal_sale.xml +30 -0
  76. data/test/fixtures/requests/init_recurring_authorize.json +34 -0
  77. data/test/fixtures/requests/init_recurring_authorize.xml +33 -0
  78. data/test/fixtures/requests/init_recurring_debit_authorize.json +33 -0
  79. data/test/fixtures/requests/init_recurring_debit_authorize.xml +32 -0
  80. data/test/fixtures/requests/init_recurring_debit_sale.json +34 -0
  81. data/test/fixtures/requests/init_recurring_debit_sale.xml +32 -0
  82. data/test/fixtures/requests/init_recurring_sale.json +34 -0
  83. data/test/fixtures/requests/init_recurring_sale.xml +33 -0
  84. data/test/fixtures/requests/init_recurring_sale_with_recurring_schedule.json +34 -0
  85. data/test/fixtures/requests/pay_in_advance.json +24 -0
  86. data/test/fixtures/requests/pay_in_advance.xml +23 -0
  87. data/test/fixtures/requests/pay_pal.json +23 -0
  88. data/test/fixtures/requests/pay_pal.xml +22 -0
  89. data/test/fixtures/requests/pay_safe_card_sale.json +23 -0
  90. data/test/fixtures/requests/pay_safe_card_sale.xml +23 -0
  91. data/test/fixtures/requests/payment_on_delivery.json +24 -0
  92. data/test/fixtures/requests/payment_on_delivery.xml +23 -0
  93. data/test/fixtures/requests/purchase_on_account.json +26 -0
  94. data/test/fixtures/requests/purchase_on_account.xml +23 -0
  95. data/test/fixtures/requests/reconcile.json +5 -0
  96. data/test/fixtures/requests/reconcile.xml +4 -0
  97. data/test/fixtures/requests/reconcile_by_date.json +7 -0
  98. data/test/fixtures/requests/reconcile_by_date.xml +6 -0
  99. data/test/fixtures/requests/recurring_debit_sale.json +11 -0
  100. data/test/fixtures/requests/recurring_debit_sale.xml +10 -0
  101. data/test/fixtures/requests/recurring_event.xml +4 -0
  102. data/test/fixtures/requests/recurring_sale.json +11 -0
  103. data/test/fixtures/requests/recurring_sale.xml +10 -0
  104. data/test/fixtures/requests/referenced_fund_transfer.json +11 -0
  105. data/test/fixtures/requests/referenced_fund_transfer.xml +10 -0
  106. data/test/fixtures/requests/refund.json +10 -0
  107. data/test/fixtures/requests/refund.xml +9 -0
  108. data/test/fixtures/requests/risk_params.json +10 -0
  109. data/test/fixtures/requests/risk_params.xml +9 -0
  110. data/test/fixtures/requests/sale.json +29 -0
  111. data/test/fixtures/requests/sale.xml +28 -0
  112. data/test/fixtures/requests/sale3d_async.json +32 -0
  113. data/test/fixtures/requests/sale3d_async.xml +31 -0
  114. data/test/fixtures/requests/sale3d_sync.json +34 -0
  115. data/test/fixtures/requests/sale3d_sync.xml +33 -0
  116. data/test/fixtures/requests/scheduler_create.json +9 -0
  117. data/test/fixtures/requests/scheduler_index_get_params.json +9 -0
  118. data/test/fixtures/requests/scheduler_update.json +8 -0
  119. data/test/fixtures/requests/void.json +8 -0
  120. data/test/fixtures/requests/void.xml +7 -0
  121. data/test/fixtures/responses/MobilePayment_new.json +20 -0
  122. data/test/fixtures/responses/MobilePayment_new.xml +19 -0
  123. data/test/fixtures/responses/PaymentNotification_echo.xml +4 -0
  124. data/test/fixtures/responses/PaymentTransactionNotification_echo.xml +4 -0
  125. data/test/fixtures/responses/WpfPayment_cancel.xml +13 -0
  126. data/test/fixtures/responses/WpfPayment_captured.xml +39 -0
  127. data/test/fixtures/responses/WpfPayment_error.json +8 -0
  128. data/test/fixtures/responses/WpfPayment_error.xml +7 -0
  129. data/test/fixtures/responses/WpfPayment_find.xml +39 -0
  130. data/test/fixtures/responses/WpfPayment_new.json +16 -0
  131. data/test/fixtures/responses/WpfPayment_new.xml +17 -0
  132. data/test/fixtures/responses/WpfPayment_refunded.xml +39 -0
  133. data/test/fixtures/responses/WpfPayment_voided.xml +39 -0
  134. data/test/fixtures/responses/authorize3d_pending_async.xml +15 -0
  135. data/test/fixtures/responses/authorize3d_sync.xml +14 -0
  136. data/test/fixtures/responses/authorize_approved.xml +14 -0
  137. data/test/fixtures/responses/authorize_error.json +16 -0
  138. data/test/fixtures/responses/authorize_error.xml +15 -0
  139. data/test/fixtures/responses/capture.xml +14 -0
  140. data/test/fixtures/responses/create_chargeback.xml +12 -0
  141. data/test/fixtures/responses/create_chargeback_reversal.xml +12 -0
  142. data/test/fixtures/responses/create_charged_debit_sale.xml +12 -0
  143. data/test/fixtures/responses/create_debit_chargeback.xml +12 -0
  144. data/test/fixtures/responses/create_deposit.xml +12 -0
  145. data/test/fixtures/responses/create_pre_arbitration.xml +12 -0
  146. data/test/fixtures/responses/create_rejected_debit_sale.xml +12 -0
  147. data/test/fixtures/responses/create_retrieval_request.xml +12 -0
  148. data/test/fixtures/responses/debit_sale.xml +12 -0
  149. data/test/fixtures/responses/direct_pay24_sale.xml +15 -0
  150. data/test/fixtures/responses/giro_pay_sale.xml +15 -0
  151. data/test/fixtures/responses/ideal_sale.xml +17 -0
  152. data/test/fixtures/responses/init_recurring_authorize.xml +14 -0
  153. data/test/fixtures/responses/init_recurring_debit_authorize.xml +17 -0
  154. data/test/fixtures/responses/init_recurring_debit_sale.xml +17 -0
  155. data/test/fixtures/responses/init_recurring_sale.xml +14 -0
  156. data/test/fixtures/responses/pay_in_advance.xml +17 -0
  157. data/test/fixtures/responses/pay_pal.xml +15 -0
  158. data/test/fixtures/responses/pay_safe_card_sale.xml +15 -0
  159. data/test/fixtures/responses/payment_on_delivery.xml +14 -0
  160. data/test/fixtures/responses/purchase_on_account.xml +18 -0
  161. data/test/fixtures/responses/reconcile_by_date_empty_result.xml +3 -0
  162. data/test/fixtures/responses/reconcile_by_date_page_1.xml +1293 -0
  163. data/test/fixtures/responses/reconcile_by_date_page_2.xml +1346 -0
  164. data/test/fixtures/responses/reconcile_by_date_page_3.xml +1394 -0
  165. data/test/fixtures/responses/reconcile_by_date_single_result.xml +16 -0
  166. data/test/fixtures/responses/recurring_debit_sale.xml +16 -0
  167. data/test/fixtures/responses/recurring_event.json +22 -0
  168. data/test/fixtures/responses/recurring_event.xml +21 -0
  169. data/test/fixtures/responses/recurring_sale.xml +14 -0
  170. data/test/fixtures/responses/referenced_fund_transfer.xml +14 -0
  171. data/test/fixtures/responses/refund.xml +14 -0
  172. data/test/fixtures/responses/sale.xml +12 -0
  173. data/test/fixtures/responses/sale3d_async.xml +15 -0
  174. data/test/fixtures/responses/sale3d_sync.xml +14 -0
  175. data/test/fixtures/responses/scheduled_transactions_empty.json +8 -0
  176. data/test/fixtures/responses/scheduled_transactions_one.json +22 -0
  177. data/test/fixtures/responses/scheduler.json +12 -0
  178. data/test/fixtures/responses/scheduler_empty_result.json +8 -0
  179. data/test/fixtures/responses/scheduler_error.json +7 -0
  180. data/test/fixtures/responses/scheduler_next.json +4 -0
  181. data/test/fixtures/responses/scheduler_page_1.json +93 -0
  182. data/test/fixtures/responses/scheduler_page_2.json +45 -0
  183. data/test/fixtures/responses/scheduler_single_result.json +21 -0
  184. data/test/fixtures/responses/void.xml +12 -0
  185. data/test/js/mobile_payment_test.js +287 -0
  186. data/test/php/all.php +9 -0
  187. data/test/php/authorize3d_test.php +546 -0
  188. data/test/php/authorize_test.php +546 -0
  189. data/test/php/capture_test.php +241 -0
  190. data/test/php/json_schema_validator_test.php +24 -0
  191. data/test/php/mobile_payment_test.php +238 -0
  192. data/test/php/reconcile_test.php +21 -0
  193. data/test/php/referenced_fund_transfer_test.php +183 -0
  194. data/test/php/refund_test.php +237 -0
  195. data/test/php/sale_test.php +546 -0
  196. data/test/php/test_helper.php +29 -0
  197. data/test/php/void_test.php +163 -0
  198. data/test/php/wpf_payment_test.php +19 -0
  199. data/test/ruby/authorize3d_async_spec.rb +29 -0
  200. data/test/ruby/authorize3d_sync_spec.rb +27 -0
  201. data/test/ruby/authorize_spec.rb +25 -0
  202. data/test/ruby/capture_spec.rb +16 -0
  203. data/test/ruby/debit_sale_spec.rb +26 -0
  204. data/test/ruby/direct_pay24_sale_spec.rb +30 -0
  205. data/test/ruby/giro_pay_sale_spec.rb +30 -0
  206. data/test/ruby/ideal_sale_spec.rb +29 -0
  207. data/test/ruby/init_recurring_authorize_spec.rb +26 -0
  208. data/test/ruby/init_recurring_debit_authorize_spec.rb +27 -0
  209. data/test/ruby/init_recurring_debit_sale_spec.rb +27 -0
  210. data/test/ruby/init_recurring_sale_spec.rb +26 -0
  211. data/test/ruby/mobile_payment_spec.rb +22 -0
  212. data/test/ruby/pay_in_advance_spec.rb +23 -0
  213. data/test/ruby/pay_pal_spec.rb +25 -0
  214. data/test/ruby/pay_safe_card_sale_spec.rb +24 -0
  215. data/test/ruby/payment_on_delivery_spec.rb +21 -0
  216. data/test/ruby/purchase_on_account_spec.rb +23 -0
  217. data/test/ruby/reconcile_spec.rb +11 -0
  218. data/test/ruby/recurring_debit_sale_spec.rb +17 -0
  219. data/test/ruby/recurring_sale_spec.rb +17 -0
  220. data/test/ruby/referenced_fund_transfer_spec.rb +17 -0
  221. data/test/ruby/refund_spec.rb +16 -0
  222. data/test/ruby/sale3d_async_spec.rb +29 -0
  223. data/test/ruby/sale3d_sync_spec.rb +27 -0
  224. data/test/ruby/sale_spec.rb +25 -0
  225. data/test/ruby/scheduler_spec.rb +43 -0
  226. data/test/ruby/test_helper.rb +74 -0
  227. data/test/ruby/types_specs.rb +1494 -0
  228. data/test/ruby/void_spec.rb +14 -0
  229. data/test/ruby/wpf_payment_spec.rb +27 -0
  230. metadata +527 -0
@@ -0,0 +1,9 @@
1
+ <?php
2
+ require_once 'test_helper.php';
3
+
4
+ class AllTests extends TestSuite {
5
+ function AllTests() {
6
+ $this->TestSuite('All tests');
7
+ $this->collect(__DIR__, new SimplePatternCollector('/_test\.php$/'));
8
+ }
9
+ }
@@ -0,0 +1,546 @@
1
+ <?php
2
+ require_once 'test_helper.php';
3
+
4
+ class authorize3d_Test extends SchemaTestCase {
5
+
6
+ function __construct() {
7
+ parent::__construct('authorize3d');
8
+ $this->jsonData = $this->fixture('authorize3d_async.json');
9
+ }
10
+
11
+ function setUp() {
12
+ $this->data = json_decode($this->jsonData);
13
+ $this->trx = $this->data->payment_transaction;
14
+ }
15
+
16
+ function testFixtureShouldValidate() {
17
+ $this->assertValid();
18
+ $this->assertEqual('authorize3d', $this->trx->transaction_type);
19
+ }
20
+
21
+ function testObjectRequired() {
22
+ $this->data = null;
23
+ $this->assertNotValid();
24
+ }
25
+
26
+ function testRootNodeRequired() {
27
+ $this->data = new stdClass;
28
+ $this->assertNotValid();
29
+ }
30
+
31
+ function testRootNodeContentsRequired() {
32
+ $this->data->payment_transaction = new stdClass;
33
+ $this->assertNotValid();
34
+ }
35
+
36
+ function testNoAdditionalFieldsAllowedInRoot() {
37
+ $this->data->should_cause_validation_error = 'foo';
38
+ $this->assertNotValid();
39
+ }
40
+
41
+ function testNoAdditionalFieldsAllowedInTrx() {
42
+ $this->trx->should_cause_validation_error = 'foo';
43
+ $this->assertNotValid();
44
+ }
45
+
46
+ function testTypeWrong() {
47
+ $this->trx->transaction_type = 'authorize';
48
+ $this->assertNotValid();
49
+ }
50
+
51
+ function testTransactionId1Char() {
52
+ $this->trx->transaction_id = 'a';
53
+ $this->assertValid();
54
+ }
55
+
56
+ function testTransactionId255Char() {
57
+ $this->trx->transaction_id = str_repeat('x', 255);
58
+ $this->assertValid();
59
+ }
60
+
61
+ function testTransactionIdValidChars() {
62
+ $this->trx->transaction_id = 'abcxyzABCDXYZ0123456789-_.';
63
+ $this->assertValid();
64
+ }
65
+
66
+ function testTransactionIdSlashShouldBeInvalid() {
67
+ $this->trx->transaction_id = '/';
68
+ $this->assertNotValid();
69
+ }
70
+
71
+ function testTransactionId256CharShouldBeInvalid() {
72
+ $this->trx->transaction_id = str_repeat('a', 256);
73
+ $this->assertNotValid();
74
+ }
75
+
76
+ function testTransactionIdBackslashShouldBeInvalid() {
77
+ $this->trx->transaction_id = '\\';
78
+ $this->assertNotValid();
79
+ }
80
+
81
+ function testTransactionIdPlusShouldBeInvalid() {
82
+ $this->trx->transaction_id = '+';
83
+ $this->assertNotValid();
84
+ }
85
+
86
+ function testTransactionIdStarShouldBeInvalid() {
87
+ $this->trx->transaction_id = '*';
88
+ $this->assertNotValid();
89
+ }
90
+
91
+ function testTransactionIdEmpty() {
92
+ $this->trx->transaction_id = '';
93
+ $this->assertNotValid();
94
+ }
95
+
96
+ function testAmount1() {
97
+ $this->trx->amount = 1;
98
+ $this->assertValid();
99
+ }
100
+ function testAmount1000000000() {
101
+ $this->trx->amount = 1000000000;
102
+ $this->assertValid();
103
+ }
104
+ function testAmountMissing() {
105
+ unset($this->trx->amount);
106
+ $this->assertNotValid();
107
+ }
108
+ function testAmount1dot2() {
109
+ $this->trx->amount = 1.2;
110
+ $this->assertNotValid();
111
+ }
112
+ function testAmount0() {
113
+ $this->trx->amount = 0;
114
+ $this->assertNotValid();
115
+ }
116
+ function testAmountMinus1() {
117
+ $this->trx->amount = -1;
118
+ $this->assertNotValid();
119
+ }
120
+ function testAmountMinus1dot2() {
121
+ $this->trx->amount = -1.2;
122
+ $this->assertNotValid();
123
+ }
124
+ function testAmountFoo() {
125
+ $this->trx->amount = 'foo';
126
+ $this->assertNotValid();
127
+ }
128
+
129
+ function testCurrencyEUR() {
130
+ $this->trx->currency = 'EUR';
131
+ $this->assertValid();
132
+ }
133
+ function testCurrencyUSD() {
134
+ $this->trx->currency = 'USD';
135
+ $this->assertValid();
136
+ }
137
+ function testCurrencyMissing() {
138
+ unset($this->trx->currency);
139
+ $this->assertNotValid();
140
+ }
141
+ function testCurrencyEmptyString() {
142
+ $this->trx->currency = '';
143
+ $this->assertNotValid();
144
+ }
145
+ function testCurrencyEuroSign() {
146
+ $this->trx->currency = '€';
147
+ $this->assertNotValid();
148
+ }
149
+ function testCurrencyDollarSign() {
150
+ $this->trx->currency = '$';
151
+ $this->assertNotValid();
152
+ }
153
+ function testCurrencyXXX() {
154
+ $this->trx->currency = 'XXX';
155
+ $this->assertNotValid();
156
+ }
157
+ function testCurrency0() {
158
+ $this->trx->currency = 0;
159
+ $this->assertNotValid();
160
+ }
161
+
162
+ function testUsage1Char() {
163
+ $this->trx->usage = 'x';
164
+ $this->assertValid();
165
+ }
166
+ function testUsage255Char() {
167
+ $this->trx->usage = str_repeat('_', 255);
168
+ $this->assertValid();
169
+ }
170
+ function testUsageEmpty() {
171
+ $this->trx->usage = '';
172
+ $this->assertNotValid();
173
+ }
174
+ function testUsage256Char() {
175
+ $this->trx->usage = str_repeat('_', 256);
176
+ $this->assertNotValid();
177
+ }
178
+ function testUsageValidChars() {
179
+ $this->trx->usage = "aAÄöéß1234 - _ / # '\" <b>";
180
+ $this->assertValid();
181
+ }
182
+ function testUsageMissing() {
183
+ unset($this->trx->usage);
184
+ $this->assertValid();
185
+ }
186
+
187
+ function testRemoteIp_0_0_0_0() {
188
+ $this->trx->remote_ip = "0.0.0.0";
189
+ $this->assertValid();
190
+ }
191
+ function testRemoteIp_127_0_0_1() {
192
+ $this->trx->remote_ip = "127.0.0.1";
193
+ $this->assertValid();
194
+ }
195
+ function testRemoteIp255_255_255_255() {
196
+ $this->trx->remote_ip = "255.255.255.255";
197
+ $this->assertValid();
198
+ }
199
+ function testRemoteIp_0_0_0() {
200
+ $this->trx->remote_ip = "0.0.0";
201
+ $this->assertNotValid();
202
+ }
203
+ function testRemoteIp_0_0() {
204
+ $this->trx->remote_ip = "0.0";
205
+ $this->assertNotValid();
206
+ }
207
+ function testRemoteIp_0() {
208
+ $this->trx->remote_ip = "0";
209
+ $this->assertNotValid();
210
+ }
211
+ function testRemoteIpMissing() {
212
+ unset($this->trx->remote_ip);
213
+ $this->assertNotValid();
214
+ }
215
+
216
+ function testCardHolderUmlaut() {
217
+ $this->trx->card_holder = 'ä';
218
+ $this->assertValid();
219
+ }
220
+ function testCardHolder255Chars() {
221
+ $this->trx->card_holder = str_repeat('z', 255);
222
+ $this->assertValid();
223
+ }
224
+ function testCardHolder256Chars() {
225
+ $this->trx->card_holder = str_repeat('z', 256);
226
+ $this->assertNotValid();
227
+ }
228
+ function testCardHolderEmpty() {
229
+ $this->trx->card_holder = '';
230
+ $this->assertNotValid();
231
+ }
232
+ function testCardHolderMissing() {
233
+ unset($this->trx->card_holder);
234
+ $this->assertNotValid();
235
+ }
236
+
237
+ function testCardNumber12Digits() {
238
+ $this->trx->card_number = str_repeat('0', 12);
239
+ $this->assertNotValid();
240
+ }
241
+ function testCardNumber13Digits() {
242
+ $this->trx->card_number = str_repeat('0', 13);
243
+ $this->assertValid();
244
+ }
245
+ function testCardNumber14Digits() {
246
+ $this->trx->card_number = str_repeat('0', 14);
247
+ $this->assertValid();
248
+ }
249
+ function testCardNumber15Digits() {
250
+ $this->trx->card_number = str_repeat('0', 15);
251
+ $this->assertValid();
252
+ }
253
+ function testCardNumber16Digits() {
254
+ $this->trx->card_number = str_repeat('0', 16);
255
+ $this->assertValid();
256
+ }
257
+ function testCardNumber17Digits() {
258
+ $this->trx->card_number = str_repeat('0', 17);
259
+ $this->assertNotValid();
260
+ }
261
+ function testCardNumberEmpty() {
262
+ $this->trx->card_number = '';
263
+ $this->assertNotValid();
264
+ }
265
+ function testCardNumberNull() {
266
+ $this->trx->card_number = null;
267
+ $this->assertNotValid();
268
+ }
269
+ function testCardNumberMissing() {
270
+ unset($this->trx->card_number);
271
+ $this->assertNotValid();
272
+ }
273
+ function testCardNumberInvalidChar() {
274
+ $this->trx->card_number = '12345678901234 ';
275
+ $this->assertNotValid();
276
+ }
277
+
278
+ function testCvv2Digits() {
279
+ $this->trx->cvv = '12';
280
+ $this->assertNotValid();
281
+ }
282
+ function testCcc3Digits() {
283
+ $this->trx->cvv = '123';
284
+ $this->assertValid();
285
+ }
286
+ function testCcc4Digits() {
287
+ $this->trx->cvv = '1234';
288
+ $this->assertValid();
289
+ }
290
+ function testCcc5Digits() {
291
+ $this->trx->cvv = '12345';
292
+ $this->assertNotValid();
293
+ }
294
+ function testCccEmpty() {
295
+ $this->trx->cvv = '';
296
+ $this->assertNotValid();
297
+ }
298
+ function testCccBlank() {
299
+ $this->trx->cvv = ' ';
300
+ $this->assertNotValid();
301
+ }
302
+ function testCccInvalidChars() {
303
+ $this->trx->cvv = 'abcd';
304
+ $this->assertNotValid();
305
+ }
306
+ function testCccMissing() {
307
+ unset($this->trx->cvv);
308
+ $this->assertValid();
309
+ }
310
+
311
+ function testExpirationMonth_00() {
312
+ $this->trx->expiration_month = '00';
313
+ $this->assertNotValid();
314
+ }
315
+ function testExpirationMonth_01() {
316
+ $this->trx->expiration_month = '01';
317
+ $this->assertValid();
318
+ }
319
+ function testExpirationMonth_02() {
320
+ $this->trx->expiration_month = '02';
321
+ $this->assertValid();
322
+ }
323
+ function testExpirationMonth_03() {
324
+ $this->trx->expiration_month = '03';
325
+ $this->assertValid();
326
+ }
327
+ function testExpirationMonth_04() {
328
+ $this->trx->expiration_month = '04';
329
+ $this->assertValid();
330
+ }
331
+ function testExpirationMonth_05() {
332
+ $this->trx->expiration_month = '05';
333
+ $this->assertValid();
334
+ }
335
+ function testExpirationMonth_06() {
336
+ $this->trx->expiration_month = '06';
337
+ $this->assertValid();
338
+ }
339
+ function testExpirationMonth_07() {
340
+ $this->trx->expiration_month = '07';
341
+ $this->assertValid();
342
+ }
343
+ function testExpirationMonth_08() {
344
+ $this->trx->expiration_month = '08';
345
+ $this->assertValid();
346
+ }
347
+ function testExpirationMonth_09() {
348
+ $this->trx->expiration_month = '09';
349
+ $this->assertValid();
350
+ }
351
+ function testExpirationMonth_1() {
352
+ $this->trx->expiration_month = '1';
353
+ $this->assertValid();
354
+ }
355
+ function testExpirationMonth_2() {
356
+ $this->trx->expiration_month = '2';
357
+ $this->assertValid();
358
+ }
359
+ function testExpirationMonth_3() {
360
+ $this->trx->expiration_month = '3';
361
+ $this->assertValid();
362
+ }
363
+ function testExpirationMonth_4() {
364
+ $this->trx->expiration_month = '4';
365
+ $this->assertValid();
366
+ }
367
+ function testExpirationMonth_5() {
368
+ $this->trx->expiration_month = '5';
369
+ $this->assertValid();
370
+ }
371
+ function testExpirationMonth_6() {
372
+ $this->trx->expiration_month = '6';
373
+ $this->assertValid();
374
+ }
375
+ function testExpirationMonth_7() {
376
+ $this->trx->expiration_month = '7';
377
+ $this->assertValid();
378
+ }
379
+ function testExpirationMonth_8() {
380
+ $this->trx->expiration_month = '8';
381
+ $this->assertValid();
382
+ }
383
+ function testExpirationMonth_9() {
384
+ $this->trx->expiration_month = '9';
385
+ $this->assertValid();
386
+ }
387
+ function testExpirationMonth_10() {
388
+ $this->trx->expiration_month = '10';
389
+ $this->assertValid();
390
+ }
391
+ function testExpirationMonth_11() {
392
+ $this->trx->expiration_month = '11';
393
+ $this->assertValid();
394
+ }
395
+ function testExpirationMonth_12() {
396
+ $this->trx->expiration_month = '12';
397
+ $this->assertValid();
398
+ }
399
+ function testExpirationMonth_13() {
400
+ $this->trx->expiration_month = '13';
401
+ $this->assertNotValid();
402
+ }
403
+ function testExpirationMonth_20() {
404
+ $this->trx->expiration_month = '20';
405
+ $this->assertNotValid();
406
+ }
407
+ function testExpirationMonth2LeadingZero() {
408
+ $this->trx->expiration_month = '001';
409
+ $this->assertNotValid();
410
+ }
411
+
412
+ function testExpirationYear_1999() {
413
+ $this->trx->expiration_year = '1999';
414
+ $this->assertNotValid();
415
+ }
416
+ function testExpirationYear_2000() {
417
+ $this->trx->expiration_year = '2000';
418
+ $this->assertValid();
419
+ }
420
+ function testExpirationYear_2001() {
421
+ $this->trx->expiration_year = '2000';
422
+ $this->assertValid();
423
+ }
424
+ function testExpirationYear_2013() {
425
+ $this->trx->expiration_year = '2013';
426
+ $this->assertValid();
427
+ }
428
+ function testExpirationYear_2013_int() {
429
+ $this->trx->expiration_year = 2013;
430
+ $this->assertNotValid();
431
+ }
432
+ function testExpirationYear_2015() {
433
+ $this->trx->expiration_year = '2015';
434
+ $this->assertValid();
435
+ }
436
+ function testExpirationYear_2016() {
437
+ $this->trx->expiration_year = '2016';
438
+ $this->assertValid();
439
+ }
440
+ function testExpirationYear_2020() {
441
+ $this->trx->expiration_year = '2020';
442
+ $this->assertValid();
443
+ }
444
+ function testExpirationYear_2021() {
445
+ $this->trx->expiration_year = '2021';
446
+ $this->assertValid();
447
+ }
448
+ function testExpirationYear_2022() {
449
+ $this->trx->expiration_year = '2022';
450
+ $this->assertValid();
451
+ }
452
+ function testExpirationYear_2030() {
453
+ $this->trx->expiration_year = '2030';
454
+ $this->assertValid();
455
+ }
456
+ function testExpirationYear_2100() {
457
+ $this->trx->expiration_year = '2100';
458
+ $this->assertNotValid();
459
+ }
460
+ function testExpirationYear_2999() {
461
+ $this->trx->expiration_year = '2999';
462
+ $this->assertNotValid();
463
+ }
464
+ function testExpirationYear_3000() {
465
+ $this->trx->expiration_year = '3000';
466
+ $this->assertNotValid();
467
+ }
468
+ function testExpirationYear_15() {
469
+ $this->trx->expiration_year = '15';
470
+ $this->assertNotValid();
471
+ }
472
+ function testExpirationYearMissing() {
473
+ unset($this->trx->expiration_year);
474
+ $this->assertNotValid();
475
+ }
476
+ function testExpirationYearBlank() {
477
+ $this->trx->expiration_year = '';
478
+ $this->assertNotValid();
479
+ }
480
+
481
+ function testCustomerEmail() {
482
+ $this->trx->customer_email = 'this-is@an.email.com';
483
+ $this->assertValid();
484
+ }
485
+ function testCustomerEmailInvalid() {
486
+ $this->trx->customer_email = 'this is no email';
487
+ $this->assertNotValid();
488
+ }
489
+ function testCustomerEmailMissing() {
490
+ unset($this->trx->customer_email);
491
+ $this->assertNotValid();
492
+ }
493
+ function testCustomerEmailBlank() {
494
+ $this->trx->customer_email = '';
495
+ $this->assertNotValid();
496
+ }
497
+
498
+ function testCustomerPhone() {
499
+ $this->trx->customer_phone = '030/123 4536 123-78';
500
+ $this->assertValid();
501
+ }
502
+ function testCustomerPhone1Char() {
503
+ $this->trx->customer_phone = '1';
504
+ $this->assertValid();
505
+ }
506
+ function testCustomerPhone255Char() {
507
+ $this->trx->customer_phone = str_repeat('1', 255);
508
+ $this->assertValid();
509
+ }
510
+ function testCustomerPhone256Char() {
511
+ $this->trx->customer_phone = str_repeat('1', 256);
512
+ $this->assertNotValid();
513
+ }
514
+ function testCustomerPhoneMissing() {
515
+ unset($this->trx->customer_phone);
516
+ $this->assertValid();
517
+ }
518
+ function testCustomerPhoneBlank() {
519
+ $this->trx->customer_phone = '';
520
+ $this->assertNotValid();
521
+ }
522
+
523
+ // billing_address tested en detail in mobile_payment_test.php
524
+ function testBillingAddressMissing() {
525
+ unset($this->trx->billing_address);
526
+ $this->assertNotValid();
527
+ }
528
+ // random test
529
+ function testBillingAddress_FirstNameMissing() {
530
+ unset($this->trx->billing_address->first_name);
531
+ $this->assertNotValid();
532
+ }
533
+
534
+ // risk_params tested en detail in mobile_payment_test.php
535
+ function testRiskParams() {
536
+ $this->trx->risk_params = json_decode($this->fixture('risk_params.json'));
537
+ $this->assertValid();
538
+ }
539
+ // random test
540
+ function testRiskParams_RemoteIpEmpty() {
541
+ $this->trx->risk_params = json_decode($this->fixture('risk_params.json'));
542
+ $this->trx->risk_params->remote_ip = '';
543
+ $this->assertNotValid();
544
+ }
545
+
546
+ }