offsite_payments 2.7.24 → 2.7.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c97ad87cccef24116fe87f91ee89b4b9b407eb45d3e495de18ba2a1b5e33a0c0
|
|
4
|
+
data.tar.gz: 1dd21e00bcb3a717c04da06c9fa3052010f10e326809fe7582f89f3264476424
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acb62c7c223c6e07c47b8c911745feec5cbf7d31e1ce735519af0623f72cb4c2286ecc56facf46f0af14d4f18614d3715d80c57c4cb0b8b862f245c747df7d22
|
|
7
|
+
data.tar.gz: dc0c0a7871376e7496c9bcf4aff180c4c305f2ad85e827388b45f0634607310bf1c93c32c0364eb1ddd6b6f3032cbc858499ee50c7d31ce6afae8b6fe9c1d40a
|
|
@@ -34,9 +34,9 @@ module OffsitePayments #:nodoc:
|
|
|
34
34
|
|
|
35
35
|
module Common
|
|
36
36
|
def generate_signature_string
|
|
37
|
-
@raw_post.slice!(0) if @raw_post.
|
|
37
|
+
@raw_post.slice!(0) if @raw_post.start_with?("&")
|
|
38
38
|
@raw_post = CGI.unescape(@raw_post)
|
|
39
|
-
@raw_post = "&#{@raw_post}" unless @raw_post.
|
|
39
|
+
@raw_post = "&#{@raw_post}" unless @raw_post.start_with?("&")
|
|
40
40
|
arr = @raw_post.split('&')
|
|
41
41
|
arr.delete(arr.last)
|
|
42
42
|
data = arr.join('&')
|
|
@@ -141,6 +141,256 @@ module OffsitePayments #:nodoc:
|
|
|
141
141
|
'WY' => 'Wyoming'
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
COUNTRY_PHONE_NUMBERS = {
|
|
145
|
+
'AD' => { :code => '376', :length => [6, 7, 8, 9] },
|
|
146
|
+
'AE' => { :code => '971', :length => [7, 8, 9] },
|
|
147
|
+
'AF' => { :code => '93', :length => [8, 9] },
|
|
148
|
+
'AG' => { :code => '1', :length => [10] },
|
|
149
|
+
'AI' => { :code => '1', :length => [10] },
|
|
150
|
+
'AL' => { :code => '355', :length => [7, 8, 9] },
|
|
151
|
+
'AM' => { :code => '374', :length => [8] },
|
|
152
|
+
'AO' => { :code => '244', :length => [9] },
|
|
153
|
+
'AQ' => { :code => '672', :length => [] },
|
|
154
|
+
'AR' => { :code => '54', :length => [8, 9] },
|
|
155
|
+
'AS' => { :code => '1', :length => [10] },
|
|
156
|
+
'AT' => { :code => '43', :length => [7, 8, 9, 10, 11, 12, 13] },
|
|
157
|
+
'AU' => { :code => '61', :length => [9] },
|
|
158
|
+
'AW' => { :code => '297', :length => [7] },
|
|
159
|
+
'AX' => { :code => '358', :length => [] },
|
|
160
|
+
'AZ' => { :code => '994', :length => [8, 9] },
|
|
161
|
+
'BA' => { :code => '387', :length => [8] },
|
|
162
|
+
'BB' => { :code => '1', :length => [10] },
|
|
163
|
+
'BD' => { :code => '880', :length => [10] },
|
|
164
|
+
'BE' => { :code => '32', :length => [8, 9] },
|
|
165
|
+
'BF' => { :code => '226', :length => [8] },
|
|
166
|
+
'BG' => { :code => '359', :length => [8, 9, 10] },
|
|
167
|
+
'BH' => { :code => '973', :length => [8] },
|
|
168
|
+
'BI' => { :code => '257', :length => [8] },
|
|
169
|
+
'BJ' => { :code => '229', :length => [8] },
|
|
170
|
+
'BL' => { :code => '590', :length => [] },
|
|
171
|
+
'BM' => { :code => '1', :length => [10] },
|
|
172
|
+
'BN' => { :code => '673', :length => [7] },
|
|
173
|
+
'BO' => { :code => '591', :length => [8] },
|
|
174
|
+
'BQ' => { :code => '599', :length => [7] },
|
|
175
|
+
'BR' => { :code => '55', :length => [10, 11] },
|
|
176
|
+
'BS' => { :code => '1', :length => [10] },
|
|
177
|
+
'BT' => { :code => '975', :length => [7, 8] },
|
|
178
|
+
'BV' => { :code => '47', :length => [] },
|
|
179
|
+
'BW' => { :code => '267', :length => [7] },
|
|
180
|
+
'BY' => { :code => '375', :length => [9] },
|
|
181
|
+
'BZ' => { :code => '501', :length => [7] },
|
|
182
|
+
'CA' => { :code => '1', :length => [10] },
|
|
183
|
+
'CC' => { :code => '61', :length => [9] },
|
|
184
|
+
'CD' => { :code => '243', :length => [8] },
|
|
185
|
+
'CF' => { :code => '236', :length => [8] },
|
|
186
|
+
'CG' => { :code => '242', :length => [7] },
|
|
187
|
+
'CH' => { :code => '41', :length => [9, 10] },
|
|
188
|
+
'CI' => { :code => '225', :length => [8] },
|
|
189
|
+
'CK' => { :code => '682', :length => [5] },
|
|
190
|
+
'CL' => { :code => '56', :length => [8, 9] },
|
|
191
|
+
'CM' => { :code => '237', :length => [8] },
|
|
192
|
+
'CN' => { :code => '86', :length => [7, 8, 9, 10, 11] },
|
|
193
|
+
'CO' => { :code => '57', :length => [9, 10] },
|
|
194
|
+
'CR' => { :code => '506', :length => [8] },
|
|
195
|
+
'CU' => { :code => '53', :length => [8] },
|
|
196
|
+
'CV' => { :code => '238', :length => [7] },
|
|
197
|
+
'CW' => { :code => '599', :length => [7] },
|
|
198
|
+
'CX' => { :code => '61', :length => [] },
|
|
199
|
+
'CY' => { :code => '357', :length => [8] },
|
|
200
|
+
'CZ' => { :code => '420', :length => [9] },
|
|
201
|
+
'DE' => { :code => '49', :length => [6, 7, 8, 9, 10, 11] },
|
|
202
|
+
'DJ' => { :code => '253', :length => [6] },
|
|
203
|
+
'DK' => { :code => '45', :length => [8] },
|
|
204
|
+
'DM' => { :code => '1', :length => [10] },
|
|
205
|
+
'DO' => { :code => '1', :length => [10] },
|
|
206
|
+
'DZ' => { :code => '213', :length => [8] },
|
|
207
|
+
'EC' => { :code => '593', :length => [8, 9] },
|
|
208
|
+
'EE' => { :code => '372', :length => [7, 8] },
|
|
209
|
+
'EG' => { :code => '20', :length => [9] },
|
|
210
|
+
'EH' => { :code => '212', :length => [] },
|
|
211
|
+
'ER' => { :code => '291', :length => [7] },
|
|
212
|
+
'ES' => { :code => '34', :length => [9] },
|
|
213
|
+
'ET' => { :code => '251', :length => [9] },
|
|
214
|
+
'FI' => { :code => '358', :length => [9] },
|
|
215
|
+
'FJ' => { :code => '679', :length => [7] },
|
|
216
|
+
'FK' => { :code => '500', :length => [5] },
|
|
217
|
+
'FM' => { :code => '691', :length => [7] },
|
|
218
|
+
'FO' => { :code => '298', :length => [6] },
|
|
219
|
+
'FR' => { :code => '33', :length => [9, 10] },
|
|
220
|
+
'GA' => { :code => '241', :length => [6, 7, 8] },
|
|
221
|
+
'GB' => { :code => '44', :length => [10, 11] },
|
|
222
|
+
'GD' => { :code => '1', :length => [10] },
|
|
223
|
+
'GE' => { :code => '995', :length => [9] },
|
|
224
|
+
'GF' => { :code => '594', :length => [10] },
|
|
225
|
+
'GG' => { :code => '44', :length => [] },
|
|
226
|
+
'GH' => { :code => '233', :length => [5, 6, 7, 8] },
|
|
227
|
+
'GI' => { :code => '350', :length => [8] },
|
|
228
|
+
'GL' => { :code => '299', :length => [6] },
|
|
229
|
+
'GM' => { :code => '220', :length => [7] },
|
|
230
|
+
'GN' => { :code => '224', :length => [8] },
|
|
231
|
+
'GP' => { :code => '590', :length => [10] },
|
|
232
|
+
'GQ' => { :code => '240', :length => [6] },
|
|
233
|
+
'GR' => { :code => '30', :length => [10] },
|
|
234
|
+
'GS' => { :code => '500', :length => [] },
|
|
235
|
+
'GT' => { :code => '502', :length => [8] },
|
|
236
|
+
'GU' => { :code => '1', :length => [10] },
|
|
237
|
+
'GW' => { :code => '245', :length => [7] },
|
|
238
|
+
'GY' => { :code => '592', :length => [6, 7] },
|
|
239
|
+
'HK' => { :code => '852', :length => [8] },
|
|
240
|
+
'HN' => { :code => '504', :length => [7, 8] },
|
|
241
|
+
'HR' => { :code => '385', :length => [8] },
|
|
242
|
+
'HT' => { :code => '509', :length => [8] },
|
|
243
|
+
'HU' => { :code => '36', :length => [8, 9] },
|
|
244
|
+
'ID' => { :code => '62', :length => [8, 9, 10, 11] },
|
|
245
|
+
'IE' => { :code => '353', :length => [9] },
|
|
246
|
+
'IL' => { :code => '972', :length => [7, 8, 9] },
|
|
247
|
+
'IM' => { :code => '44', :length => [] },
|
|
248
|
+
'IN' => { :code => '91', :length => [10] },
|
|
249
|
+
'IO' => { :code => '246', :length => [] },
|
|
250
|
+
'IQ' => { :code => '964', :length => [8, 9, 10] },
|
|
251
|
+
'IR' => { :code => '98', :length => [10] },
|
|
252
|
+
'IS' => { :code => '354', :length => [7, 8, 9] },
|
|
253
|
+
'IT' => { :code => '39', :length => [9, 11] },
|
|
254
|
+
'JE' => { :code => '44', :length => [] },
|
|
255
|
+
'JM' => { :code => '1', :length => [10] },
|
|
256
|
+
'JO' => { :code => '962', :length => [8, 9] },
|
|
257
|
+
'JP' => { :code => '81', :length => [9, 10] },
|
|
258
|
+
'KE' => { :code => '254', :length => [9] },
|
|
259
|
+
'KG' => { :code => '996', :length => [9] },
|
|
260
|
+
'KH' => { :code => '855', :length => [8] },
|
|
261
|
+
'KI' => { :code => '686', :length => [5] },
|
|
262
|
+
'KM' => { :code => '269', :length => [7] },
|
|
263
|
+
'KN' => { :code => '1', :length => [10] },
|
|
264
|
+
'KP' => { :code => '850', :length => [8, 9] },
|
|
265
|
+
'KR' => { :code => '82', :length => [8, 9] },
|
|
266
|
+
'KW' => { :code => '965', :length => [7] },
|
|
267
|
+
'KY' => { :code => '1', :length => [10] },
|
|
268
|
+
'KZ' => { :code => '7', :length => [10] },
|
|
269
|
+
'LA' => { :code => '856', :length => [8] },
|
|
270
|
+
'LB' => { :code => '961', :length => [8] },
|
|
271
|
+
'LC' => { :code => '1', :length => [10] },
|
|
272
|
+
'LI' => { :code => '423', :length => [7] },
|
|
273
|
+
'LK' => { :code => '94', :length => [10] },
|
|
274
|
+
'LR' => { :code => '231', :length => [6, 7, 8] },
|
|
275
|
+
'LS' => { :code => '266', :length => [8] },
|
|
276
|
+
'LT' => { :code => '370', :length => [8] },
|
|
277
|
+
'LU' => { :code => '352', :length => [9] },
|
|
278
|
+
'LV' => { :code => '371', :length => [8] },
|
|
279
|
+
'LY' => { :code => '218', :length => [8, 9] },
|
|
280
|
+
'MA' => { :code => '212', :length => [8] },
|
|
281
|
+
'MC' => { :code => '377', :length => [8, 9] },
|
|
282
|
+
'MD' => { :code => '373', :length => [8] },
|
|
283
|
+
'ME' => { :code => '382', :length => [8] },
|
|
284
|
+
'MF' => { :code => '590', :length => [] },
|
|
285
|
+
'MG' => { :code => '261', :length => [9] },
|
|
286
|
+
'MH' => { :code => '692', :length => [7] },
|
|
287
|
+
'MK' => { :code => '389', :length => [7, 8] },
|
|
288
|
+
'ML' => { :code => '223', :length => [8] },
|
|
289
|
+
'MM' => { :code => '95', :length => [7, 8] },
|
|
290
|
+
'MN' => { :code => '976', :length => [7, 8, 9, 10] },
|
|
291
|
+
'MO' => { :code => '853', :length => [8] },
|
|
292
|
+
'MP' => { :code => '1', :length => [10] },
|
|
293
|
+
'MQ' => { :code => '596', :length => [10] },
|
|
294
|
+
'MR' => { :code => '222', :length => [7] },
|
|
295
|
+
'MS' => { :code => '1', :length => [10] },
|
|
296
|
+
'MT' => { :code => '356', :length => [8] },
|
|
297
|
+
'MU' => { :code => '230', :length => [7] },
|
|
298
|
+
'MV' => { :code => '960', :length => [7] },
|
|
299
|
+
'MW' => { :code => '265', :length => [8] },
|
|
300
|
+
'MX' => { :code => '52', :length => [8, 9, 10] },
|
|
301
|
+
'MY' => { :code => '60', :length => [9, 10] },
|
|
302
|
+
'MZ' => { :code => '258', :length => [8, 9] },
|
|
303
|
+
'NA' => { :code => '264', :length => [6, 7] },
|
|
304
|
+
'NC' => { :code => '687', :length => [6] },
|
|
305
|
+
'NE' => { :code => '227', :length => [8] },
|
|
306
|
+
'NF' => { :code => '672', :length => [6] },
|
|
307
|
+
'NG' => { :code => '234', :length => [7, 8] },
|
|
308
|
+
'NI' => { :code => '505', :length => [8] },
|
|
309
|
+
'NL' => { :code => '31', :length => [9] },
|
|
310
|
+
'NO' => { :code => '47', :length => [8] },
|
|
311
|
+
'NP' => { :code => '977', :length => [7, 8] },
|
|
312
|
+
'NR' => { :code => '674', :length => [7] },
|
|
313
|
+
'NU' => { :code => '683', :length => [4] },
|
|
314
|
+
'NZ' => { :code => '64', :length => [8, 9] },
|
|
315
|
+
'OM' => { :code => '968', :length => [8] },
|
|
316
|
+
'PA' => { :code => '507', :length => [7] },
|
|
317
|
+
'PE' => { :code => '51', :length => [8, 9] },
|
|
318
|
+
'PF' => { :code => '689', :length => [6] },
|
|
319
|
+
'PG' => { :code => '675', :length => [7] },
|
|
320
|
+
'PH' => { :code => '63', :length => [8, 9, 10] },
|
|
321
|
+
'PK' => { :code => '92', :length => [9, 10] },
|
|
322
|
+
'PL' => { :code => '48', :length => [9] },
|
|
323
|
+
'PM' => { :code => '508', :length => [6] },
|
|
324
|
+
'PN' => { :code => '64', :length => [9] },
|
|
325
|
+
'PR' => { :code => '1', :length => [10] },
|
|
326
|
+
'PS' => { :code => '970', :length => [8] },
|
|
327
|
+
'PT' => { :code => '351', :length => [9] },
|
|
328
|
+
'PW' => { :code => '680', :length => [7] },
|
|
329
|
+
'PY' => { :code => '595', :length => [9] },
|
|
330
|
+
'QA' => { :code => '974', :length => [7] },
|
|
331
|
+
'RE' => { :code => '262', :length => [10] },
|
|
332
|
+
'RO' => { :code => '40', :length => [9] },
|
|
333
|
+
'RS' => { :code => '381', :length => [9] },
|
|
334
|
+
'RU' => { :code => '7', :length => [10] },
|
|
335
|
+
'RW' => { :code => '250', :length => [8, 9] },
|
|
336
|
+
'SA' => { :code => '966', :length => [8, 9] },
|
|
337
|
+
'SB' => { :code => '677', :length => [5] },
|
|
338
|
+
'SC' => { :code => '248', :length => [6] },
|
|
339
|
+
'SD' => { :code => '249', :length => [9] },
|
|
340
|
+
'SE' => { :code => '46', :length => [9] },
|
|
341
|
+
'SG' => { :code => '65', :length => [8, 9] },
|
|
342
|
+
'SH' => { :code => '290', :length => [4] },
|
|
343
|
+
'SI' => { :code => '386', :length => [8] },
|
|
344
|
+
'SJ' => { :code => '47', :length => [8] },
|
|
345
|
+
'SK' => { :code => '421', :length => [9] },
|
|
346
|
+
'SL' => { :code => '232', :length => [8] },
|
|
347
|
+
'SM' => { :code => '378', :length => [9, 10, 11, 12] },
|
|
348
|
+
'SN' => { :code => '221', :length => [7] },
|
|
349
|
+
'SO' => { :code => '252', :length => [7, 8] },
|
|
350
|
+
'SR' => { :code => '597', :length => [6] },
|
|
351
|
+
'SS' => { :code => '211', :length => [9] },
|
|
352
|
+
'ST' => { :code => '239', :length => [6, 7] },
|
|
353
|
+
'SV' => { :code => '503', :length => [8] },
|
|
354
|
+
'SX' => { :code => '1', :length => [10] },
|
|
355
|
+
'SY' => { :code => '963', :length => [7, 8] },
|
|
356
|
+
'SZ' => { :code => '268', :length => [7] },
|
|
357
|
+
'TC' => { :code => '1', :length => [10] },
|
|
358
|
+
'TD' => { :code => '235', :length => [7] },
|
|
359
|
+
'TF' => { :code => '262', :length => [] },
|
|
360
|
+
'TG' => { :code => '228', :length => [7] },
|
|
361
|
+
'TH' => { :code => '66', :length => [9, 10] },
|
|
362
|
+
'TJ' => { :code => '992', :length => [9] },
|
|
363
|
+
'TK' => { :code => '690', :length => [4] },
|
|
364
|
+
'TL' => { :code => '670', :length => [7] },
|
|
365
|
+
'TM' => { :code => '993', :length => [8] },
|
|
366
|
+
'TN' => { :code => '216', :length => [8] },
|
|
367
|
+
'TO' => { :code => '676', :length => [5, 6, 7] },
|
|
368
|
+
'TR' => { :code => '90', :length => [10] },
|
|
369
|
+
'TT' => { :code => '1', :length => [10] },
|
|
370
|
+
'TV' => { :code => '688', :length => [5] },
|
|
371
|
+
'TW' => { :code => '886', :length => [7, 8] },
|
|
372
|
+
'TZ' => { :code => '255', :length => [9] },
|
|
373
|
+
'UA' => { :code => '380', :length => [8, 9] },
|
|
374
|
+
'UG' => { :code => '256', :length => [9] },
|
|
375
|
+
'UM' => { :code => '1', :length => [] },
|
|
376
|
+
'US' => { :code => '1', :length => [10] },
|
|
377
|
+
'UY' => { :code => '598', :length => [7, 8] },
|
|
378
|
+
'UZ' => { :code => '998', :length => [9] },
|
|
379
|
+
'VA' => { :code => '39', :length => [9] },
|
|
380
|
+
'VC' => { :code => '1', :length => [10] },
|
|
381
|
+
'VE' => { :code => '58', :length => [10] },
|
|
382
|
+
'VG' => { :code => '1', :length => [10] },
|
|
383
|
+
'VI' => { :code => '1', :length => [10] },
|
|
384
|
+
'VN' => { :code => '84', :length => [7, 8, 9, 10] },
|
|
385
|
+
'VU' => { :code => '678', :length => [5, 6, 7] },
|
|
386
|
+
'WF' => { :code => '681', :length => [6] },
|
|
387
|
+
'WS' => { :code => '685', :length => [6, 7] },
|
|
388
|
+
'YE' => { :code => '967', :length => [7, 8, 9] },
|
|
389
|
+
'YT' => { :code => '262', :length => [7] },
|
|
390
|
+
'ZA' => { :code => '27', :length => [9] },
|
|
391
|
+
'ZM' => { :code => '260', :length => [9] },
|
|
392
|
+
'ZW' => { :code => '263', :length => [8, 9, 10, 11] }
|
|
393
|
+
}
|
|
144
394
|
|
|
145
395
|
def create_signature(fields, secret)
|
|
146
396
|
data = fields.join('.')
|
|
@@ -171,27 +421,65 @@ module OffsitePayments #:nodoc:
|
|
|
171
421
|
value.scan(/\d+/).join('')
|
|
172
422
|
end
|
|
173
423
|
|
|
424
|
+
# This method is used for generating the "BILLING_CODE" field,
|
|
425
|
+
# this field is generated by concatenating the zip field and
|
|
426
|
+
# the first line of address with a pipe(|) between them
|
|
427
|
+
# if the country is GB, we remove the non-numeric characters
|
|
174
428
|
def extract_avs_code(params={})
|
|
175
|
-
|
|
429
|
+
return unless params[:zip] && params[:address1]
|
|
430
|
+
code = [params[:zip], params[:address1]]
|
|
431
|
+
code = code.collect{|p| extract_digits(p) } if params[:country] == 'GB'
|
|
432
|
+
code.reject{|p| p.empty? }.join('|')
|
|
176
433
|
end
|
|
177
434
|
|
|
178
435
|
def extract_address_match_indicator(value)
|
|
179
436
|
value ? 'TRUE' : 'FALSE'
|
|
180
437
|
end
|
|
181
438
|
|
|
439
|
+
def adjust_phone_number_length(country_calling_code, phone_number)
|
|
440
|
+
country_calling_code[0...3] + '|' + phone_number[0...15]
|
|
441
|
+
end
|
|
442
|
+
|
|
182
443
|
# The home phone number provided by the Cardholder. Should be In format:
|
|
183
444
|
# of 'CountryCallingCode|Number' for example, '1|123456789'.
|
|
184
|
-
def format_phone_number(phone_number)
|
|
445
|
+
def format_phone_number(phone_number, country_code)
|
|
185
446
|
return nil if phone_number.nil?
|
|
186
447
|
|
|
187
|
-
|
|
448
|
+
country_number = COUNTRY_PHONE_NUMBERS[country_code] || { :code => '0', :length => [] }
|
|
449
|
+
|
|
450
|
+
# Remove non-digit characters
|
|
451
|
+
processed_number = phone_number.gsub(/\D/, '')
|
|
452
|
+
return '0|0' if [[], ['0']].include? processed_number.chars.uniq
|
|
188
453
|
|
|
189
|
-
|
|
454
|
+
# Allow Italy and Ivory Coast to have leading zero, as they use it as a part of some phone numbers
|
|
455
|
+
if ['IT', 'CI'].include?(country_code) && /\A0[1-9]\d*/.match(processed_number)
|
|
456
|
+
return adjust_phone_number_length(country_number[:code], processed_number)
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
return '0|0' if processed_number == country_number[:code]
|
|
460
|
+
|
|
461
|
+
# Remove leading zero(s)
|
|
462
|
+
processed_number = processed_number.gsub(/\A0*/, '')
|
|
463
|
+
|
|
464
|
+
# Check if the potential Singapore calling code is not the local prefix
|
|
465
|
+
if country_code == 'SG' &&
|
|
466
|
+
processed_number.start_with?(country_number[:code]) &&
|
|
467
|
+
country_number[:length].include?(processed_number.length)
|
|
468
|
+
then
|
|
469
|
+
return adjust_phone_number_length(country_number[:code], processed_number)
|
|
470
|
+
end
|
|
190
471
|
|
|
191
|
-
|
|
192
|
-
|
|
472
|
+
# Remove country calling code from the processed number and try to fix trivial mistakes
|
|
473
|
+
if processed_number.start_with?(country_number[:code]) ||
|
|
474
|
+
(!(country_number[:length].include?(processed_number.length)) &&
|
|
475
|
+
country_number[:length].include?(processed_number.length - country_number[:code].length) &&
|
|
476
|
+
(country_number[:code].chars.sort == processed_number[0...country_number[:code].length].chars.sort))
|
|
477
|
+
then
|
|
478
|
+
processed_number = processed_number[country_number[:code].length..-1]
|
|
479
|
+
end
|
|
193
480
|
|
|
194
|
-
|
|
481
|
+
# Limit returned string to 3 characters + | + 15 characters
|
|
482
|
+
adjust_phone_number_length(country_number[:code], processed_number)
|
|
195
483
|
end
|
|
196
484
|
|
|
197
485
|
def lookup_state_code(country_code, state)
|
|
@@ -213,6 +501,48 @@ module OffsitePayments #:nodoc:
|
|
|
213
501
|
add_field("HPP_SHIPPING_#{k.split('HPP_BILLING_')[1]}", v)
|
|
214
502
|
end
|
|
215
503
|
end
|
|
504
|
+
|
|
505
|
+
# Validations
|
|
506
|
+
def get_pattern(key)
|
|
507
|
+
case key
|
|
508
|
+
when 'HPP_CUSTOMER_EMAIL' then /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,24})*$/
|
|
509
|
+
when 'HPP_CUSTOMER_PHONENUMBER_MOBILE' then /^([0-9 +]){1,3}(\|){0,1}([0-9 +]){1,15}$/
|
|
510
|
+
when 'HPP_BILLING_STREET1', 'HPP_SHIPPING_STREET1', 'HPP_BILLING_STREET2', 'HPP_SHIPPING_STREET2' then /^[\p{L}\p{M}\p{Blank}\p{N}\/\.\-\_\'\,]{1,50}$/
|
|
511
|
+
when 'HPP_BILLING_CITY', 'HPP_SHIPPING_CITY' then /^[\p{L}\p{M}\p{Blank}\p{N}\/\.\-\_\'\,]{1,40}$/
|
|
512
|
+
when 'HPP_BILLING_COUNTRY', 'HPP_SHIPPING_COUNTRY' then /^([0-9])*$/
|
|
513
|
+
when 'HPP_BILLING_POSTALCODE', 'HPP_SHIPPING_POSTALCODE' then /^[a-zA-Z0-9\-\s]{1,16}$/
|
|
514
|
+
when 'HPP_BILLING_STATE', 'HPP_SHIPPING_STATE' then /^([A-Z])*$/
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
def get_message(key)
|
|
519
|
+
case key
|
|
520
|
+
when 'HPP_CUSTOMER_EMAIL' then 'Invalid E-mail address.'
|
|
521
|
+
when 'HPP_CUSTOMER_PHONENUMBER_MOBILE' then 'Invalid Telephone. The selected payment method only allows numbers, spaces or punctuation (+, |), and no more than 19 characters.'
|
|
522
|
+
when 'HPP_BILLING_STREET1', 'HPP_SHIPPING_STREET1', 'HPP_BILLING_STREET2', 'HPP_SHIPPING_STREET2' then 'Invalid Street address. The selected payment method only allows letters, numbers, spaces or punctuation, and no more than 50 characters per line.'
|
|
523
|
+
when 'HPP_BILLING_CITY', 'HPP_SHIPPING_CITY' then 'Invalid City. The selected payment method only allows letters, numbers, spaces or punctuation, and no more than 40 characters.'
|
|
524
|
+
when 'HPP_BILLING_COUNTRY', 'HPP_SHIPPING_COUNTRY' then 'Invalid Country code.'
|
|
525
|
+
when 'HPP_BILLING_POSTALCODE', 'HPP_SHIPPING_POSTALCODE' then 'Invalid Zip/Postal Code. The selected payment method only allows letters, numbers, spaces or punctuation, and no more than 16 characters.'
|
|
526
|
+
when 'HPP_BILLING_STATE', 'HPP_SHIPPING_STATE' then 'Invalid State.'
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def validate(key, value)
|
|
531
|
+
pattern = get_pattern(key)
|
|
532
|
+
|
|
533
|
+
return value unless pattern.present?
|
|
534
|
+
|
|
535
|
+
if value =~pattern
|
|
536
|
+
return value
|
|
537
|
+
else
|
|
538
|
+
raise ArgumentError, get_message(key)
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
def add_field(name, value)
|
|
543
|
+
return if name.blank? || value.blank?
|
|
544
|
+
@fields[name.to_s] = validate(name.to_s, value.to_s)
|
|
545
|
+
end
|
|
216
546
|
end
|
|
217
547
|
|
|
218
548
|
class Helper < OffsitePayments::Helper
|
|
@@ -254,32 +584,55 @@ module OffsitePayments #:nodoc:
|
|
|
254
584
|
def billing_address(params={})
|
|
255
585
|
country = params[:country]
|
|
256
586
|
country_code = lookup_country_code(country, :alpha2)
|
|
587
|
+
avs_code = extract_avs_code(params)
|
|
588
|
+
params[:state] = lookup_state_code(country_code, params[:state])
|
|
589
|
+
|
|
257
590
|
super
|
|
258
591
|
|
|
259
|
-
add_field(mappings[:billing_address][:zip], extract_avs_code(params))
|
|
260
592
|
add_field(mappings[:billing_address][:country], lookup_country_code(country))
|
|
593
|
+
add_field(mappings[:billing_address][:code], avs_code)
|
|
594
|
+
|
|
595
|
+
unless ['US', 'CA'].include?(country_code)
|
|
596
|
+
# HPP_BILLING_STATE is required only for US and CA, otherwise is deleted
|
|
597
|
+
@fields.delete_if do |k, _|
|
|
598
|
+
k == 'HPP_BILLING_STATE'
|
|
599
|
+
end
|
|
600
|
+
end
|
|
261
601
|
|
|
262
|
-
if [
|
|
263
|
-
add_field(mappings[:
|
|
602
|
+
if @fields[mappings[:customer][:phone]]
|
|
603
|
+
add_field(mappings[:customer][:phone], format_phone_number(@phone_number, country_code))
|
|
264
604
|
end
|
|
265
605
|
end
|
|
266
606
|
|
|
267
607
|
def shipping_address(params={})
|
|
268
608
|
country = params[:country]
|
|
269
609
|
country_code = lookup_country_code(country, :alpha2)
|
|
610
|
+
params[:state] = lookup_state_code(country_code, params[:state])
|
|
611
|
+
|
|
270
612
|
super
|
|
271
613
|
|
|
272
|
-
add_field(mappings[:shipping_address][:
|
|
273
|
-
|
|
614
|
+
add_field(mappings[:shipping_address][:country], lookup_country_code(country))
|
|
615
|
+
# the mapping for 'SHIPPING_CODE' field, which has the same value as the 'HPP_SHIPPING_POSTALCODE'
|
|
616
|
+
add_field(mappings[:shipping_address][:code], params[:zip])
|
|
274
617
|
|
|
275
|
-
|
|
276
|
-
|
|
618
|
+
unless ['US', 'CA'].include?(country_code)
|
|
619
|
+
# HPP_SHIPPING_STATE is required only for US and CA, otherwise is deleted
|
|
620
|
+
@fields.delete_if do |k, _|
|
|
621
|
+
k == 'HPP_SHIPPING_STATE'
|
|
622
|
+
end
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
if @fields[mappings[:customer][:phone]]&.[](0..1) == '0|'
|
|
626
|
+
add_field(mappings[:customer][:phone], format_phone_number(@phone_number, country_code))
|
|
277
627
|
end
|
|
278
628
|
end
|
|
279
629
|
|
|
280
630
|
def customer(params={})
|
|
631
|
+
country = @fields[mappings[:billing_address][:country]]
|
|
632
|
+
@phone_number = params[:phone]
|
|
633
|
+
params[:phone] = format_phone_number(@phone_number, lookup_country_code(country, :alpha2))
|
|
634
|
+
|
|
281
635
|
super
|
|
282
|
-
add_field(mappings[:customer][:phone], format_phone_number(params[:phone]))
|
|
283
636
|
end
|
|
284
637
|
|
|
285
638
|
def addresses_match(address_match = nil)
|
|
@@ -339,7 +692,8 @@ module OffsitePayments #:nodoc:
|
|
|
339
692
|
:address2 => 'HPP_SHIPPING_STREET2',
|
|
340
693
|
:address3 => 'HPP_SHIPPING_STREET3',
|
|
341
694
|
:city => 'HPP_SHIPPING_CITY',
|
|
342
|
-
:state => 'HPP_SHIPPING_STATE'
|
|
695
|
+
:state => 'HPP_SHIPPING_STATE',
|
|
696
|
+
:code => 'SHIPPING_CODE'
|
|
343
697
|
|
|
344
698
|
mapping :billing_address, :zip => 'HPP_BILLING_POSTALCODE',
|
|
345
699
|
:country => 'HPP_BILLING_COUNTRY',
|
|
@@ -347,7 +701,8 @@ module OffsitePayments #:nodoc:
|
|
|
347
701
|
:address2 => 'HPP_BILLING_STREET2',
|
|
348
702
|
:address3 => 'HPP_BILLING_STREET3',
|
|
349
703
|
:city => 'HPP_BILLING_CITY',
|
|
350
|
-
:state => 'HPP_BILLING_STATE'
|
|
704
|
+
:state => 'HPP_BILLING_STATE',
|
|
705
|
+
:code => 'BILLING_CODE'
|
|
351
706
|
|
|
352
707
|
mapping :addresses_match, 'HPP_ADDRESS_MATCH_INDICATOR'
|
|
353
708
|
mapping :comment, 'COMMENT2'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: offsite_payments
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.7.
|
|
4
|
+
version: 2.7.26
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Luetke
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|