recurly 2.15.4 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/recurly.rb +1 -2
- data/lib/recurly/account.rb +6 -0
- data/lib/recurly/api.rb +1 -1
- data/lib/recurly/custom_field.rb +15 -0
- data/lib/recurly/invoice.rb +4 -0
- data/lib/recurly/money.rb +0 -2
- data/lib/recurly/plan.rb +1 -0
- data/lib/recurly/purchase.rb +22 -2
- data/lib/recurly/resource.rb +2 -2
- data/lib/recurly/subscription.rb +19 -0
- data/lib/recurly/version.rb +2 -2
- metadata +3 -4
- data/lib/rails/generators/recurly/config_generator.rb +0 -25
- data/lib/rails/recurly.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e239381f1946c2933db35636b8c7ee25c5ad51c4d39f1514c1e831dcc548cd79
|
4
|
+
data.tar.gz: 650ec4f07db78242d1bdac62eccb2b564ef00b2c71c97164561dce7dd0db6129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21ff58a6c85dd74286cb0c879294d74bc90efbb94e764415e2d55452bc56b52190d3f1ea2df93949ecd00e9be03f802943c90253bebd405c1dd7630f2af6760d
|
7
|
+
data.tar.gz: 38cb19db071c857a910bb8b41f3a5ff7fbdceae6467d8e9935d339f48601f4b859042d07d95caf201dc2bab7b30782a0a6e508a7c7b250856e31fca62c15fd52
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Recurly is packaged as a Ruby gem. We recommend you install it with
|
|
14
14
|
[Bundler](http://gembundler.com/) by adding the following line to your Gemfile:
|
15
15
|
|
16
16
|
``` ruby
|
17
|
-
gem 'recurly', '~> 2.
|
17
|
+
gem 'recurly', '~> 2.16.0'
|
18
18
|
```
|
19
19
|
|
20
20
|
Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
|
data/lib/recurly.rb
CHANGED
@@ -6,6 +6,7 @@ module Recurly
|
|
6
6
|
require 'recurly/resource'
|
7
7
|
require 'recurly/shipping_address'
|
8
8
|
require 'recurly/billing_info'
|
9
|
+
require 'recurly/custom_field'
|
9
10
|
require 'recurly/account'
|
10
11
|
require 'recurly/account_balance'
|
11
12
|
require 'recurly/add_on'
|
@@ -137,5 +138,3 @@ module Recurly
|
|
137
138
|
end
|
138
139
|
end
|
139
140
|
end
|
140
|
-
|
141
|
-
require 'rails/recurly' if defined? Rails::Railtie
|
data/lib/recurly/account.rb
CHANGED
@@ -42,6 +42,9 @@ module Recurly
|
|
42
42
|
# @return [Pager<CreditPayment>, []]
|
43
43
|
has_many :credit_payments, class_name: :CreditPayment, readonly: true
|
44
44
|
|
45
|
+
# @return [[CustomField], []]
|
46
|
+
has_many :custom_fields, class_name: :CustomField, readonly: false
|
47
|
+
|
45
48
|
# Get's the first redemption given a coupon code
|
46
49
|
# @deprecated Use #{redemptions} instead
|
47
50
|
# @param coupon_code [String] The coupon code for the redemption
|
@@ -149,6 +152,9 @@ module Recurly
|
|
149
152
|
if address.respond_to?(:changed?) && address.changed?
|
150
153
|
attrs['address'] = address
|
151
154
|
end
|
155
|
+
if custom_fields.any?(&:changed?)
|
156
|
+
attrs['custom_fields'] = custom_fields.select(&:changed?)
|
157
|
+
end
|
152
158
|
attrs
|
153
159
|
end
|
154
160
|
|
data/lib/recurly/api.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Recurly
|
2
|
+
# Recurly Documentation: https://dev.recurly.com/docs/custom-fields
|
3
|
+
class CustomField < Resource
|
4
|
+
|
5
|
+
define_attribute_methods %w(
|
6
|
+
name
|
7
|
+
value
|
8
|
+
)
|
9
|
+
|
10
|
+
# include the name with the serialized field, even though it can't change
|
11
|
+
def xml_keys
|
12
|
+
attributes.keys
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/recurly/invoice.rb
CHANGED
@@ -29,6 +29,10 @@ module Recurly
|
|
29
29
|
# @return [Pager<Adjustment>, []]
|
30
30
|
has_many :all_line_items, class_name: :Adjustment
|
31
31
|
|
32
|
+
# This will only be present if the invoice has > 500 transactions
|
33
|
+
# @return [Pager<Transaction>, []]
|
34
|
+
has_many :all_transactions, class_name: :Transaction
|
35
|
+
|
32
36
|
# @return [Pager<Redemption>, []]
|
33
37
|
has_many :redemptions
|
34
38
|
|
data/lib/recurly/money.rb
CHANGED
data/lib/recurly/plan.rb
CHANGED
data/lib/recurly/purchase.rb
CHANGED
@@ -123,6 +123,7 @@ module Recurly
|
|
123
123
|
customer_notes
|
124
124
|
vat_reverse_charge_notes
|
125
125
|
shipping_address_id
|
126
|
+
gateway_code
|
126
127
|
)
|
127
128
|
|
128
129
|
class << self
|
@@ -170,11 +171,30 @@ module Recurly
|
|
170
171
|
post(purchase, "#{collection_path}/pending")
|
171
172
|
end
|
172
173
|
|
174
|
+
# Allows the merchant to cancel an authorization.
|
175
|
+
#
|
176
|
+
# @param transaction_uuid [String] The uuid for the transaction representing the authorization. Can typically be found at invoice_collection.charge_invoice.transactions.first.uuid.
|
177
|
+
# @return [InvoiceCollection] The canceled invoice collection.
|
178
|
+
# @raise [Invalid] Raised if the authorization cannot be canceled.
|
179
|
+
def cancel!(transaction_uuid)
|
180
|
+
post(nil, "#{collection_path}/transaction-uuid-#{transaction_uuid}/cancel")
|
181
|
+
end
|
182
|
+
|
183
|
+
# Allows the merchants to initiate a capture transaction tied to the original authorization.
|
184
|
+
#
|
185
|
+
# @param transaction_uuid [String] The uuid for the transaction representing the authorization. Can typically be found at invoice_collection.charge_invoice.transactions.first.uuid.
|
186
|
+
# @return [InvoiceCollection] The captured invoice collection.
|
187
|
+
# @raise [Invalid] Raised if the authorization cannot be captured.
|
188
|
+
def capture!(transaction_uuid)
|
189
|
+
post(nil, "#{collection_path}/transaction-uuid-#{transaction_uuid}/capture")
|
190
|
+
end
|
191
|
+
|
173
192
|
def post(purchase, path)
|
174
|
-
|
193
|
+
body = purchase.nil? ? nil : purchase.to_xml
|
194
|
+
response = API.send(:post, path, body)
|
175
195
|
InvoiceCollection.from_response(response)
|
176
196
|
rescue API::UnprocessableEntity => e
|
177
|
-
purchase.apply_errors(e)
|
197
|
+
purchase.apply_errors(e) if purchase
|
178
198
|
Transaction::Error.validate!(e, nil)
|
179
199
|
raise Resource::Invalid.new(purchase)
|
180
200
|
end
|
data/lib/recurly/resource.rb
CHANGED
@@ -508,7 +508,7 @@ module Recurly
|
|
508
508
|
# @return [Proc, nil]
|
509
509
|
# @param collection_name [Symbol] Association name.
|
510
510
|
# @param options [Hash] A hash of association options.
|
511
|
-
# @option options [true, false] :readonly
|
511
|
+
# @option options [true, false] :readonly Define a setter when false, defaults to true
|
512
512
|
# [String] :class_name Actual associated resource class name
|
513
513
|
# if not same as collection_name.
|
514
514
|
def has_many(collection_name, options = {})
|
@@ -518,7 +518,7 @@ module Recurly
|
|
518
518
|
if self[collection_name]
|
519
519
|
self[collection_name]
|
520
520
|
else
|
521
|
-
attributes[collection_name] = []
|
521
|
+
attributes[collection_name.to_s] = []
|
522
522
|
end
|
523
523
|
end
|
524
524
|
if options.key?(:readonly) && options[:readonly] == false
|
data/lib/recurly/subscription.rb
CHANGED
@@ -20,6 +20,9 @@ module Recurly
|
|
20
20
|
# @return [Pager<Redemption>, []]
|
21
21
|
has_many :redemptions
|
22
22
|
|
23
|
+
# @return [[CustomField], []]
|
24
|
+
has_many :custom_fields, class_name: :CustomField, readonly: false
|
25
|
+
|
23
26
|
# @return [Account]
|
24
27
|
belongs_to :account
|
25
28
|
|
@@ -82,6 +85,13 @@ module Recurly
|
|
82
85
|
credit_customer_notes
|
83
86
|
remaining_pause_cycles
|
84
87
|
paused_at
|
88
|
+
auto_renew
|
89
|
+
renewal_billing_cycles
|
90
|
+
first_billing_date
|
91
|
+
first_bill_date
|
92
|
+
next_bill_date
|
93
|
+
current_term_started_at
|
94
|
+
current_term_ends_at
|
85
95
|
)
|
86
96
|
alias to_param uuid
|
87
97
|
|
@@ -281,6 +291,15 @@ module Recurly
|
|
281
291
|
super.merge :plan_code => plan_code
|
282
292
|
end
|
283
293
|
|
294
|
+
def changed_attributes
|
295
|
+
attrs = super
|
296
|
+
if custom_fields.any?(&:changed?)
|
297
|
+
attrs['custom_fields'] = custom_fields.select(&:changed?)
|
298
|
+
end
|
299
|
+
attrs
|
300
|
+
end
|
301
|
+
|
302
|
+
|
284
303
|
private
|
285
304
|
|
286
305
|
def clear_attributes_if_plan_code_changed attributes
|
data/lib/recurly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recurly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Recurly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -160,8 +160,6 @@ extra_rdoc_files:
|
|
160
160
|
files:
|
161
161
|
- README.md
|
162
162
|
- bin/recurly
|
163
|
-
- lib/rails/generators/recurly/config_generator.rb
|
164
|
-
- lib/rails/recurly.rb
|
165
163
|
- lib/recurly.rb
|
166
164
|
- lib/recurly/account.rb
|
167
165
|
- lib/recurly/account_balance.rb
|
@@ -174,6 +172,7 @@ files:
|
|
174
172
|
- lib/recurly/billing_info.rb
|
175
173
|
- lib/recurly/coupon.rb
|
176
174
|
- lib/recurly/credit_payment.rb
|
175
|
+
- lib/recurly/custom_field.rb
|
177
176
|
- lib/recurly/delivery.rb
|
178
177
|
- lib/recurly/error.rb
|
179
178
|
- lib/recurly/gift_card.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Recurly
|
2
|
-
class ConfigGenerator < Rails::Generators::Base
|
3
|
-
desc "Creates a configuration file at config/initializers/recurly.rb"
|
4
|
-
|
5
|
-
# Creates a configuration file at <tt>config/initializers/recurly.rb</tt>
|
6
|
-
# when running <tt>rails g recurly:config</tt>.
|
7
|
-
def create_recurly_file
|
8
|
-
create_file 'config/initializers/recurly.rb', <<EOF
|
9
|
-
|
10
|
-
# Required (this should contain subdomain for your recurly account)
|
11
|
-
Recurly.subdomain = ENV['RECURLY_SUBDOMAIN']
|
12
|
-
|
13
|
-
# Required (this is your "Private API Key" which can be found under "API Credentials" in the admin panel
|
14
|
-
Recurly.api_key = ENV['RECURLY_API_KEY']
|
15
|
-
|
16
|
-
# Optional (if you want to change the default currency from USD)
|
17
|
-
# Recurly.default_currency = 'USD'
|
18
|
-
|
19
|
-
# Optional (if you want to use Recurly.js you can store public_key here)
|
20
|
-
# Recurly.js.public_key = ENV['RECURLY_PUBLIC_API_KEY']
|
21
|
-
|
22
|
-
EOF
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/rails/recurly.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Recurly
|
2
|
-
class Railtie < Rails::Railtie
|
3
|
-
initializer :recurly_set_logger do
|
4
|
-
Recurly.logger = Rails.logger
|
5
|
-
end
|
6
|
-
|
7
|
-
initializer :recurly_set_accept_language do
|
8
|
-
prepend_method = :prepend_before_filter
|
9
|
-
if ActionController::Base.respond_to?(:prepend_before_action)
|
10
|
-
prepend_method = :prepend_before_action
|
11
|
-
end
|
12
|
-
|
13
|
-
ActionController::Base.send(prepend_method) do
|
14
|
-
Recurly::API.accept_language = request.env['HTTP_ACCEPT_LANGUAGE']
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|