recurly 0.2.7 → 0.2.8

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.

@@ -16,19 +16,27 @@ module Recurly
16
16
  # convert the data into a paginated resultset (array with singleton methods)
17
17
  def paginate_data(data)
18
18
 
19
+ per_page = data["per_page"] || 0
20
+ current_page = data["current_page"] || 0
21
+ total_entries = data["total_entries"] || 0
22
+
19
23
  # find the first array and use that as the resultset (lame workaround)
20
24
  results = data.values.select{|v| v.is_a?(Array)}.first || []
25
+ if results.empty?
26
+ data.delete("per_page")
27
+ data.delete("current_page")
28
+ data.delete("total_entries")
29
+ data.delete("type")
30
+ results = [data.values.first].compact
31
+ end
21
32
 
22
33
  # define total_entries accessor on result object
23
- total_entries = data["total_entries"] || 0
24
34
  results.instance_eval "def total_entries; #{total_entries.to_i}; end"
25
35
 
26
36
  # define current_page accessor on result object
27
- current_page = data["current_page"] || 0
28
37
  results.instance_eval "def current_page; #{current_page.to_i}; end"
29
38
 
30
39
  # define per_page accessor on result object
31
- per_page = data["per_page"] || 0
32
40
  results.instance_eval "def per_page; #{per_page.to_i}; end"
33
41
 
34
42
  results
@@ -1,3 +1,3 @@
1
1
  module Recurly #:nodoc
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -52,16 +52,20 @@ module Recurly
52
52
  end
53
53
 
54
54
  describe "list account transactions" do
55
- context "empty transactions" do
56
- use_vcr_cassette "transaction/list-empty/#{timestamp}"
57
- let(:account) { Factory.create_account_with_billing_info("transaction-list-empty-#{timestamp}") }
55
+ context "initial void transaction" do
56
+ use_vcr_cassette "transaction/list-initial/#{timestamp}"
57
+ let(:account) { Factory.create_account_with_billing_info("transaction-list-initial-#{timestamp}") }
58
58
 
59
59
  before(:each) do
60
60
  @transactions = Transaction.list_for_account(account.account_code)
61
61
  end
62
62
 
63
- it "should return an empty array of transactions" do
64
- @transactions.should be_empty
63
+ it "should one transaction after registering" do
64
+ @transactions.count.should eql(1)
65
+ end
66
+
67
+ it "should be in void state" do
68
+ @transactions.first.status.should == "void"
65
69
  end
66
70
  end
67
71
 
@@ -143,4 +147,4 @@ module Recurly
143
147
 
144
148
 
145
149
  end
146
- end
150
+ end
@@ -0,0 +1,78 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/transactions.xml
6
+ body:
7
+ headers:
8
+ authorization:
9
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
10
+ accept:
11
+ - application/xml
12
+ accept-encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ user-agent:
15
+ - Ruby
16
+ connection:
17
+ - close
18
+ response: !ruby/struct:VCR::Response
19
+ status: !ruby/struct:VCR::ResponseStatus
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ server:
24
+ - nginx/0.7.65
25
+ date:
26
+ - Fri, 12 Nov 2010 10:36:50 GMT
27
+ content-type:
28
+ - application/xml; charset=utf-8
29
+ transfer-encoding:
30
+ - chunked
31
+ connection:
32
+ - close
33
+ x-runtime:
34
+ - "64"
35
+ etag:
36
+ - "\"1ee5d044f2a784cbb80d09e6fbb1629f\""
37
+ cache-control:
38
+ - private, max-age=0, must-revalidate
39
+ set-cookie:
40
+ - _recurly_session=85dc3091e063c5fa8cbf6c9c7dd8d70e; domain=.recurly.com; path=/; secure; HttpOnly
41
+ x-ua-compatible:
42
+ - IE=Edge
43
+ content-encoding:
44
+ - gzip
45
+ body: !binary |
46
+ H4sIAAAAAAAAA+1bTXPbNhC951dodFeE7w+NrFw67SkznWl66cWzABY2p7Lk
47
+ ISmn6a/vUpRsqbZqKVFsT4qbBCyWIPh2+fAWnH7462Y+uMO6qZaLiyF/z4YD
48
+ XMRlqhZXF8PfP/08csMPs3fTtoZFA7Elq2bQfrnFi2Fczue4bhnO3g0G07iq
49
+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LkIz0kWkvrSGq8xzi
66
+ Nzr+S7D509QaUYhNkWvWRYXHxMYFqlrlzBXjQSWVCP6atEvhFFciG3UI9LsF
67
+ rD74NoyeS04az/kVHDdRYqLOruAUqb4LjVdK9a8o1QPpkh4ss450SqrWhmRR
68
+ hqxUBg1cHCXVn4T7bylTsR786lT58hluX7D//8Q+9xLosEJyjhmq1waHSUgS
69
+ My0kbrg86tBCh52XyPiy1GZ/oCMKr5jwjTB0GsFIHUij56C8D4wKU4F7bkH4
70
+ g/vZXaJzAui/Pd3Lku4L8s+xr01OSBuytoBJgdBgo/N0RE0bjgY4HEPx90T7
71
+ 70rxxWl726Jglq3tga1tQinBaBG0QCUJ6o74DWhvqVKbAI/a2r4g7uVJ7F4U
72
+ 5b7Uqp6WdDjLJL946wW3KmkZMFgXXKCClefChDeW70/DfdHvS74/kO+10Tpm
73
+ BCMp3yungZGSw+hsTozaG6bPjvtv5/i87G4Lxz8Hx2dMRAwOAn2CoWw2ns4l
74
+ ZI9BqIB0SOGo3e28q9jmir7IeRFlh5+W+AvRL4n/QOKXySoRYiByrxXSF1hO
75
+ CS4d44mBcfbgkeNdaedtg7+w/QL+A+C3jGenQFoMTJG8E7SPOtpkhVKk6B9V
76
+ yHph8LNzs55yZOdHO7Kz9yFiM3v3D5rO25ZkPAAA
77
+
78
+ http_version: "1.1"
@@ -0,0 +1,93 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/transactions.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <transaction>
9
+ <account>
10
+ <account-code>transaction-create-with-accout-1289558212</account-code>
11
+ <first-name>Verena</first-name>
12
+ <last-name>Test</last-name>
13
+ <email>verena@test.com</email>
14
+ <company-name>Recurly Ruby Gem</company-name>
15
+ <billing-info>
16
+ <address1>123 Test St</address1>
17
+ <city>San Francisco</city>
18
+ <state>CA</state>
19
+ <zip>94115</zip>
20
+ <country>US</country>
21
+ <credit-card>
22
+ <number>1</number>
23
+ <year type="integer">2011</year>
24
+ <month type="integer">11</month>
25
+ <verification-value>123</verification-value>
26
+ </credit-card>
27
+ </billing-info>
28
+ </account>
29
+ <amount-in-cents type="integer">700</amount-in-cents>
30
+ <description>setup fee of 7 dollarz</description>
31
+ </transaction>
32
+
33
+ headers:
34
+ authorization:
35
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
36
+ content-type:
37
+ - application/xml
38
+ accept:
39
+ - "*/*"
40
+ user-agent:
41
+ - Ruby
42
+ connection:
43
+ - close
44
+ response: !ruby/struct:VCR::Response
45
+ status: !ruby/struct:VCR::ResponseStatus
46
+ code: 201
47
+ message: Created
48
+ headers:
49
+ server:
50
+ - nginx/0.7.65
51
+ date:
52
+ - Fri, 12 Nov 2010 10:36:48 GMT
53
+ content-type:
54
+ - application/xml; charset=utf-8
55
+ connection:
56
+ - close
57
+ cache-control:
58
+ - no-cache
59
+ location:
60
+ - https://recurlytest3-test.recurly.com/transactions/cd5812c273004eadb1f4c870833fcbbf
61
+ x-runtime:
62
+ - "421"
63
+ content-length:
64
+ - "862"
65
+ set-cookie:
66
+ - account_credentials=0e7b74a69e59ed0fe075084713224141c70db6890ad97af76b622dd5d1ec4f355fcfd4960d3ade183019daa263a1dfed8d4b58e73ea4def1a654c9172869b073%3A%3A; domain=.recurly.com; path=/
67
+ - ""
68
+ - _recurly_session=c7cbea1f580e3c62ac1f34f203218075; domain=.recurly.com; path=/; secure; HttpOnly
69
+ body: |
70
+ <?xml version="1.0" encoding="UTF-8"?>
71
+ <transaction type="Payment">
72
+ <id>cd5812c273004eadb1f4c870833fcbbf</id>
73
+ <account_code>transaction-create-with-accout-1289558212</account_code>
74
+ <action>purchase</action>
75
+ <date type="datetime">2010-11-12T10:36:47Z</date>
76
+ <amount_in_cents type="integer">700</amount_in_cents>
77
+ <status>success</status>
78
+ <message>Test Gateway: Successful test transaction</message>
79
+ <reference></reference>
80
+ <cvv_result code="M">Match</cvv_result>
81
+ <avs_result code="D">Street address and postal code match.</avs_result>
82
+ <avs_result_street></avs_result_street>
83
+ <avs_result_postal></avs_result_postal>
84
+ <test type="boolean">true</test>
85
+ <voidable type="boolean">true</voidable>
86
+ <refundable type="boolean">true</refundable>
87
+ <credit_card>
88
+ <type>bogus</type>
89
+ <last_four>1</last_four>
90
+ </credit_card>
91
+ </transaction>
92
+
93
+ http_version: "1.1"
@@ -0,0 +1,226 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <account>
9
+ <account-code>transaction-create-with-account-1289558212</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
+ </account>
15
+
16
+ headers:
17
+ authorization:
18
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
19
+ content-type:
20
+ - application/xml
21
+ accept:
22
+ - "*/*"
23
+ user-agent:
24
+ - Ruby
25
+ connection:
26
+ - close
27
+ response: !ruby/struct:VCR::Response
28
+ status: !ruby/struct:VCR::ResponseStatus
29
+ code: 201
30
+ message: Created
31
+ headers:
32
+ server:
33
+ - nginx/0.7.65
34
+ date:
35
+ - Fri, 12 Nov 2010 10:36:51 GMT
36
+ content-type:
37
+ - application/xml; charset=utf-8
38
+ connection:
39
+ - close
40
+ cache-control:
41
+ - no-cache
42
+ location:
43
+ - https://recurlytest3-test.recurly.com/accounts/transaction-create-with-account-1289558212
44
+ x-runtime:
45
+ - "256"
46
+ content-length:
47
+ - "617"
48
+ set-cookie:
49
+ - account_credentials=3a691d79d6a32d2747e14d880115f2c4771e03b018a50fa5023dfb1ce3a2f92b95849ead79c7063a770202192877a34759144f5a454cfbe81a37c66607c166d3%3A%3A; domain=.recurly.com; path=/
50
+ - ""
51
+ - _recurly_session=bbc5f6c30266895da31b04c483e58e85; domain=.recurly.com; path=/; secure; HttpOnly
52
+ body: |
53
+ <?xml version="1.0" encoding="UTF-8"?>
54
+ <account>
55
+ <id>transaction-create-with-account-1289558212</id>
56
+ <account_code>transaction-create-with-account-1289558212</account_code>
57
+ <username></username>
58
+ <email>verena@test.com</email>
59
+ <first_name>Verena</first_name>
60
+ <last_name>Test</last_name>
61
+ <company_name>Recurly Ruby Gem</company_name>
62
+ <balance_in_cents type="integer">0</balance_in_cents>
63
+ <closed type="boolean">false</closed>
64
+ <hosted_login_token>b4fc3ff5b35b459cafe292b57e82a5a3</hosted_login_token>
65
+ <created_at type="datetime">2010-11-12T10:36:51Z</created_at>
66
+ <state>active</state>
67
+ </account>
68
+
69
+ http_version: "1.1"
70
+ - !ruby/struct:VCR::HTTPInteraction
71
+ request: !ruby/struct:VCR::Request
72
+ method: :put
73
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts/transaction-create-with-account-1289558212/billing_info.xml
74
+ body: |
75
+ <?xml version="1.0" encoding="UTF-8"?>
76
+ <billing-info>
77
+ <address1>123 Test St</address1>
78
+ <city>San Francisco</city>
79
+ <state>CA</state>
80
+ <zip>94115</zip>
81
+ <country>US</country>
82
+ <credit-card>
83
+ <number>1</number>
84
+ <year type="integer">2011</year>
85
+ <month type="integer">11</month>
86
+ <verification-value>123</verification-value>
87
+ </credit-card>
88
+ <account-code>transaction-create-with-account-1289558212</account-code>
89
+ <first-name>Verena</first-name>
90
+ <last-name>Test</last-name>
91
+ </billing-info>
92
+
93
+ headers:
94
+ authorization:
95
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
96
+ content-type:
97
+ - application/xml
98
+ accept:
99
+ - "*/*"
100
+ user-agent:
101
+ - Ruby
102
+ connection:
103
+ - close
104
+ response: !ruby/struct:VCR::Response
105
+ status: !ruby/struct:VCR::ResponseStatus
106
+ code: 200
107
+ message: OK
108
+ headers:
109
+ server:
110
+ - nginx/0.7.65
111
+ date:
112
+ - Fri, 12 Nov 2010 10:36:49 GMT
113
+ content-type:
114
+ - application/xml; charset=utf-8
115
+ connection:
116
+ - close
117
+ x-runtime:
118
+ - "50"
119
+ etag:
120
+ - "\"5ef02eb026f26bce19b98238b33f513d\""
121
+ cache-control:
122
+ - private, max-age=0, must-revalidate
123
+ content-length:
124
+ - "656"
125
+ set-cookie:
126
+ - _recurly_session=ead509055139d43c23378a601ffc02d7; domain=.recurly.com; path=/; secure; HttpOnly
127
+ x-ua-compatible:
128
+ - IE=Edge
129
+ body: |
130
+ <?xml version="1.0" encoding="UTF-8"?>
131
+ <billing_info>
132
+ <account_code>transaction-create-with-account-1289558212</account_code>
133
+ <first_name>Verena</first_name>
134
+ <last_name>Test</last_name>
135
+ <address1>123 Test St</address1>
136
+ <address2></address2>
137
+ <city>San Francisco</city>
138
+ <state>CA</state>
139
+ <country>US</country>
140
+ <zip>94115</zip>
141
+ <phone></phone>
142
+ <vat_number></vat_number>
143
+ <ip_address></ip_address>
144
+ <credit_card>
145
+ <type>bogus</type>
146
+ <last_four>1</last_four>
147
+ <month type="integer">11</month>
148
+ <year type="integer">2011</year>
149
+ </credit_card>
150
+ <updated_at type="datetime">2010-11-12T10:36:49Z</updated_at>
151
+ </billing_info>
152
+
153
+ http_version: "1.1"
154
+ - !ruby/struct:VCR::HTTPInteraction
155
+ request: !ruby/struct:VCR::Request
156
+ method: :post
157
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/transactions.xml
158
+ body: |
159
+ <?xml version="1.0" encoding="UTF-8"?>
160
+ <transaction>
161
+ <account>
162
+ <account-code>transaction-create-with-account-1289558212</account-code>
163
+ </account>
164
+ <amount-in-cents type="integer">700</amount-in-cents>
165
+ <description>test transaction for $7</description>
166
+ </transaction>
167
+
168
+ headers:
169
+ authorization:
170
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
171
+ content-type:
172
+ - application/xml
173
+ accept:
174
+ - "*/*"
175
+ user-agent:
176
+ - Ruby
177
+ connection:
178
+ - close
179
+ response: !ruby/struct:VCR::Response
180
+ status: !ruby/struct:VCR::ResponseStatus
181
+ code: 201
182
+ message: Created
183
+ headers:
184
+ server:
185
+ - nginx/0.7.65
186
+ date:
187
+ - Fri, 12 Nov 2010 10:36:52 GMT
188
+ content-type:
189
+ - application/xml; charset=utf-8
190
+ connection:
191
+ - close
192
+ cache-control:
193
+ - no-cache
194
+ location:
195
+ - https://recurlytest3-test.recurly.com/transactions/17145bda916d46988179efa9e0258177
196
+ x-runtime:
197
+ - "174"
198
+ content-length:
199
+ - "863"
200
+ set-cookie:
201
+ - _recurly_session=290ecd6346e65df39212cc03fcdc163a; domain=.recurly.com; path=/; secure; HttpOnly
202
+ body: |
203
+ <?xml version="1.0" encoding="UTF-8"?>
204
+ <transaction type="Payment">
205
+ <id>17145bda916d46988179efa9e0258177</id>
206
+ <account_code>transaction-create-with-account-1289558212</account_code>
207
+ <action>purchase</action>
208
+ <date type="datetime">2010-11-12T10:36:52Z</date>
209
+ <amount_in_cents type="integer">700</amount_in_cents>
210
+ <status>success</status>
211
+ <message>Test Gateway: Successful test transaction</message>
212
+ <reference></reference>
213
+ <cvv_result code="M">Match</cvv_result>
214
+ <avs_result code="D">Street address and postal code match.</avs_result>
215
+ <avs_result_street></avs_result_street>
216
+ <avs_result_postal></avs_result_postal>
217
+ <test type="boolean">true</test>
218
+ <voidable type="boolean">true</voidable>
219
+ <refundable type="boolean">true</refundable>
220
+ <credit_card>
221
+ <type>bogus</type>
222
+ <last_four>1</last_four>
223
+ </credit_card>
224
+ </transaction>
225
+
226
+ http_version: "1.1"