recurly 2.0.10 → 2.0.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of recurly might be problematic. Click here for more details.
- data/lib/recurly/js.rb +35 -15
- data/lib/recurly/resource.rb +2 -2
- data/lib/recurly/transaction.rb +2 -0
- data/lib/recurly/version.rb +1 -1
- metadata +120 -67
data/lib/recurly/js.rb
CHANGED
@@ -23,35 +23,45 @@ module Recurly
|
|
23
23
|
attr_writer :private_key
|
24
24
|
|
25
25
|
# @return [String]
|
26
|
-
def
|
27
|
-
sign '
|
26
|
+
def sign_subscription plan_code, account_code, extras = {}
|
27
|
+
sign 'subscriptioncreate', {
|
28
|
+
'plan_code' => plan_code,
|
29
|
+
'account_code' => account_code
|
30
|
+
}, extras
|
28
31
|
end
|
29
32
|
|
30
33
|
# @return [String]
|
31
|
-
def
|
34
|
+
def sign_billing_info account_code, extras = {}
|
35
|
+
sign 'billinginfoupdate', { 'account_code' => account_code }, extras
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String]
|
39
|
+
def sign_transaction(
|
40
|
+
amount_in_cents, currency = nil, account_code = nil, extras = {}
|
41
|
+
)
|
32
42
|
sign 'transactioncreate', {
|
33
43
|
'amount_in_cents' => amount_in_cents,
|
34
44
|
'currency' => currency || Recurly.default_currency,
|
35
45
|
'account_code' => account_code
|
36
|
-
}
|
46
|
+
}, extras
|
37
47
|
end
|
38
48
|
|
39
49
|
# @return [true]
|
40
50
|
# @raise [RequestForgery] If verification fails.
|
41
|
-
def
|
42
|
-
verify! '
|
51
|
+
def verify_subscription! params
|
52
|
+
verify! 'subscriptioncreated', params
|
43
53
|
end
|
44
54
|
|
45
55
|
# @return [true]
|
46
56
|
# @raise [RequestForgery] If verification fails.
|
47
|
-
def
|
48
|
-
verify! '
|
57
|
+
def verify_billing_info! params
|
58
|
+
verify! 'billinginfoupdated', params
|
49
59
|
end
|
50
60
|
|
51
61
|
# @return [true]
|
52
62
|
# @raise [RequestForgery] If verification fails.
|
53
|
-
def
|
54
|
-
verify! '
|
63
|
+
def verify_transaction! params
|
64
|
+
verify! 'transactioncreated', params
|
55
65
|
end
|
56
66
|
|
57
67
|
# @return [String]
|
@@ -61,13 +71,23 @@ module Recurly
|
|
61
71
|
|
62
72
|
private
|
63
73
|
|
64
|
-
def
|
65
|
-
|
74
|
+
def collect_keypaths extras, prefix = nil
|
75
|
+
if extras.is_a? Hash
|
76
|
+
extras.map { |key, value|
|
77
|
+
collect_keypaths value, prefix ? "#{prefix}.#{key}" : key.to_s
|
78
|
+
}.flatten.sort
|
79
|
+
else
|
80
|
+
prefix
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def sign claim, params, extras = {}, timestamp = Time.now
|
85
|
+
hexdigest = OpenSSL::HMAC.hexdigest(
|
66
86
|
OpenSSL::Digest::Digest.new('SHA1'),
|
67
87
|
Digest::SHA1.digest(private_key),
|
68
|
-
digest([timestamp = timestamp.to_i, claim, params])
|
88
|
+
digest([timestamp = timestamp.to_i, claim, params.merge(extras)])
|
69
89
|
)
|
70
|
-
"#{
|
90
|
+
["#{hexdigest}-#{timestamp}", *collect_keypaths(extras)].join '+'
|
71
91
|
end
|
72
92
|
|
73
93
|
def verify! claim, params
|
@@ -81,7 +101,7 @@ module Recurly
|
|
81
101
|
raise RequestForgery, 'stale timestamp'
|
82
102
|
end
|
83
103
|
|
84
|
-
if signature != sign(claim, params, timestamp)
|
104
|
+
if signature != sign(claim, params, {}, timestamp)
|
85
105
|
raise RequestForgery,
|
86
106
|
"signature can't be verified (invalid request or private key)"
|
87
107
|
end
|
data/lib/recurly/resource.rb
CHANGED
@@ -467,10 +467,10 @@ module Recurly
|
|
467
467
|
self[member_name] = case member
|
468
468
|
when Hash
|
469
469
|
associated.send :new, member.merge(:uri => associated_uri)
|
470
|
-
when
|
470
|
+
when associated
|
471
471
|
member.uri = associated_uri and member
|
472
472
|
else
|
473
|
-
raise ArgumentError, "expected #{
|
473
|
+
raise ArgumentError, "expected #{associated}"
|
474
474
|
end
|
475
475
|
}
|
476
476
|
define_method("build_#{member_name}") { |*args|
|
data/lib/recurly/transaction.rb
CHANGED
data/lib/recurly/version.rb
CHANGED
metadata
CHANGED
@@ -1,101 +1,146 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurly
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 11
|
10
|
+
version: 2.0.11
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Recurly
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-01-17 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: rake
|
16
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
25
|
none: false
|
18
|
-
requirements:
|
26
|
+
requirements:
|
19
27
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 63
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 9
|
33
|
+
- 2
|
21
34
|
version: 0.9.2
|
22
35
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
26
38
|
name: bundler
|
27
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
41
|
none: false
|
29
|
-
requirements:
|
42
|
+
requirements:
|
30
43
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 1923831893
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 1
|
49
|
+
- pre
|
50
|
+
- 10
|
32
51
|
version: 1.1.pre.10
|
33
52
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
37
55
|
name: minitest
|
38
|
-
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
58
|
none: false
|
40
|
-
requirements:
|
59
|
+
requirements:
|
41
60
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 21
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 6
|
66
|
+
- 1
|
43
67
|
version: 2.6.1
|
44
68
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
69
|
+
version_requirements: *id003
|
70
|
+
- !ruby/object:Gem::Dependency
|
48
71
|
name: webmock
|
49
|
-
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
74
|
none: false
|
51
|
-
requirements:
|
75
|
+
requirements:
|
52
76
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 7
|
79
|
+
segments:
|
80
|
+
- 1
|
81
|
+
- 7
|
82
|
+
- 6
|
54
83
|
version: 1.7.6
|
55
84
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
85
|
+
version_requirements: *id004
|
86
|
+
- !ruby/object:Gem::Dependency
|
59
87
|
name: guard-minitest
|
60
|
-
|
88
|
+
prerelease: false
|
89
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
90
|
none: false
|
62
|
-
requirements:
|
91
|
+
requirements:
|
63
92
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 15
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
- 4
|
98
|
+
- 0
|
65
99
|
version: 0.4.0
|
66
100
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
101
|
+
version_requirements: *id005
|
102
|
+
- !ruby/object:Gem::Dependency
|
70
103
|
name: rb-fsevent
|
71
|
-
|
104
|
+
prerelease: false
|
105
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
72
106
|
none: false
|
73
|
-
requirements:
|
107
|
+
requirements:
|
74
108
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 97
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
- 4
|
114
|
+
- 3
|
115
|
+
- 1
|
76
116
|
version: 0.4.3.1
|
77
117
|
type: :development
|
78
|
-
|
79
|
-
|
80
|
-
- !ruby/object:Gem::Dependency
|
118
|
+
version_requirements: *id006
|
119
|
+
- !ruby/object:Gem::Dependency
|
81
120
|
name: growl_notify
|
82
|
-
|
121
|
+
prerelease: false
|
122
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
83
123
|
none: false
|
84
|
-
requirements:
|
124
|
+
requirements:
|
85
125
|
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 29
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
- 0
|
131
|
+
- 1
|
87
132
|
version: 0.0.1
|
88
133
|
type: :development
|
89
|
-
|
90
|
-
|
91
|
-
description: ! 'An API client library for Recurly: http://recurly.com'
|
134
|
+
version_requirements: *id007
|
135
|
+
description: "An API client library for Recurly: http://recurly.com"
|
92
136
|
email: support@recurly.com
|
93
|
-
executables:
|
137
|
+
executables:
|
94
138
|
- recurly
|
95
139
|
extensions: []
|
96
|
-
|
140
|
+
|
141
|
+
extra_rdoc_files:
|
97
142
|
- README.markdown
|
98
|
-
files:
|
143
|
+
files:
|
99
144
|
- lib/rails/generators/recurly/config_generator.rb
|
100
145
|
- lib/rails/recurly.rb
|
101
146
|
- lib/recurly/account.rb
|
@@ -126,32 +171,40 @@ files:
|
|
126
171
|
- lib/recurly.rb
|
127
172
|
- README.markdown
|
128
173
|
- bin/recurly
|
174
|
+
has_rdoc: true
|
129
175
|
homepage: http://github.com/recurly/recurly-client-ruby
|
130
|
-
licenses:
|
176
|
+
licenses:
|
131
177
|
- MIT
|
132
178
|
post_install_message:
|
133
|
-
rdoc_options:
|
179
|
+
rdoc_options:
|
134
180
|
- --main
|
135
181
|
- README.markdown
|
136
|
-
require_paths:
|
182
|
+
require_paths:
|
137
183
|
- lib
|
138
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
185
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
hash: 3
|
190
|
+
segments:
|
191
|
+
- 0
|
192
|
+
version: "0"
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
194
|
none: false
|
146
|
-
requirements:
|
147
|
-
- -
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
hash: 3
|
199
|
+
segments:
|
200
|
+
- 0
|
201
|
+
version: "0"
|
150
202
|
requirements: []
|
203
|
+
|
151
204
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.
|
205
|
+
rubygems_version: 1.6.2
|
153
206
|
signing_key:
|
154
207
|
specification_version: 3
|
155
208
|
summary: Recurly API Client
|
156
209
|
test_files: []
|
157
|
-
|
210
|
+
|