offsite_payments 2.7.11 → 2.7.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80e586df2a8864f246dc9aaa3ab3f53d3cc04b4f14200f195a504cf8cb3bb551
4
- data.tar.gz: dbbf5498a71aa62aafc296834d849f7c2c307a1c6abcae457c50a4385108860f
3
+ metadata.gz: d025fba3cb9d4bd253242a960ede519e6e4d8eb42f4e519de20b25518c3e9fae
4
+ data.tar.gz: 625c9fc0b712b746b13fcecc1c1d720f9f8a089d74e17257f0750d3f658be2b9
5
5
  SHA512:
6
- metadata.gz: 0c032a24a16ff43cf25fc011f1eddd2b0fde6f3064e14ae6982977d280f9eb6a99cc79d559e6091f6fc311a846a7ee21087b24f87448c07faa38eff46cb6fe37
7
- data.tar.gz: d7205f0cc31e891d3f88b8c7c4419516f2f59232ccf342a39f32bd1a24f53ec623e51c190c17e7372fae04a6763b5aecf922893b6de875a33dc5d749c3c53f36
6
+ metadata.gz: 87bd4aaae479a2c590f9e450c347bf9ab9e11ae2f64f1c2290e2ae51240b17198d252bcc7143de9083e05521640075c6ad2159d97c09020dfd3a494f337f5f23
7
+ data.tar.gz: e4852bfbcd3329242f261f5f78ac42e97f15d61e690d5e38ece24616051e10b984e83abe93f58bdb63997c14f5244877ffd51a9907fe03e4614123cc3608e83c
@@ -1,12 +1,13 @@
1
1
  module OffsitePayments #:nodoc:
2
2
  module Integrations #:nodoc:
3
3
  module BitPay
4
+ API_V1_URL = 'https://bitpay.com/api/invoice'
5
+ API_V1_TOKEN_REGEX = /[0OIl]/
6
+ API_V2_URL = 'https://bitpay.com/invoices'
7
+
4
8
  mattr_accessor :service_url
5
9
  self.service_url = 'https://bitpay.com/invoice'
6
10
 
7
- mattr_accessor :invoicing_url
8
- self.invoicing_url = 'https://bitpay.com/api/invoice'
9
-
10
11
  def self.notification(post, options = {})
11
12
  Notification.new(post, options)
12
13
  end
@@ -19,6 +20,18 @@ module OffsitePayments #:nodoc:
19
20
  Return.new(query_string)
20
21
  end
21
22
 
23
+ def self.v2_api_token?(api_token)
24
+ api_token.length >= 44 && !API_V1_TOKEN_REGEX.match(api_token)
25
+ end
26
+
27
+ def self.invoicing_url(api_token)
28
+ if v2_api_token?(api_token)
29
+ API_V2_URL
30
+ else
31
+ API_V1_URL
32
+ end
33
+ end
34
+
22
35
  class Helper < OffsitePayments::Helper
23
36
  def initialize(order_id, account, options)
24
37
  super
@@ -63,7 +76,7 @@ module OffsitePayments #:nodoc:
63
76
  private
64
77
 
65
78
  def create_invoice
66
- uri = URI.parse(BitPay.invoicing_url)
79
+ uri = URI.parse(BitPay.invoicing_url(@account))
67
80
  http = Net::HTTP.new(uri.host, uri.port)
68
81
  http.use_ssl = true
69
82
 
@@ -115,7 +128,7 @@ module OffsitePayments #:nodoc:
115
128
  end
116
129
 
117
130
  def acknowledge(authcode = nil)
118
- uri = URI.parse("#{OffsitePayments::Integrations::BitPay.invoicing_url}/#{transaction_id}")
131
+ uri = URI.parse("#{OffsitePayments::Integrations::BitPay.invoicing_url(@options[:credential1])}/#{transaction_id}")
119
132
 
120
133
  http = Net::HTTP.new(uri.host, uri.port)
121
134
  http.use_ssl = true
@@ -1,3 +1,3 @@
1
1
  module OffsitePayments
2
- VERSION = "2.7.11"
2
+ VERSION = "2.7.12"
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.11
4
+ version: 2.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-14 00:00:00.000000000 Z
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.14
19
+ version: 5.2.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.14
26
+ version: 5.2.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -76,36 +76,44 @@ dependencies:
76
76
  name: nokogiri
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '1.6'
81
+ version: 1.8.5
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '1.6'
88
+ version: 1.8.5
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: actionpack
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 3.2.20
96
- - - "<"
97
- - !ruby/object:Gem::Version
98
- version: '6.0'
95
+ version: 5.2.3
99
96
  type: :runtime
100
97
  prerelease: false
101
98
  version_requirements: !ruby/object:Gem::Requirement
102
99
  requirements:
103
100
  - - ">="
104
101
  - !ruby/object:Gem::Version
105
- version: 3.2.20
106
- - - "<"
102
+ version: 5.2.3
103
+ - !ruby/object:Gem::Dependency
104
+ name: actionview
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 5.1.6.2
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
107
115
  - !ruby/object:Gem::Version
108
- version: '6.0'
116
+ version: 5.1.6.2
109
117
  - !ruby/object:Gem::Dependency
110
118
  name: rake
111
119
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +184,20 @@ dependencies:
176
184
  - - ">="
177
185
  - !ruby/object:Gem::Version
178
186
  version: '0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: webmock
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
179
201
  description: Offsite Payments is a simple abstraction library used in and sponsored
180
202
  by Shopify. It is written by Tobias Luetke, Cody Fauser, and contributors. The aim
181
203
  of the project is to put as simple an abstraction as possible on top of offsite