offsite_payments 2.7.27 → 3.0.0

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: 5a045a98fd10c22d309a48cf2ecf4d9d6fc612d28adac50bd3896d6a2db34f49
4
+ data.tar.gz: a6982ef987e443c0eae1d1f78bfc35bba6bdecea24f8a2ca177b36509225cab1
5
5
  SHA512:
6
- metadata.gz: 3d15d1a95e2e6230b67176ceb7bdb8dc4831923611fe9dc93304d4a9a727acc97361117978161a8c31bf40c6df01f152bfe72e24f7af6626b7c0851a6e142a76
7
- data.tar.gz: 83a2c6d68f7979cc7ba91ca7842aef2774f34e3e412f8c97da063e327c36ee0f78dab2c6a99a4c0d37f90ccc878da6ac69454ff47564f4bff69420051132808f
6
+ metadata.gz: 4cc1411ae98b5e8c9ede9f4c4e7ef759186a779b95917c2e2e18ad160077dbd5baa83d1e4354b8deeffc4a1f7fa10ae2f7858dca46c46989b2263b513d047904
7
+ data.tar.gz: ad859cda068445f86b5afe022305c0766bae7045b34278c3ece6dafc894bc4eb945bc8ddf1e527804c97137b15f64dbcab7844208fc1b679b13b0d324c152ec2
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ > [!CAUTION]
2
+ > This gem is not actively maintained, and many of the integrations have not been updated in years. It is deprecated at Shopify, and should not be used.
3
+
1
4
  # Offsite Payments
2
5
  [![Build Status](https://github.com/activemerchant/offsite_payments/workflows/CI/badge.svg?branch=master)](https://github.com/activemerchant/offsite_payments/actions?query=workflow%3ACI)
3
6
  [![Code Climate](https://codeclimate.com/github/activemerchant/offsite_payments/badges/gpa.svg)](https://codeclimate.com/github/activemerchant/offsite_payments)
@@ -1,5 +1,13 @@
1
1
  module OffsitePayments #:nodoc:
2
+ module MoneyCompatibility
3
+ def to_cents(money)
4
+ money.try(:cents) || money.try(:subunits) || money
5
+ end
6
+ end
7
+
2
8
  class Helper #:nodoc:
9
+ include MoneyCompatibility
10
+
3
11
  attr_reader :fields
4
12
  class_attribute :service_url
5
13
  class_attribute :mappings
@@ -97,7 +97,7 @@ module OffsitePayments #:nodoc:
97
97
 
98
98
  # Need to format the amount to have 2 decimal places
99
99
  def amount=(money)
100
- cents = money.respond_to?(:cents) ? money.cents : money
100
+ cents = to_cents(money)
101
101
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
102
102
  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
103
103
 
@@ -89,7 +89,7 @@ module OffsitePayments #:nodoc:
89
89
 
90
90
  # Need to format the amount to have 2 decimal places
91
91
  def amount=(money)
92
- cents = money.respond_to?(:cents) ? money.cents : money
92
+ cents = to_cents(money)
93
93
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
94
94
  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
95
95
 
@@ -43,7 +43,7 @@ module OffsitePayments #:nodoc:
43
43
  mapping :amount, 'amount'
44
44
 
45
45
  def amount=(money)
46
- cents = money.respond_to?(:cents) ? money.cents : money
46
+ cents = to_cents(money)
47
47
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
48
48
  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
49
49
 
@@ -66,7 +66,7 @@ module OffsitePayments #:nodoc:
66
66
  end
67
67
 
68
68
  def amount=(money)
69
- @amount_in_cents = money.respond_to?(:cents) ? money.cents : money
69
+ @amount_in_cents = to_cents(money)
70
70
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
71
71
  raise ActionViewHelperError, "amount must be greater than $0.00" if @amount_in_cents.to_i <= 0
72
72
 
@@ -94,7 +94,7 @@ module OffsitePayments #:nodoc:
94
94
 
95
95
  # Need to format the amount to have 2 decimal places
96
96
  def amount=(money)
97
- cents = money.respond_to?(:cents) ? money.cents : money
97
+ cents = to_cents(money)
98
98
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
99
99
  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0
100
100
 
@@ -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,\+\-£\/@!\?%\*:$#\[\]|=\\&amp;\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,\+\-£\/@!\?%\*:$#\[\]|=\\&amp;\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
@@ -367,7 +367,7 @@ module OffsitePayments #:nodoc:
367
367
 
368
368
  # Used by composition methods, but not supplied by SagePay.
369
369
  def currency
370
- nil
370
+ Money::NULL_CURRENCY
371
371
  end
372
372
 
373
373
  def test?
@@ -63,7 +63,23 @@ module OffsitePayments #:nodoc:
63
63
  @raw = post.to_s
64
64
  for line in @raw.split('&')
65
65
  key, value = *line.scan( %r{^([A-Za-z0-9_.-]+)\=(.*)$} ).flatten
66
- params[key] = CGI.unescape(value.to_s) if key.present?
66
+ if key.present?
67
+ value = CGI.unescape(value.to_s)
68
+
69
+ # Paypal tend to send data encoded in ISO-8859-1
70
+ unless value.valid_encoding?
71
+ iso_value = value.dup.force_encoding(Encoding::ISO_8859_1)
72
+ if iso_value.valid_encoding?
73
+ value = iso_value.encode(Encoding::UTF_8)
74
+ else
75
+ # To be safe, if we get something even weirder, we ensure
76
+ # we return a UTF-8 strings.
77
+ value = value.b.encode(Encoding::UTF_8, replace: "?")
78
+ end
79
+ end
80
+
81
+ params[key] = value
82
+ end
67
83
  end
68
84
  end
69
85
  end
@@ -1,3 +1,3 @@
1
1
  module OffsitePayments
2
- VERSION = "2.7.27"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,43 @@
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: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-21 00:00:00.000000000 Z
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shopify-money
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activesupport
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: 5.2.3
33
+ version: 7.2.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: 5.2.3
40
+ version: 7.2.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: i18n
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -62,14 +76,14 @@ dependencies:
62
76
  name: active_utils
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
- - - "~>"
79
+ - - ">="
66
80
  - !ruby/object:Gem::Version
67
81
  version: 3.3.0
68
82
  type: :runtime
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - "~>"
86
+ - - ">="
73
87
  - !ruby/object:Gem::Version
74
88
  version: 3.3.0
75
89
  - !ruby/object:Gem::Dependency
@@ -92,28 +106,28 @@ dependencies:
92
106
  requirements:
93
107
  - - ">="
94
108
  - !ruby/object:Gem::Version
95
- version: 5.2.3
109
+ version: 7.2.0
96
110
  type: :runtime
97
111
  prerelease: false
98
112
  version_requirements: !ruby/object:Gem::Requirement
99
113
  requirements:
100
114
  - - ">="
101
115
  - !ruby/object:Gem::Version
102
- version: 5.2.3
116
+ version: 7.2.0
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: actionview
105
119
  requirement: !ruby/object:Gem::Requirement
106
120
  requirements:
107
121
  - - ">="
108
122
  - !ruby/object:Gem::Version
109
- version: 5.1.6.2
123
+ version: 7.2.0
110
124
  type: :runtime
111
125
  prerelease: false
112
126
  version_requirements: !ruby/object:Gem::Requirement
113
127
  requirements:
114
128
  - - ">="
115
129
  - !ruby/object:Gem::Version
116
- version: 5.1.6.2
130
+ version: 7.2.0
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: rake
119
133
  requirement: !ruby/object:Gem::Requirement
@@ -278,15 +292,7 @@ licenses:
278
292
  - MIT
279
293
  metadata:
280
294
  allowed_push_host: https://rubygems.org
281
- post_install_message: "\n In order to use `offsite_payments` gem, you need to either
282
- install or add to your Gemfile\n one of the two options for Money gem:\n -
283
- `gem 'money'`\n - `gem 'shopify-money', require: 'money'`\n\n Regardless
284
- of which gem you choose, please add them *before* `offsite_payments`.\n For more
285
- info, go to https://github.com/activemerchant/offsite_payments#money-gem-dependency\n\n
286
- \ It's also important to note that all Money object usage inside `offsite_payments`
287
- is being\n deprecated. We encourage you to use your own Money object inside your
288
- app instead of relying\n on `offsite_payments` doing it for you, e.g. `Money.from_amount(notification.gross)`\n
289
- \ "
295
+ post_install_message:
290
296
  rdoc_options: []
291
297
  require_paths:
292
298
  - lib
@@ -301,8 +307,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
307
  - !ruby/object:Gem::Version
302
308
  version: '0'
303
309
  requirements: []
304
- rubygems_version: 3.0.3
305
- signing_key:
310
+ rubygems_version: 3.5.18
311
+ signing_key:
306
312
  specification_version: 4
307
313
  summary: Framework and tools for dealing with offsite (hosted) payment pages.
308
314
  test_files: []