recurly 0.4.14 → 0.4.15
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/README.md +26 -56
- data/lib/recurly/rails3/recurly.rake +0 -27
- data/lib/recurly/transparent.rb +4 -1
- data/lib/recurly/version.rb +1 -1
- data/spec/integration/transparent_spec.rb +4 -2
- data/spec/vcr/transparent/post-url/1317063400.yml +105 -0
- data/spec/vcr/transparent/post-url/1317063474.yml +105 -0
- metadata +8 -4
data/README.md
CHANGED
@@ -14,27 +14,33 @@ Please see the [documentation](http://support.recurly.com/faqs/api/ruby-client)
|
|
14
14
|
Installation
|
15
15
|
------------
|
16
16
|
|
17
|
-
|
17
|
+
gem 'recurly', '~> 0.4'
|
18
18
|
|
19
|
-
gem 'recurly', '~> 0.4.11'
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
gem 'recurly', :git => "http://github.com/recurly/recurly-client-ruby.git"
|
20
|
+
Configuration
|
21
|
+
-------------
|
24
22
|
|
23
|
+
The Recurly Ruby Client requires an API user to connect. Please see the [Authentication](http://docs.recurly.com/api/authentication/) documentation for more information.
|
25
24
|
|
26
|
-
|
27
|
-
--------------
|
25
|
+
In a YAML file at 'config/recurly.yml':
|
28
26
|
|
29
|
-
|
27
|
+
production:
|
28
|
+
api_key: your_api_key
|
29
|
+
private_key: your_private_key
|
30
|
+
subdomain: your_recurly_subdomain
|
30
31
|
|
31
|
-
|
32
|
+
development:
|
33
|
+
api_key: your_api_key
|
34
|
+
private_key: your_private_key
|
35
|
+
subdomain: your_recurly_subdomain
|
32
36
|
|
37
|
+
The environment is optional. If you're using the same account with development and production, it can be simplified to:
|
33
38
|
|
34
|
-
|
35
|
-
|
39
|
+
api_key: your_api_key
|
40
|
+
private_key: your_private_key
|
41
|
+
subdomain: your_recurly_subdomain
|
36
42
|
|
37
|
-
|
43
|
+
Or, you may configure the Recurly gem using a `configure` block in 'config/initializers/recurly.rb':
|
38
44
|
|
39
45
|
Recurly.configure do |c|
|
40
46
|
c.api_key = 'your_api_key'
|
@@ -42,12 +48,9 @@ Alternatively, if not using Rails 3, just make sure to call a Recurly configure
|
|
42
48
|
c.subdomain = 'your-recurly-subdomain'
|
43
49
|
end
|
44
50
|
|
45
|
-
In Rails 2.x, this code should be in config/initializers/recurly.rb
|
46
|
-
|
47
|
-
In Sinatra, it should be within a `configure` block.
|
48
|
-
|
49
51
|
**Please Note:** the setup parameters changed in version 0.4.0. Additional configuration options were also added for the [Transparent Post API](http://docs.recurly.com/transparent-post/basics).
|
50
52
|
|
53
|
+
|
51
54
|
Manual Setup via YAML or JSON
|
52
55
|
--------------
|
53
56
|
You can also configure Recurly via a YAML file by using:
|
@@ -63,13 +66,6 @@ The Recurly Configuration YAML is in the format of:
|
|
63
66
|
|
64
67
|
The same format could be applied in JSON instead of YAML using: Recurly.configure_from_json('path/to/file.json')
|
65
68
|
|
66
|
-
Clearing test data (Rails3)
|
67
|
-
----------------
|
68
|
-
|
69
|
-
The Recurly Railtie (for rails3) includes a rake task that allows you to easily clear out the test data on your Account. This is useful when automating the testing of the api interation within your own app.
|
70
|
-
|
71
|
-
rake recurly:clear_test_data
|
72
|
-
|
73
69
|
|
74
70
|
Rails Demo Application
|
75
71
|
----------------
|
@@ -82,7 +78,7 @@ Examples
|
|
82
78
|
|
83
79
|
The [API Documentation](http://docs.recurly.com/api/basics) has numerous examples demonstrating how to use the Ruby client library.
|
84
80
|
|
85
|
-
All the functionality is demonstrated by the tests in the __spec__ directory.
|
81
|
+
All the functionality is also demonstrated by the tests in the __spec__ directory.
|
86
82
|
|
87
83
|
|
88
84
|
Running the Specs
|
@@ -92,41 +88,15 @@ Recurly gem uses RSpec2 for testing. It also uses VCR / Webmock to handle fast a
|
|
92
88
|
|
93
89
|
The way this works is when each spec is first run, it will save each HTTP request generated within the spec/vcr folder. Subsequent http requests will be mocked using the data contained in these YML files.
|
94
90
|
|
95
|
-
The
|
96
|
-
|
97
|
-
gem install bundler
|
98
|
-
|
99
|
-
The next thing is to setup all the spec dependencies
|
100
|
-
|
101
|
-
bundle
|
102
|
-
|
103
|
-
When first running the specs, you'll need to setup a recurly test account. Use the provided rake task to walk you through creating spec/config/recurly.yml with all the authentication info.
|
104
|
-
|
105
|
-
rake recurly:setup
|
106
|
-
|
107
|
-
Now when you run `rake` it will hit recurly's api to run all the specs. Subsequent calls will no longer hit the API (and be run locally).
|
108
|
-
|
109
|
-
The tests expect certain plans, add ons, and coupons to be present on the Site you'll be testing against. You'll need:
|
110
|
-
Plan with no trial with a plan_code of 'paid'
|
111
|
-
Plan with a trial with a plan_code of 'trial'
|
112
|
-
Add ons with codes 'special' and special2' on the 'paid' plan
|
113
|
-
Coupon with coupon code 'coupon' which can be applied to all plans
|
114
|
-
|
115
|
-
|
116
|
-
Something go Wrong?
|
117
|
-
------------------
|
118
|
-
|
119
|
-
You can view the full http interactions with Recurly at spec/vcr. Please attached these to any bug reports so we can replicate.
|
120
|
-
|
121
|
-
|
122
|
-
Clearing Test Data in Specs
|
123
|
-
----------------------------
|
91
|
+
The specs require API credentials in '/spec/config/recurly.yml' and the following setup in your Recurly account:
|
124
92
|
|
125
|
-
|
93
|
+
* A plan with no trial, use plan_code "paid".
|
94
|
+
* Add-ons with the codes "special" and "special2" on the "paid" plan.
|
95
|
+
* A plan with a trial period, use plan_code "trial"
|
96
|
+
* A coupon with the coupon_code "coupon" which can be applied to all plans.
|
126
97
|
|
127
|
-
|
98
|
+
To re-run specs, you will need to clear the test data from your Recurly account.
|
128
99
|
|
129
|
-
This will run `recurly:clear_test_data` (using your spec/config/recurly.yml authentication info) to clear out the test data on the server and then delete the associated spec/vcr files so you can start from scratch.
|
130
100
|
|
131
101
|
API Documentation
|
132
102
|
-----------------
|
@@ -6,33 +6,6 @@ namespace :recurly do
|
|
6
6
|
@recurly_config = Recurly::ConfigParser.parse
|
7
7
|
end
|
8
8
|
|
9
|
-
desc "Clears out the Test data from your configured Recurly site (does not touch your data in production mode)"
|
10
|
-
task :clear_test_data => :load_settings do
|
11
|
-
puts "\n"
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'restclient'
|
15
|
-
rescue LoadError
|
16
|
-
puts "Install the 'rest-client' gem in order to automatically clear your recurly test data via a rake task. If using Bundler, add it to your project's Gemfile (in :development group) and run again."
|
17
|
-
exit
|
18
|
-
end
|
19
|
-
|
20
|
-
api_key = @recurly_config["api_key"]
|
21
|
-
environment = @recurly_config["environment"]
|
22
|
-
|
23
|
-
# now lets clear site data
|
24
|
-
begin
|
25
|
-
if environment == :development
|
26
|
-
RestClient.delete("http://#{api_key}@api.lvh.me:3000/configuration/test_data")
|
27
|
-
else
|
28
|
-
RestClient.delete("https://#{api_key}@api.recurly.com/configuration/test_data")
|
29
|
-
end
|
30
|
-
raise "Clearing Didn't work for some reason. Is your site setting correct?"
|
31
|
-
rescue RestClient::Found => e
|
32
|
-
puts "Test Data Cleared"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
9
|
def setup_static
|
37
10
|
@recurly_config["api_key"] ||= "my_api_key"
|
38
11
|
@recurly_config["private_key"] ||= "my_private_key"
|
data/lib/recurly/transparent.rb
CHANGED
@@ -128,13 +128,16 @@ module Recurly
|
|
128
128
|
|
129
129
|
# recursively process the query data (running to_s on values)
|
130
130
|
def self.process_data(data = {})
|
131
|
+
return data unless data.is_a?(Hash)
|
131
132
|
data.each do |key, val|
|
132
133
|
if val.is_a?(Hash)
|
133
134
|
data[key] = process_data(val)
|
134
135
|
elsif val.is_a?(String)
|
135
136
|
data[key] = val.to_s
|
136
137
|
elsif val.is_a?(Enumerable)
|
137
|
-
|
138
|
+
values = Hash.new
|
139
|
+
val.each_with_index{ |item, index| values[index] = process_data(item) }
|
140
|
+
data[key] = values
|
138
141
|
else
|
139
142
|
data[key] = val.to_s
|
140
143
|
end
|
data/lib/recurly/version.rb
CHANGED
@@ -90,8 +90,10 @@ END
|
|
90
90
|
response.should_receive(:body).at_least(:once).and_return response_xml
|
91
91
|
|
92
92
|
subscription = Subscription.new.from_transparent_results(response)
|
93
|
-
subscription.account.billing_info.errors[:number].should_not
|
94
|
-
subscription.account.billing_info.errors[:
|
93
|
+
subscription.account.billing_info.credit_card.errors[:number].should_not be_empty
|
94
|
+
subscription.account.billing_info.credit_card.errors[:number].should include('is required')
|
95
|
+
subscription.account.billing_info.credit_card.errors[:verification_value].should_not be_empty
|
96
|
+
subscription.account.billing_info.credit_card.errors[:verification_value].should include('is required')
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :post
|
5
|
+
uri: http://2a655d41659d4ae0b37fcaec06331bf5:@api.lvh.me:3000/accounts.xml
|
6
|
+
body: |
|
7
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
8
|
+
<account>
|
9
|
+
<account-code>account-get-1317063400</account-code>
|
10
|
+
<first-name>Verena</first-name>
|
11
|
+
<last-name>Test</last-name>
|
12
|
+
<email>verena@test.com</email>
|
13
|
+
<company-name>Recurly Ruby Gem</company-name>
|
14
|
+
<billing-info>
|
15
|
+
<credit-card>
|
16
|
+
</credit-card>
|
17
|
+
</billing-info>
|
18
|
+
<accept-language nil="true"></accept-language>
|
19
|
+
</account>
|
20
|
+
|
21
|
+
headers:
|
22
|
+
user-agent:
|
23
|
+
- Recurly Ruby Client v0.4.14
|
24
|
+
content-type:
|
25
|
+
- application/xml
|
26
|
+
response: !ruby/struct:VCR::Response
|
27
|
+
status: !ruby/struct:VCR::ResponseStatus
|
28
|
+
code: 201
|
29
|
+
message: Created
|
30
|
+
headers:
|
31
|
+
location:
|
32
|
+
- http://api.lvh.me:3000/accounts/account-get-1317063400
|
33
|
+
content-type:
|
34
|
+
- application/xml; charset=utf-8
|
35
|
+
cache-control:
|
36
|
+
- no-cache
|
37
|
+
x-ua-compatible:
|
38
|
+
- IE=Edge
|
39
|
+
set-cookie:
|
40
|
+
- _recurly_session=4e81ed0ba0b7a5432e69da605b4cbbf6; domain=.lvh.me; path=/; HttpOnly
|
41
|
+
server:
|
42
|
+
- thin 1.2.11 codename Bat-Shit Crazy
|
43
|
+
body: |
|
44
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
45
|
+
<account>
|
46
|
+
<id>account-get-1317063400</id>
|
47
|
+
<account_code>account-get-1317063400</account_code>
|
48
|
+
<username></username>
|
49
|
+
<email>verena@test.com</email>
|
50
|
+
<first_name>Verena</first_name>
|
51
|
+
<last_name>Test</last_name>
|
52
|
+
<company_name>Recurly Ruby Gem</company_name>
|
53
|
+
<balance_in_cents type="integer">0</balance_in_cents>
|
54
|
+
<closed type="boolean">false</closed>
|
55
|
+
<hosted_login_token>5823616e8dc0439c99f45edff05ffaeb</hosted_login_token>
|
56
|
+
<created_at type="datetime">2011-09-26T18:57:16Z</created_at>
|
57
|
+
<state>active</state>
|
58
|
+
</account>
|
59
|
+
|
60
|
+
http_version: "1.1"
|
61
|
+
- !ruby/struct:VCR::HTTPInteraction
|
62
|
+
request: !ruby/struct:VCR::Request
|
63
|
+
method: :get
|
64
|
+
uri: http://2a655d41659d4ae0b37fcaec06331bf5:@api.lvh.me:3000/accounts/account-get-1317063400.xml
|
65
|
+
body:
|
66
|
+
headers:
|
67
|
+
user-agent:
|
68
|
+
- Recurly Ruby Client v0.4.14
|
69
|
+
accept:
|
70
|
+
- application/xml
|
71
|
+
accept-encoding:
|
72
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
73
|
+
response: !ruby/struct:VCR::Response
|
74
|
+
status: !ruby/struct:VCR::ResponseStatus
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
content-type:
|
79
|
+
- application/xml; charset=utf-8
|
80
|
+
etag:
|
81
|
+
- "\"4207b49346e061c62ef4c8622d1c8be2\""
|
82
|
+
cache-control:
|
83
|
+
- max-age=0, private, must-revalidate
|
84
|
+
x-ua-compatible:
|
85
|
+
- IE=Edge
|
86
|
+
server:
|
87
|
+
- thin 1.2.11 codename Bat-Shit Crazy
|
88
|
+
body: |
|
89
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
90
|
+
<account>
|
91
|
+
<id>account-get-1317063400</id>
|
92
|
+
<account_code>account-get-1317063400</account_code>
|
93
|
+
<username></username>
|
94
|
+
<email>verena@test.com</email>
|
95
|
+
<first_name>Verena</first_name>
|
96
|
+
<last_name>Test</last_name>
|
97
|
+
<company_name>Recurly Ruby Gem</company_name>
|
98
|
+
<balance_in_cents type="integer">0</balance_in_cents>
|
99
|
+
<closed type="boolean">false</closed>
|
100
|
+
<hosted_login_token>5823616e8dc0439c99f45edff05ffaeb</hosted_login_token>
|
101
|
+
<created_at type="datetime">2011-09-26T18:57:16Z</created_at>
|
102
|
+
<state>active</state>
|
103
|
+
</account>
|
104
|
+
|
105
|
+
http_version: "1.1"
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
- !ruby/struct:VCR::HTTPInteraction
|
3
|
+
request: !ruby/struct:VCR::Request
|
4
|
+
method: :post
|
5
|
+
uri: http://2a655d41659d4ae0b37fcaec06331bf5:@api.lvh.me:3000/accounts.xml
|
6
|
+
body: |
|
7
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
8
|
+
<account>
|
9
|
+
<account-code>account-get-1317063474</account-code>
|
10
|
+
<first-name>Verena</first-name>
|
11
|
+
<last-name>Test</last-name>
|
12
|
+
<email>verena@test.com</email>
|
13
|
+
<company-name>Recurly Ruby Gem</company-name>
|
14
|
+
<billing-info>
|
15
|
+
<credit-card>
|
16
|
+
</credit-card>
|
17
|
+
</billing-info>
|
18
|
+
<accept-language nil="true"></accept-language>
|
19
|
+
</account>
|
20
|
+
|
21
|
+
headers:
|
22
|
+
user-agent:
|
23
|
+
- Recurly Ruby Client v0.4.14
|
24
|
+
content-type:
|
25
|
+
- application/xml
|
26
|
+
response: !ruby/struct:VCR::Response
|
27
|
+
status: !ruby/struct:VCR::ResponseStatus
|
28
|
+
code: 201
|
29
|
+
message: Created
|
30
|
+
headers:
|
31
|
+
location:
|
32
|
+
- http://api.lvh.me:3000/accounts/account-get-1317063474
|
33
|
+
content-type:
|
34
|
+
- application/xml; charset=utf-8
|
35
|
+
cache-control:
|
36
|
+
- no-cache
|
37
|
+
x-ua-compatible:
|
38
|
+
- IE=Edge
|
39
|
+
set-cookie:
|
40
|
+
- _recurly_session=e9a4c74c87d659c65141eb9cc75a0498; domain=.lvh.me; path=/; HttpOnly
|
41
|
+
server:
|
42
|
+
- thin 1.2.11 codename Bat-Shit Crazy
|
43
|
+
body: |
|
44
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
45
|
+
<account>
|
46
|
+
<id>account-get-1317063474</id>
|
47
|
+
<account_code>account-get-1317063474</account_code>
|
48
|
+
<username></username>
|
49
|
+
<email>verena@test.com</email>
|
50
|
+
<first_name>Verena</first_name>
|
51
|
+
<last_name>Test</last_name>
|
52
|
+
<company_name>Recurly Ruby Gem</company_name>
|
53
|
+
<balance_in_cents type="integer">0</balance_in_cents>
|
54
|
+
<closed type="boolean">false</closed>
|
55
|
+
<hosted_login_token>f535367212dc4ca18e95d4e6b1c5e7e0</hosted_login_token>
|
56
|
+
<created_at type="datetime">2011-09-26T18:57:59Z</created_at>
|
57
|
+
<state>active</state>
|
58
|
+
</account>
|
59
|
+
|
60
|
+
http_version: "1.1"
|
61
|
+
- !ruby/struct:VCR::HTTPInteraction
|
62
|
+
request: !ruby/struct:VCR::Request
|
63
|
+
method: :get
|
64
|
+
uri: http://2a655d41659d4ae0b37fcaec06331bf5:@api.lvh.me:3000/accounts/account-get-1317063474.xml
|
65
|
+
body:
|
66
|
+
headers:
|
67
|
+
user-agent:
|
68
|
+
- Recurly Ruby Client v0.4.14
|
69
|
+
accept:
|
70
|
+
- application/xml
|
71
|
+
accept-encoding:
|
72
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
73
|
+
response: !ruby/struct:VCR::Response
|
74
|
+
status: !ruby/struct:VCR::ResponseStatus
|
75
|
+
code: 200
|
76
|
+
message: OK
|
77
|
+
headers:
|
78
|
+
content-type:
|
79
|
+
- application/xml; charset=utf-8
|
80
|
+
etag:
|
81
|
+
- "\"d885948736791ccddc6eb5ad3c5e77c8\""
|
82
|
+
cache-control:
|
83
|
+
- max-age=0, private, must-revalidate
|
84
|
+
x-ua-compatible:
|
85
|
+
- IE=Edge
|
86
|
+
server:
|
87
|
+
- thin 1.2.11 codename Bat-Shit Crazy
|
88
|
+
body: |
|
89
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
90
|
+
<account>
|
91
|
+
<id>account-get-1317063474</id>
|
92
|
+
<account_code>account-get-1317063474</account_code>
|
93
|
+
<username></username>
|
94
|
+
<email>verena@test.com</email>
|
95
|
+
<first_name>Verena</first_name>
|
96
|
+
<last_name>Test</last_name>
|
97
|
+
<company_name>Recurly Ruby Gem</company_name>
|
98
|
+
<balance_in_cents type="integer">0</balance_in_cents>
|
99
|
+
<closed type="boolean">false</closed>
|
100
|
+
<hosted_login_token>f535367212dc4ca18e95d4e6b1c5e7e0</hosted_login_token>
|
101
|
+
<created_at type="datetime">2011-09-26T18:57:59Z</created_at>
|
102
|
+
<state>active</state>
|
103
|
+
</account>
|
104
|
+
|
105
|
+
http_version: "1.1"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 15
|
9
|
+
version: 0.4.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Isaac Hall
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-21 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -235,6 +235,8 @@ files:
|
|
235
235
|
- spec/vcr/transaction/list-initial/1311126815.yml
|
236
236
|
- spec/vcr/transaction/lookup/1311126815.yml
|
237
237
|
- spec/vcr/transaction/void/1311126815.yml
|
238
|
+
- spec/vcr/transparent/post-url/1317063400.yml
|
239
|
+
- spec/vcr/transparent/post-url/1317063474.yml
|
238
240
|
has_rdoc: true
|
239
241
|
homepage: http://github.com/recurly/recurly-client-ruby
|
240
242
|
licenses: []
|
@@ -249,7 +251,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
251
|
requirements:
|
250
252
|
- - ">="
|
251
253
|
- !ruby/object:Gem::Version
|
252
|
-
hash:
|
254
|
+
hash: -363756991346156052
|
253
255
|
segments:
|
254
256
|
- 0
|
255
257
|
version: "0"
|
@@ -350,3 +352,5 @@ test_files:
|
|
350
352
|
- spec/vcr/transaction/list-initial/1311126815.yml
|
351
353
|
- spec/vcr/transaction/lookup/1311126815.yml
|
352
354
|
- spec/vcr/transaction/void/1311126815.yml
|
355
|
+
- spec/vcr/transparent/post-url/1317063400.yml
|
356
|
+
- spec/vcr/transparent/post-url/1317063474.yml
|