hypercharge-schema 1.24.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +14 -0
- data/composer.json +17 -0
- data/hypercharge-schema.gemspec +27 -0
- data/json/MobilePayment.json +73 -0
- data/json/WpfPayment.json +99 -0
- data/json/authorize.json +77 -0
- data/json/authorize3d.json +173 -0
- data/json/capture.json +42 -0
- data/json/debit_sale.json +73 -0
- data/json/direct_pay24_sale.json +85 -0
- data/json/giro_pay_sale.json +85 -0
- data/json/ideal_sale.json +87 -0
- data/json/init_recurring_authorize.json +81 -0
- data/json/init_recurring_debit_authorize.json +77 -0
- data/json/init_recurring_debit_sale.json +77 -0
- data/json/init_recurring_sale.json +81 -0
- data/json/pay_in_advance.json +61 -0
- data/json/pay_pal.json +65 -0
- data/json/pay_safe_card_sale.json +69 -0
- data/json/payment_on_delivery.json +57 -0
- data/json/purchase_on_account.json +61 -0
- data/json/reconcile.json +20 -0
- data/json/recurring_debit_sale.json +45 -0
- data/json/recurring_sale.json +45 -0
- data/json/referenced_fund_transfer.json +46 -0
- data/json/refund.json +42 -0
- data/json/sale.json +77 -0
- data/json/sale3d.json +173 -0
- data/json/scheduler_create.json +46 -0
- data/json/scheduler_index.json +34 -0
- data/json/scheduler_update.json +35 -0
- data/json/types.json +385 -0
- data/json/void.json +33 -0
- data/lib/php/JsonSchemaFixture.php +12 -0
- data/lib/php/JsonSchemaValidator.php +47 -0
- data/lib/ruby/hypercharge/schema.rb +31 -0
- data/lib/ruby/hypercharge/schema/fixture.rb +30 -0
- data/lib/ruby/hypercharge/schema/version.rb +7 -0
- data/package.json +27 -0
- data/test/fixtures/notifications/PaymentNotification_echo.xml +4 -0
- data/test/fixtures/notifications/TransactionNotification_echo.xml +4 -0
- data/test/fixtures/notifications/recurring_event.json +13 -0
- data/test/fixtures/notifications/scheduler.json +7 -0
- data/test/fixtures/requests/MobilePayment.json +35 -0
- data/test/fixtures/requests/MobilePayment.xml +34 -0
- data/test/fixtures/requests/WpfPayment.json +40 -0
- data/test/fixtures/requests/WpfPayment.xml +39 -0
- data/test/fixtures/requests/WpfPayment_cancel.xml +4 -0
- data/test/fixtures/requests/WpfPayment_capture.xml +4 -0
- data/test/fixtures/requests/WpfPayment_refund.xml +4 -0
- data/test/fixtures/requests/WpfPayment_void.xml +4 -0
- data/test/fixtures/requests/authorize.json +29 -0
- data/test/fixtures/requests/authorize.xml +28 -0
- data/test/fixtures/requests/authorize3d_async.json +32 -0
- data/test/fixtures/requests/authorize3d_async.xml +31 -0
- data/test/fixtures/requests/authorize3d_sync.json +34 -0
- data/test/fixtures/requests/authorize3d_sync.xml +33 -0
- data/test/fixtures/requests/capture.json +10 -0
- data/test/fixtures/requests/capture.xml +9 -0
- data/test/fixtures/requests/debit_sale.json +28 -0
- data/test/fixtures/requests/debit_sale.xml +27 -0
- data/test/fixtures/requests/direct_pay24_sale.json +31 -0
- data/test/fixtures/requests/direct_pay24_sale.xml +30 -0
- data/test/fixtures/requests/giro_pay_sale.json +31 -0
- data/test/fixtures/requests/giro_pay_sale.xml +30 -0
- data/test/fixtures/requests/ideal_sale.json +31 -0
- data/test/fixtures/requests/ideal_sale.xml +30 -0
- data/test/fixtures/requests/init_recurring_authorize.json +34 -0
- data/test/fixtures/requests/init_recurring_authorize.xml +33 -0
- data/test/fixtures/requests/init_recurring_debit_authorize.json +33 -0
- data/test/fixtures/requests/init_recurring_debit_authorize.xml +32 -0
- data/test/fixtures/requests/init_recurring_debit_sale.json +34 -0
- data/test/fixtures/requests/init_recurring_debit_sale.xml +32 -0
- data/test/fixtures/requests/init_recurring_sale.json +34 -0
- data/test/fixtures/requests/init_recurring_sale.xml +33 -0
- data/test/fixtures/requests/init_recurring_sale_with_recurring_schedule.json +34 -0
- data/test/fixtures/requests/pay_in_advance.json +24 -0
- data/test/fixtures/requests/pay_in_advance.xml +23 -0
- data/test/fixtures/requests/pay_pal.json +23 -0
- data/test/fixtures/requests/pay_pal.xml +22 -0
- data/test/fixtures/requests/pay_safe_card_sale.json +23 -0
- data/test/fixtures/requests/pay_safe_card_sale.xml +23 -0
- data/test/fixtures/requests/payment_on_delivery.json +24 -0
- data/test/fixtures/requests/payment_on_delivery.xml +23 -0
- data/test/fixtures/requests/purchase_on_account.json +26 -0
- data/test/fixtures/requests/purchase_on_account.xml +23 -0
- data/test/fixtures/requests/reconcile.json +5 -0
- data/test/fixtures/requests/reconcile.xml +4 -0
- data/test/fixtures/requests/reconcile_by_date.json +7 -0
- data/test/fixtures/requests/reconcile_by_date.xml +6 -0
- data/test/fixtures/requests/recurring_debit_sale.json +11 -0
- data/test/fixtures/requests/recurring_debit_sale.xml +10 -0
- data/test/fixtures/requests/recurring_event.xml +4 -0
- data/test/fixtures/requests/recurring_sale.json +11 -0
- data/test/fixtures/requests/recurring_sale.xml +10 -0
- data/test/fixtures/requests/referenced_fund_transfer.json +11 -0
- data/test/fixtures/requests/referenced_fund_transfer.xml +10 -0
- data/test/fixtures/requests/refund.json +10 -0
- data/test/fixtures/requests/refund.xml +9 -0
- data/test/fixtures/requests/risk_params.json +10 -0
- data/test/fixtures/requests/risk_params.xml +9 -0
- data/test/fixtures/requests/sale.json +29 -0
- data/test/fixtures/requests/sale.xml +28 -0
- data/test/fixtures/requests/sale3d_async.json +32 -0
- data/test/fixtures/requests/sale3d_async.xml +31 -0
- data/test/fixtures/requests/sale3d_sync.json +34 -0
- data/test/fixtures/requests/sale3d_sync.xml +33 -0
- data/test/fixtures/requests/scheduler_create.json +9 -0
- data/test/fixtures/requests/scheduler_index_get_params.json +9 -0
- data/test/fixtures/requests/scheduler_update.json +8 -0
- data/test/fixtures/requests/void.json +8 -0
- data/test/fixtures/requests/void.xml +7 -0
- data/test/fixtures/responses/MobilePayment_new.json +20 -0
- data/test/fixtures/responses/MobilePayment_new.xml +19 -0
- data/test/fixtures/responses/PaymentNotification_echo.xml +4 -0
- data/test/fixtures/responses/PaymentTransactionNotification_echo.xml +4 -0
- data/test/fixtures/responses/WpfPayment_cancel.xml +13 -0
- data/test/fixtures/responses/WpfPayment_captured.xml +39 -0
- data/test/fixtures/responses/WpfPayment_error.json +8 -0
- data/test/fixtures/responses/WpfPayment_error.xml +7 -0
- data/test/fixtures/responses/WpfPayment_find.xml +39 -0
- data/test/fixtures/responses/WpfPayment_new.json +16 -0
- data/test/fixtures/responses/WpfPayment_new.xml +17 -0
- data/test/fixtures/responses/WpfPayment_refunded.xml +39 -0
- data/test/fixtures/responses/WpfPayment_voided.xml +39 -0
- data/test/fixtures/responses/authorize3d_pending_async.xml +15 -0
- data/test/fixtures/responses/authorize3d_sync.xml +14 -0
- data/test/fixtures/responses/authorize_approved.xml +14 -0
- data/test/fixtures/responses/authorize_error.json +16 -0
- data/test/fixtures/responses/authorize_error.xml +15 -0
- data/test/fixtures/responses/capture.xml +14 -0
- data/test/fixtures/responses/create_chargeback.xml +12 -0
- data/test/fixtures/responses/create_chargeback_reversal.xml +12 -0
- data/test/fixtures/responses/create_charged_debit_sale.xml +12 -0
- data/test/fixtures/responses/create_debit_chargeback.xml +12 -0
- data/test/fixtures/responses/create_deposit.xml +12 -0
- data/test/fixtures/responses/create_pre_arbitration.xml +12 -0
- data/test/fixtures/responses/create_rejected_debit_sale.xml +12 -0
- data/test/fixtures/responses/create_retrieval_request.xml +12 -0
- data/test/fixtures/responses/debit_sale.xml +12 -0
- data/test/fixtures/responses/direct_pay24_sale.xml +15 -0
- data/test/fixtures/responses/giro_pay_sale.xml +15 -0
- data/test/fixtures/responses/ideal_sale.xml +17 -0
- data/test/fixtures/responses/init_recurring_authorize.xml +14 -0
- data/test/fixtures/responses/init_recurring_debit_authorize.xml +17 -0
- data/test/fixtures/responses/init_recurring_debit_sale.xml +17 -0
- data/test/fixtures/responses/init_recurring_sale.xml +14 -0
- data/test/fixtures/responses/pay_in_advance.xml +17 -0
- data/test/fixtures/responses/pay_pal.xml +15 -0
- data/test/fixtures/responses/pay_safe_card_sale.xml +15 -0
- data/test/fixtures/responses/payment_on_delivery.xml +14 -0
- data/test/fixtures/responses/purchase_on_account.xml +18 -0
- data/test/fixtures/responses/reconcile_by_date_empty_result.xml +3 -0
- data/test/fixtures/responses/reconcile_by_date_page_1.xml +1293 -0
- data/test/fixtures/responses/reconcile_by_date_page_2.xml +1346 -0
- data/test/fixtures/responses/reconcile_by_date_page_3.xml +1394 -0
- data/test/fixtures/responses/reconcile_by_date_single_result.xml +16 -0
- data/test/fixtures/responses/recurring_debit_sale.xml +16 -0
- data/test/fixtures/responses/recurring_event.json +22 -0
- data/test/fixtures/responses/recurring_event.xml +21 -0
- data/test/fixtures/responses/recurring_sale.xml +14 -0
- data/test/fixtures/responses/referenced_fund_transfer.xml +14 -0
- data/test/fixtures/responses/refund.xml +14 -0
- data/test/fixtures/responses/sale.xml +12 -0
- data/test/fixtures/responses/sale3d_async.xml +15 -0
- data/test/fixtures/responses/sale3d_sync.xml +14 -0
- data/test/fixtures/responses/scheduled_transactions_empty.json +8 -0
- data/test/fixtures/responses/scheduled_transactions_one.json +22 -0
- data/test/fixtures/responses/scheduler.json +12 -0
- data/test/fixtures/responses/scheduler_empty_result.json +8 -0
- data/test/fixtures/responses/scheduler_error.json +7 -0
- data/test/fixtures/responses/scheduler_next.json +4 -0
- data/test/fixtures/responses/scheduler_page_1.json +93 -0
- data/test/fixtures/responses/scheduler_page_2.json +45 -0
- data/test/fixtures/responses/scheduler_single_result.json +21 -0
- data/test/fixtures/responses/void.xml +12 -0
- data/test/js/mobile_payment_test.js +287 -0
- data/test/php/all.php +9 -0
- data/test/php/authorize3d_test.php +546 -0
- data/test/php/authorize_test.php +546 -0
- data/test/php/capture_test.php +241 -0
- data/test/php/json_schema_validator_test.php +24 -0
- data/test/php/mobile_payment_test.php +238 -0
- data/test/php/reconcile_test.php +21 -0
- data/test/php/referenced_fund_transfer_test.php +183 -0
- data/test/php/refund_test.php +237 -0
- data/test/php/sale_test.php +546 -0
- data/test/php/test_helper.php +29 -0
- data/test/php/void_test.php +163 -0
- data/test/php/wpf_payment_test.php +19 -0
- data/test/ruby/authorize3d_async_spec.rb +29 -0
- data/test/ruby/authorize3d_sync_spec.rb +27 -0
- data/test/ruby/authorize_spec.rb +25 -0
- data/test/ruby/capture_spec.rb +16 -0
- data/test/ruby/debit_sale_spec.rb +26 -0
- data/test/ruby/direct_pay24_sale_spec.rb +30 -0
- data/test/ruby/giro_pay_sale_spec.rb +30 -0
- data/test/ruby/ideal_sale_spec.rb +29 -0
- data/test/ruby/init_recurring_authorize_spec.rb +26 -0
- data/test/ruby/init_recurring_debit_authorize_spec.rb +27 -0
- data/test/ruby/init_recurring_debit_sale_spec.rb +27 -0
- data/test/ruby/init_recurring_sale_spec.rb +26 -0
- data/test/ruby/mobile_payment_spec.rb +22 -0
- data/test/ruby/pay_in_advance_spec.rb +23 -0
- data/test/ruby/pay_pal_spec.rb +25 -0
- data/test/ruby/pay_safe_card_sale_spec.rb +24 -0
- data/test/ruby/payment_on_delivery_spec.rb +21 -0
- data/test/ruby/purchase_on_account_spec.rb +23 -0
- data/test/ruby/reconcile_spec.rb +11 -0
- data/test/ruby/recurring_debit_sale_spec.rb +17 -0
- data/test/ruby/recurring_sale_spec.rb +17 -0
- data/test/ruby/referenced_fund_transfer_spec.rb +17 -0
- data/test/ruby/refund_spec.rb +16 -0
- data/test/ruby/sale3d_async_spec.rb +29 -0
- data/test/ruby/sale3d_sync_spec.rb +27 -0
- data/test/ruby/sale_spec.rb +25 -0
- data/test/ruby/scheduler_spec.rb +43 -0
- data/test/ruby/test_helper.rb +74 -0
- data/test/ruby/types_specs.rb +1494 -0
- data/test/ruby/void_spec.rb +14 -0
- data/test/ruby/wpf_payment_spec.rb +27 -0
- metadata +527 -0
@@ -0,0 +1,241 @@
|
|
1
|
+
<?php
|
2
|
+
require_once 'test_helper.php';
|
3
|
+
|
4
|
+
class capture_Test extends SchemaTestCase {
|
5
|
+
|
6
|
+
function __construct() {
|
7
|
+
parent::__construct('capture');
|
8
|
+
$this->jsonData = $this->fixture('capture.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('capture', $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 = 'sale';
|
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->assertNotValid();
|
190
|
+
}
|
191
|
+
function testRemoteIp_127_0_0_1() {
|
192
|
+
$this->trx->remote_ip = "127.0.0.1";
|
193
|
+
$this->assertNotValid();
|
194
|
+
}
|
195
|
+
function testRemoteIp255_255_255_255() {
|
196
|
+
$this->trx->remote_ip = "255.255.255.255";
|
197
|
+
$this->assertNotValid();
|
198
|
+
}
|
199
|
+
function testRemoteIp_0() {
|
200
|
+
$this->trx->remote_ip = "0";
|
201
|
+
$this->assertNotValid();
|
202
|
+
}
|
203
|
+
function testRemoteIpMissing() {
|
204
|
+
unset($this->trx->remote_ip);
|
205
|
+
$this->assertValid();
|
206
|
+
}
|
207
|
+
|
208
|
+
function testRefenrenceIdRequired() {
|
209
|
+
unset($this->trx->reference_id);
|
210
|
+
$this->assertNotValid();
|
211
|
+
}
|
212
|
+
function testRefenrenceIdEmpty() {
|
213
|
+
$this->trx->reference_id = '';
|
214
|
+
$this->assertNotValid();
|
215
|
+
}
|
216
|
+
function testRefenrenceIdBlank() {
|
217
|
+
$this->trx->reference_id = str_repeat(' ', 32);
|
218
|
+
$this->assertNotValid();
|
219
|
+
}
|
220
|
+
function testRefenrenceId_31_chars() {
|
221
|
+
$this->trx->reference_id = str_repeat('a', 31);
|
222
|
+
$this->assertNotValid();
|
223
|
+
}
|
224
|
+
function testRefenrenceId_32_chars() {
|
225
|
+
$this->trx->reference_id = str_repeat('a', 32);
|
226
|
+
$this->assertValid();
|
227
|
+
}
|
228
|
+
function testRefenrenceId_33_chars() {
|
229
|
+
$this->trx->reference_id = str_repeat('a', 33);
|
230
|
+
$this->assertNotValid();
|
231
|
+
}
|
232
|
+
function testRefenrenceId_255_chars() {
|
233
|
+
$this->trx->reference_id = str_repeat('a', 256);
|
234
|
+
$this->assertNotValid();
|
235
|
+
}
|
236
|
+
|
237
|
+
function testRiskParamsNotAllowed() {
|
238
|
+
$this->trx->risk_params = json_decode($this->fixture('risk_params.json'));
|
239
|
+
$this->assertNotValid();
|
240
|
+
}
|
241
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?php
|
2
|
+
require_once dirname(dirname(__DIR__)).'/vendor/autoload.php';
|
3
|
+
require_once dirname(dirname(__DIR__)).'/vendor/vierbergenlars/simpletest/autorun.php';
|
4
|
+
|
5
|
+
class JsonSchemaValidatorTest extends UnitTestCase {
|
6
|
+
|
7
|
+
function testSchemaPathForSale() {
|
8
|
+
$file = \Hypercharge\JsonSchemaValidator::schemaPathFor('sale');
|
9
|
+
$this->assertPattern('|/json/sale.json$|', $file);
|
10
|
+
$this->assertTrue(file_exists($file), "file: $file");
|
11
|
+
}
|
12
|
+
|
13
|
+
function testSchemaPathForWpfPayment() {
|
14
|
+
$file = \Hypercharge\JsonSchemaValidator::schemaPathFor('WpfPayment');
|
15
|
+
$this->assertPattern('|/json/WpfPayment.json$|', $file);
|
16
|
+
$this->assertTrue(file_exists($file), "file: $file");
|
17
|
+
}
|
18
|
+
|
19
|
+
function testSchemaPathForWrongType() {
|
20
|
+
$file = \Hypercharge\JsonSchemaValidator::schemaPathFor('wrong_type');
|
21
|
+
$this->assertPattern('|/json/wrong_type.json$|', $file);
|
22
|
+
$this->assertTrue(! file_exists($file), "file does exist but should not: $file");
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,238 @@
|
|
1
|
+
<?php
|
2
|
+
require_once 'test_helper.php';
|
3
|
+
|
4
|
+
class MobilePaymentTest extends SchemaTestCase {
|
5
|
+
|
6
|
+
function __construct() {
|
7
|
+
parent::__construct('MobilePayment');
|
8
|
+
$this->jsonData = $this->fixture('MobilePayment.json');
|
9
|
+
}
|
10
|
+
|
11
|
+
function setUp() {
|
12
|
+
$this->data = json_decode($this->jsonData);
|
13
|
+
$this->payment = $this->data->payment;
|
14
|
+
}
|
15
|
+
|
16
|
+
function testFixtureShouldValidate() {
|
17
|
+
$this->assertValid();
|
18
|
+
}
|
19
|
+
|
20
|
+
function testWrongRootNode() {
|
21
|
+
$o = new stdClass;
|
22
|
+
$o->wrong_root_node = $this->payment;
|
23
|
+
$this->assertNotValid($o);
|
24
|
+
}
|
25
|
+
|
26
|
+
function testAdditionalRootNode() {
|
27
|
+
$this->data->additional_node = 'foo';
|
28
|
+
$this->assertNotValid();
|
29
|
+
}
|
30
|
+
function testAdditionalPaymentNode() {
|
31
|
+
$this->data->payment->additional_node = 'foo';
|
32
|
+
$this->assertNotValid();
|
33
|
+
}
|
34
|
+
|
35
|
+
function testAmount1() {
|
36
|
+
$this->payment->amount = 1;
|
37
|
+
$this->assertValid();
|
38
|
+
}
|
39
|
+
function testAmount1000000000() {
|
40
|
+
$this->payment->amount = 1000000000;
|
41
|
+
$this->assertValid();
|
42
|
+
}
|
43
|
+
function testAmountMissing() {
|
44
|
+
unset($this->payment->amount);
|
45
|
+
$this->assertNotValid();
|
46
|
+
}
|
47
|
+
function testAmount1dot2() {
|
48
|
+
$this->payment->amount = 1.2;
|
49
|
+
$this->assertNotValid();
|
50
|
+
}
|
51
|
+
function testAmount0() {
|
52
|
+
$this->payment->amount = 0;
|
53
|
+
$this->assertNotValid();
|
54
|
+
}
|
55
|
+
function testAmountMinus1() {
|
56
|
+
$this->payment->amount = -1;
|
57
|
+
$this->assertNotValid();
|
58
|
+
}
|
59
|
+
function testAmountMinus1dot2() {
|
60
|
+
$this->payment->amount = -1.2;
|
61
|
+
$this->assertNotValid();
|
62
|
+
}
|
63
|
+
function testAmountFoo() {
|
64
|
+
$this->payment->amount = 'foo';
|
65
|
+
$this->assertNotValid();
|
66
|
+
}
|
67
|
+
|
68
|
+
function testCurrencyEUR() {
|
69
|
+
$this->payment->currency = 'EUR';
|
70
|
+
$this->assertValid();
|
71
|
+
}
|
72
|
+
function testCurrencyUSD() {
|
73
|
+
$this->payment->currency = 'USD';
|
74
|
+
$this->assertValid();
|
75
|
+
}
|
76
|
+
function testCurrencyMissing() {
|
77
|
+
unset($this->payment->currency);
|
78
|
+
$this->assertNotValid();
|
79
|
+
}
|
80
|
+
function testCurrencyEmptyString() {
|
81
|
+
$this->payment->currency = '';
|
82
|
+
$this->assertNotValid();
|
83
|
+
}
|
84
|
+
function testCurrencyEuroSign() {
|
85
|
+
$this->payment->currency = '€';
|
86
|
+
$this->assertNotValid();
|
87
|
+
}
|
88
|
+
function testCurrencyDollarSign() {
|
89
|
+
$this->payment->currency = '$';
|
90
|
+
$this->assertNotValid();
|
91
|
+
}
|
92
|
+
function testCurrencyXXX() {
|
93
|
+
$this->payment->currency = 'XXX';
|
94
|
+
$this->assertNotValid();
|
95
|
+
}
|
96
|
+
function testCurrency0() {
|
97
|
+
$this->payment->currency = 0;
|
98
|
+
$this->assertNotValid();
|
99
|
+
}
|
100
|
+
|
101
|
+
function testNotificationUrlValidHttp() {
|
102
|
+
$this->payment->notification_url = 'http://test-server.de/hypercharge/payment-notification.php';
|
103
|
+
$this->assertValid();
|
104
|
+
}
|
105
|
+
function testNotificationUrlValidHttps() {
|
106
|
+
$this->payment->notification_url = 'https://test-server.de/hypercharge/payment-notification.php';
|
107
|
+
$this->assertValid();
|
108
|
+
}
|
109
|
+
function testNotificationUrlMissing() {
|
110
|
+
unset($this->payment->notification_url);
|
111
|
+
$this->assertNotValid();
|
112
|
+
}
|
113
|
+
function testNotificationUrlEmpty() {
|
114
|
+
$this->payment->notification_url = '';
|
115
|
+
$this->assertNotValid();
|
116
|
+
}
|
117
|
+
function testNotificationUrl77() {
|
118
|
+
$this->payment->notification_url = 77;
|
119
|
+
$this->assertNotValid();
|
120
|
+
}
|
121
|
+
function testNotificationUrlFileUri() {
|
122
|
+
$this->payment->notification_url = 'file:///Home/homer/simpson.txt';
|
123
|
+
$this->assertNotValid();
|
124
|
+
}
|
125
|
+
function testNotificationUrlShort() {
|
126
|
+
$this->payment->notification_url = 'http://';
|
127
|
+
$this->assertNotValid();
|
128
|
+
}
|
129
|
+
|
130
|
+
function testTransactionIdHex() {
|
131
|
+
$this->payment->transaction_id = '1234efdaf32102423ad5f';
|
132
|
+
$this->assertValid();
|
133
|
+
}
|
134
|
+
function testTransactionHexDashDot() {
|
135
|
+
$this->payment->transaction_id = '1234efd-af3.210-2423ad5f';
|
136
|
+
$this->assertValid();
|
137
|
+
}
|
138
|
+
|
139
|
+
function testBillingAddressNull() {
|
140
|
+
$this->payment->billing_address = null;
|
141
|
+
$this->assertNotValid();
|
142
|
+
}
|
143
|
+
function testBillingAddressMissing() {
|
144
|
+
unset($this->payment->billing_address);
|
145
|
+
$this->assertValid();
|
146
|
+
}
|
147
|
+
function testBillingAddress_FirstNameMissing() {
|
148
|
+
unset($this->payment->billing_address->first_name);
|
149
|
+
$this->assertNotValid();
|
150
|
+
}
|
151
|
+
function testBillingAddress_FirstNameBlank() {
|
152
|
+
$this->payment->billing_address->first_name = '';
|
153
|
+
$this->assertNotValid();
|
154
|
+
}
|
155
|
+
function testBillingAddress_LastNameMissing() {
|
156
|
+
unset($this->payment->billing_address->last_name);
|
157
|
+
$this->assertNotValid();
|
158
|
+
}
|
159
|
+
function testBillingAddress_LastNameBlank() {
|
160
|
+
$this->payment->billing_address->last_name = '';
|
161
|
+
$this->assertNotValid();
|
162
|
+
}
|
163
|
+
function testBillingAddress_Address1Missing() {
|
164
|
+
unset($this->payment->billing_address->address1);
|
165
|
+
$this->assertNotValid();
|
166
|
+
}
|
167
|
+
function testBillingAddress_Address1Blank() {
|
168
|
+
$this->payment->billing_address->address1 = '';
|
169
|
+
$this->assertNotValid();
|
170
|
+
}
|
171
|
+
function testBillingAddress_Address2Missing() {
|
172
|
+
unset($this->payment->billing_address->address2);
|
173
|
+
$this->assertValid();
|
174
|
+
}
|
175
|
+
function testBillingAddress_Address2Blank() {
|
176
|
+
$this->payment->billing_address->address2 = '';
|
177
|
+
$this->assertNotValid();
|
178
|
+
}
|
179
|
+
function testBillingAddress_CityMissing() {
|
180
|
+
unset($this->payment->billing_address->city);
|
181
|
+
$this->assertNotValid();
|
182
|
+
}
|
183
|
+
function testBillingAddress_CityBlank() {
|
184
|
+
$this->payment->billing_address->city = '';
|
185
|
+
$this->assertNotValid();
|
186
|
+
}
|
187
|
+
function testBillingAddress_ZipCodeMissing() {
|
188
|
+
unset($this->payment->billing_address->zip_code);
|
189
|
+
$this->assertNotValid();
|
190
|
+
}
|
191
|
+
function testBillingAddress_ZipCodeBlank() {
|
192
|
+
$this->payment->billing_address->zip_code = '';
|
193
|
+
$this->assertNotValid();
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
function testBillingAddress_StateAA() {
|
198
|
+
$this->payment->billing_address->state = 'AA';
|
199
|
+
$this->assertValid();
|
200
|
+
}
|
201
|
+
function testBillingAddress_StateLowercase() {
|
202
|
+
$this->payment->billing_address->state = 'aa';
|
203
|
+
$this->assertNotValid();
|
204
|
+
}
|
205
|
+
function testBillingAddress_StateWrong() {
|
206
|
+
$this->payment->billing_address->state = 'XX';
|
207
|
+
$this->assertNotValid();
|
208
|
+
}
|
209
|
+
function testBillingAddress_StateMissing() {
|
210
|
+
unset($this->payment->billing_address->state);
|
211
|
+
$this->assertValid();
|
212
|
+
}
|
213
|
+
function testBillingAddress_StateBlank() {
|
214
|
+
$this->payment->billing_address->state = '';
|
215
|
+
$this->assertNotValid();
|
216
|
+
}
|
217
|
+
|
218
|
+
function testBillingAddress_CountryUS() {
|
219
|
+
$this->payment->billing_address->country = 'US';
|
220
|
+
$this->assertValid();
|
221
|
+
}
|
222
|
+
function testBillingAddress_CountryLowercase() {
|
223
|
+
$this->payment->billing_address->country = 'us';
|
224
|
+
$this->assertNotValid();
|
225
|
+
}
|
226
|
+
function testBillingAddress_CountryWrong() {
|
227
|
+
$this->payment->billing_address->country = 'XX';
|
228
|
+
$this->assertNotValid();
|
229
|
+
}
|
230
|
+
function testBillingAddress_CountryMissing() {
|
231
|
+
unset($this->payment->billing_address->country);
|
232
|
+
$this->assertNotValid();
|
233
|
+
}
|
234
|
+
function testBillingAddress_CountryBlank() {
|
235
|
+
$this->payment->billing_address->country = '';
|
236
|
+
$this->assertNotValid();
|
237
|
+
}
|
238
|
+
}
|