aliquot 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aliquot/error.rb +2 -0
- data/lib/aliquot/payment.rb +11 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fd348440efd40e2b2f67cbff74deb5100e7e68280710af2d67f6d64343122b7
|
4
|
+
data.tar.gz: 121a611e53d3d4745082877e0ab50d733349cc857d61abc905945b4392f7c193
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 647493009e7daee01e264752c5fd1bd32969c4e1e3c9c1e78ee4e4f5bd074730d39144be9c07bc8757d653bd61301bf9eb11f1bb45339e39d83d4d1a1e5d0c44
|
7
|
+
data.tar.gz: cdc115e4500ddebdbbdb49b427ccb057162259c1f1400f5274e6d07a9e814333b07f2ea981a3b7b5151c9cac29ef9dbab8c7c90cdd61e31b56816a1c333a8777
|
data/lib/aliquot/error.rb
CHANGED
data/lib/aliquot/payment.rb
CHANGED
@@ -17,7 +17,7 @@ module Aliquot
|
|
17
17
|
# Parameters:
|
18
18
|
# token_string:: Google Pay token (JSON string)
|
19
19
|
# shared_secret:: Base64 encoded shared secret
|
20
|
-
# merchant_id:: Google Pay merchant ID
|
20
|
+
# merchant_id:: Google Pay merchant ID
|
21
21
|
# signing_keys:: Signing keys fetched from Google
|
22
22
|
def initialize(token_string, shared_secret, merchant_id,
|
23
23
|
signing_keys: ENV['GOOGLE_SIGNING_KEYS'])
|
@@ -43,13 +43,15 @@ module Aliquot
|
|
43
43
|
raise Error, "supported protocol versions are #{SUPPORTED_PROTOCOL_VERSIONS.join(', ')}"
|
44
44
|
end
|
45
45
|
|
46
|
+
@recipient_id = validate_merchant_id
|
47
|
+
|
48
|
+
check_shared_secret
|
49
|
+
|
46
50
|
if protocol_version == 'ECv2'
|
47
51
|
@intermediate_key = validate_intermediate_key
|
48
52
|
raise InvalidSignatureError, 'intermediate certificate expired' if intermediate_key_expired?
|
49
53
|
end
|
50
54
|
|
51
|
-
check_shared_secret
|
52
|
-
|
53
55
|
check_signature
|
54
56
|
|
55
57
|
@signed_message = validate_signed_message
|
@@ -100,6 +102,11 @@ module Aliquot
|
|
100
102
|
@intermediate_key[:keyExpiration].to_i < cur_millis
|
101
103
|
end
|
102
104
|
|
105
|
+
def validate_merchant_id
|
106
|
+
raise InvalidMerchantIDError unless /[[:graph:]]/ =~ @merchant_id
|
107
|
+
"merchant:#{@merchant_id}"
|
108
|
+
end
|
109
|
+
|
103
110
|
def check_shared_secret
|
104
111
|
begin
|
105
112
|
decoded = Base64.strict_decode64(@shared_secret)
|
@@ -111,7 +118,7 @@ module Aliquot
|
|
111
118
|
end
|
112
119
|
|
113
120
|
def check_signature
|
114
|
-
signed_string_message = ['Google', @
|
121
|
+
signed_string_message = ['Google', @recipient_id, protocol_version, @token[:signedMessage]].map do |str|
|
115
122
|
[str.length].pack('V') + str
|
116
123
|
end.join
|
117
124
|
message_signature = Base64.strict_decode64(@token[:signature])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliquot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clearhaus
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.11'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.11'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|