offsite_payments 2.7.27 → 2.7.28

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: 26c27fc431af5ea0650cb099bd36dc13ec371928e9f1ceabbe2aff0a09904a6e
4
- data.tar.gz: 99edfdf3c683213d89fb05dc227c7323e2ded4e6725ea3d232a6a142cf38def5
3
+ metadata.gz: 7d6f15a62a3d0c2744b89d969b27b4211d3308edd81175447fd2c9609c191787
4
+ data.tar.gz: cb1dff98006362f1f80fb9d9957dff0e049d6a401658f4544c112f538de1c5ee
5
5
  SHA512:
6
- metadata.gz: 3d15d1a95e2e6230b67176ceb7bdb8dc4831923611fe9dc93304d4a9a727acc97361117978161a8c31bf40c6df01f152bfe72e24f7af6626b7c0851a6e142a76
7
- data.tar.gz: 83a2c6d68f7979cc7ba91ca7842aef2774f34e3e412f8c97da063e327c36ee0f78dab2c6a99a4c0d37f90ccc878da6ac69454ff47564f4bff69420051132808f
6
+ metadata.gz: 572f3afcfb7d6d22cbf0097d778996d727091e831a534f1e1f9f6e7a2063cac9091588026ffb9430664138c906fadba86b4d52d7a6499bb7cdcc576d8ab22c3f
7
+ data.tar.gz: e0701df36a24581fa8530529f017e3eb550c4e76abab0ca74265637e5cf57109d6094c661f0fa7f92f29876b7388594d6ac744f980608f1193133b3bb75ac516
@@ -422,14 +422,19 @@ module OffsitePayments #:nodoc:
422
422
  end
423
423
 
424
424
  # This method is used for generating the "BILLING_CODE" field,
425
- # this field is generated by concatenating the zip field and
425
+ # which is only needed for US, CA and GB.
426
+ # This field is generated by concatenating the zip field and
426
427
  # the first line of address with a pipe(|) between them
427
428
  # if the country is GB, we remove the non-numeric characters
428
429
  def extract_avs_code(params={})
429
- return unless params[:zip] && params[:address1]
430
+ country_code = lookup_country_code(params[:country], :alpha2)
431
+ return unless params[:zip] && params[:address1] && ['US', 'CA', 'GB'].include?(country_code)
430
432
  code = [params[:zip], params[:address1]]
431
433
  code = code.collect{|p| extract_digits(p) } if params[:country] == 'GB'
432
- code.reject{|p| p.empty? }.join('|')
434
+ code = code.reject{|p| p.empty? }.join('|')
435
+ # Since this field accepts only a few characters, we remove the ones that are not accepted,
436
+ # and trim the white spaces
437
+ code = code.gsub(/[^a-z0-9_\-| ]+/i, '').strip
433
438
  end
434
439
 
435
440
  def extract_address_match_indicator(value)
@@ -507,8 +512,8 @@ module OffsitePayments #:nodoc:
507
512
  case key
508
513
  when 'HPP_CUSTOMER_EMAIL' then /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,24})*$/
509
514
  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}$/
515
+ when 'HPP_BILLING_STREET1', 'HPP_SHIPPING_STREET1', 'HPP_BILLING_STREET2', 'HPP_SHIPPING_STREET2' then /^[ÀÁÂÃÂÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåªæçèéêëìíîïðñòóôõöº÷ø¤ùúûüýþÿ~L~N~Z~\~^~_¥a-zA-Z0-9.'";\s,\+\-£\/@!\?%\*:$#\[\]|=\\&\u0152\u0153\u017D\u0161\u017E\u0178\u20AC]{1,50}$/
516
+ when 'HPP_BILLING_CITY', 'HPP_SHIPPING_CITY' then /^[ÀÁÂÃÂÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåªæçèéêëìíîïðñòóôõöº÷ø¤ùúûüýþÿ~L~N~Z~\~^~_¥a-zA-Z0-9.'";\s,\+\-£\/@!\?%\*:$#\[\]|=\\&\u0152\u0153\u017D\u0161\u017E\u0178\u20AC]{1,40}$/
512
517
  when 'HPP_BILLING_COUNTRY', 'HPP_SHIPPING_COUNTRY' then /^([0-9])*$/
513
518
  when 'HPP_BILLING_POSTALCODE', 'HPP_SHIPPING_POSTALCODE' then /^[a-zA-Z0-9\-\s]{1,16}$/
514
519
  when 'HPP_BILLING_STATE', 'HPP_SHIPPING_STATE' then /^([A-Z])*$/
@@ -599,6 +604,14 @@ module OffsitePayments #:nodoc:
599
604
  end
600
605
  end
601
606
 
607
+ unless ['US', 'CA', 'GB'].include?(country_code)
608
+ # BILLING_CODE is required only for US, CA and GB, otherwise is nil,
609
+ # therefore the field is deleted for the other countries
610
+ @fields.delete_if do |k, _|
611
+ k == 'BILLING_CODE'
612
+ end
613
+ end
614
+
602
615
  if @fields[mappings[:customer][:phone]]
603
616
  add_field(mappings[:customer][:phone], format_phone_number(@phone_number, country_code))
604
617
  end
@@ -1,3 +1,3 @@
1
1
  module OffsitePayments
2
- VERSION = "2.7.27"
2
+ VERSION = "2.7.28"
3
3
  end
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.27
4
+ version: 2.7.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-21 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport