recurly 2.18.5 → 2.18.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4baccdf365b116bf67d6881bfcb87895a1528baf6f265514167a7a727d072c88
4
- data.tar.gz: 0d67d21fe66bcf7e1a9354d8f90715fe5c1141822600f84057ae9e504b406dca
3
+ metadata.gz: 9385debc236700bed1b93ee013313ab4c70a7dfdea8c42e7d48a8d0dd755d26e
4
+ data.tar.gz: f8b0ee42838c58896a4c6c58b86795d75b2b952ba9abcf96424d751c93f24b75
5
5
  SHA512:
6
- metadata.gz: 5413f8214c2053c4d4b1965dd6c91844f1bb5b1dbf7f7b9da2f730096d37b69dacd1e5dde9292ad950783f17d13c1cb6e7d4505107a5c0e54179dd1587688cd3
7
- data.tar.gz: e0cdd2a64396ed0cfeef2fb31f49e181c1dd1a8d5120a8f82e4053f8eadf47df9bd8815c551fc5999584f6dc88c03a12c5c9cc2e65d20efc07f29a898fcfd227
6
+ metadata.gz: 9ec2b05f194f44f727bd6ad3c553be37559a3a40735d7b1408eb151ee242f79f3e6368418c76dcec8d60156ae7724c2943549031fa4587679b67bcbc3a2c6ec7
7
+ data.tar.gz: 0b4277c3af336d565b7d2797f22f1897a4827e790dffd6dc6455ebd0f3b383bbc86392e6c6931e2272dc0e434db2fbcd9031f5b619b039b4cd92deeb32d84f24
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.18.5'
17
+ gem 'recurly', '~> 2.18.10'
18
18
  ```
19
19
 
20
20
  Recurly will automatically use [Nokogiri](http://nokogiri.org/) (for a nice
@@ -40,6 +40,7 @@ module Recurly
40
40
  require 'recurly/gift_card'
41
41
  require 'recurly/purchase'
42
42
  require 'recurly/webhook'
43
+ require 'recurly/tier'
43
44
 
44
45
  @subdomain = nil
45
46
 
@@ -2,9 +2,11 @@ module Recurly
2
2
  class AddOn < Resource
3
3
  # @return [Plan]
4
4
  belongs_to :plan
5
+ has_many :tiers, class_name: :Tier, readonly: false
5
6
 
6
7
  define_attribute_methods %w(
7
8
  add_on_code
9
+ item_code
8
10
  name
9
11
  accounting_code
10
12
  default_quantity
@@ -19,10 +21,19 @@ module Recurly
19
21
  revenue_schedule_type
20
22
  created_at
21
23
  updated_at
24
+ tier_type
22
25
  )
23
26
  alias to_param add_on_code
24
27
  alias quantity default_quantity
25
28
 
29
+ def changed_attributes
30
+ attrs = super
31
+ if tiers.any?(&:changed?)
32
+ attrs['tiers'] = tiers.select(&:changed?)
33
+ end
34
+ attrs
35
+ end
36
+
26
37
  # Add-ons are only writeable and readable through {Plan} instances.
27
38
  embedded!
28
39
  private_class_method :find
@@ -37,6 +37,7 @@ module Recurly
37
37
  currency
38
38
  product_code
39
39
  item_code
40
+ external_sku
40
41
  start_date
41
42
  end_date
42
43
  created_at
@@ -18,7 +18,7 @@ module Recurly
18
18
  @@base_uri = "https://api.recurly.com/v2/"
19
19
  @@valid_domains = [".recurly.com"]
20
20
 
21
- RECURLY_API_VERSION = '2.24'
21
+ RECURLY_API_VERSION = '2.27'
22
22
 
23
23
  FORMATS = Helper.hash_with_indifferent_read_access(
24
24
  'pdf' => 'application/pdf',
@@ -8,6 +8,8 @@ module Recurly
8
8
  AMAZON_ATTRIBUTES = %w(amazon_billing_agreement_id amazon_region).freeze
9
9
  PAYPAL_ATTRIBUTES = %w(paypal_billing_agreement_id).freeze
10
10
  ROKU_ATTRIBUTES = %w(roku_billing_agreement_id last_four).freeze
11
+ SEPA_ATTRIBUTES = %w(iban).freeze
12
+ BACS_ATTRIBUTES = %w(account_number sort_code type).freeze
11
13
 
12
14
  # @return [Account]
13
15
  belongs_to :account
@@ -36,32 +38,41 @@ module Recurly
36
38
  fraud_session_id
37
39
  three_d_secure_action_result_token_id
38
40
  transaction_type
39
- ) | CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES | AMAZON_ATTRIBUTES | PAYPAL_ATTRIBUTES | ROKU_ATTRIBUTES
40
-
41
- # @return ["credit_card", "paypal", "amazon", "bank_account", "roku", nil] The type of billing info.
42
- attr_reader :type
41
+ mandate_reference
42
+ ) | CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES | AMAZON_ATTRIBUTES | PAYPAL_ATTRIBUTES | ROKU_ATTRIBUTES | SEPA_ATTRIBUTES | BACS_ATTRIBUTES
43
43
 
44
44
  # @return [String]
45
45
  def inspect
46
46
  attributes = self.class.attribute_names
47
47
  case type
48
48
  when 'credit_card'
49
- attributes -= (AMAZON_ATTRIBUTES + PAYPAL_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES + ROKU_ATTRIBUTES)
49
+ attributes -= (AMAZON_ATTRIBUTES + PAYPAL_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES + ROKU_ATTRIBUTES + SEPA_ATTRIBUTES + BACS_ATTRIBUTES)
50
50
  attributes |= CREDIT_CARD_ATTRIBUTES
51
51
  when 'paypal'
52
- attributes -= (CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES + AMAZON_ATTRIBUTES + ROKU_ATTRIBUTES)
52
+ attributes -= (CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES + AMAZON_ATTRIBUTES + ROKU_ATTRIBUTES + SEPA_ATTRIBUTES + BACS_ATTRIBUTES)
53
53
  when 'amazon'
54
- attributes -= (CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES + PAYPAL_ATTRIBUTES + ROKU_ATTRIBUTES)
54
+ attributes -= (CREDIT_CARD_ATTRIBUTES | BANK_ACCOUNT_ATTRIBUTES + PAYPAL_ATTRIBUTES + ROKU_ATTRIBUTES + SEPA_ATTRIBUTES + BACS_ATTRIBUTES)
55
55
  when 'bank_account'
56
- attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + ROKU_ATTRIBUTES)
56
+ attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + ROKU_ATTRIBUTES + SEPA_ATTRIBUTES + BACS_ATTRIBUTES)
57
57
  attributes |= BANK_ACCOUNT_ATTRIBUTES
58
58
  when 'roku'
59
- attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES)
59
+ attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES + SEPA_ATTRIBUTES + BACS_ATTRIBUTES)
60
60
  attributes |= ROKU_ATTRIBUTES
61
+ when 'sepa'
62
+ attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES + ROKU_ATTRIBUTES + BACS_ATTRIBUTES)
63
+ attributes |= SEPA_ATTRIBUTES
64
+ when 'bacs'
65
+ attributes -= (CREDIT_CARD_ATTRIBUTES + PAYPAL_ATTRIBUTES + AMAZON_ATTRIBUTES + BANK_ACCOUNT_ATTRIBUTES + ROKU_ATTRIBUTES + SEPA_ATTRIBUTES)
66
+ attributes |= BACS_ATTRIBUTES
61
67
  end
62
68
  super attributes
63
69
  end
64
70
 
71
+ # @return ["credit_card", "paypal", "amazon", "bank_account", "roku", "sepa", "bacs", nil] The type of billing info.
72
+ def type
73
+ self[:type] || @type
74
+ end
75
+
65
76
  class << self
66
77
  # Overrides the inherited member_path method to allow for billing info's
67
78
  # irregular URL structure.
@@ -24,12 +24,9 @@ module Recurly
24
24
  attrs
25
25
  end
26
26
 
27
- # method should be changed to use a link once it is added to api
28
- # example:
29
- # return false unless link? :reactivate
30
- # reload follow_link :reactivate
31
27
  def reactivate
32
- reload API.put("#{uri}/reactivate")
28
+ return false unless link? :reactivate
29
+ reload follow_link :reactivate
33
30
  true
34
31
  end
35
32
 
@@ -32,6 +32,7 @@ module Recurly
32
32
  tax_code
33
33
  trial_requires_billing_info
34
34
  auto_renew
35
+ allow_any_item_on_subscriptions
35
36
  created_at
36
37
  updated_at
37
38
  )
@@ -174,6 +174,35 @@ module Recurly
174
174
  sub.tap {|e| e.currency = currency} if sub.is_a? Subscription
175
175
  end
176
176
 
177
+ # Convert free trial to paid subscription when transaction_type is "moto"
178
+ # which stands for "Mail Order Telephone Order".
179
+ #
180
+ # @return true
181
+ def convert_trial_moto()
182
+ builder = XML.new("<subscription/>")
183
+ builder.add_element('transaction_type', "moto")
184
+ reload API.put("#{uri}/convert_trial", builder.to_s)
185
+ true
186
+ end
187
+
188
+ # Convert free trial to paid subscription. Optionally uses a 3ds token.
189
+ #
190
+ # @param three_d_secure_action_result_token_id [String] three_d_secure_action_result_token_id
191
+ # returned by Recurly.js referencing the result of the 3DS authentication for PSD2
192
+ # @return true when payment is accepted
193
+ def convert_trial(three_d_secure_action_result_token_id = nil)
194
+ body = if three_d_secure_action_result_token_id != nil
195
+ builder = Recurly::XML.new("<subscription/>")
196
+ account = builder.add_element('account')
197
+ billing_info = account.add_element('billing_info')
198
+ billing_info.add_element('three_d_secure_action_result_token_id', three_d_secure_action_result_token_id)
199
+ builder.to_s
200
+ end
201
+
202
+ reload API.put("#{uri}/convert_trial", body)
203
+ true
204
+ end
205
+
177
206
  # Cancel a subscription so that it will not renew.
178
207
  #
179
208
  # @param [String] optional timeframe. Choose one of "bill_date" or "term_end"
@@ -25,7 +25,12 @@ module Recurly
25
25
  def << add_on
26
26
  add_on = SubscriptionAddOn.new(add_on, @subscription)
27
27
 
28
- exist = @add_ons.find { |a| a.add_on_code == add_on.add_on_code }
28
+ exist = @add_ons.find do |a|
29
+ source1 = a.add_on_source || "plan_add_on"
30
+ source2 = add_on.add_on_source || "plan_add_on"
31
+ a.add_on_code == add_on.add_on_code && source1 == source2
32
+ end
33
+
29
34
  if exist
30
35
  exist.quantity ||= 1
31
36
  exist.quantity += add_on.quantity || 1
@@ -13,6 +13,7 @@ module Recurly
13
13
  add_on_type
14
14
  usage_type
15
15
  usage_percentage
16
+ add_on_source
16
17
  )
17
18
 
18
19
  attr_reader :subscription
@@ -28,6 +29,7 @@ module Recurly
28
29
  if add_on.unit_amount_in_cents
29
30
  self.unit_amount_in_cents = add_on.unit_amount_in_cents.to_i
30
31
  end
32
+ self.add_on_source = add_on.add_on_source
31
33
  when Hash
32
34
  self.attributes = add_on
33
35
  when String, Symbol
@@ -0,0 +1,17 @@
1
+ module Recurly
2
+ class Tier < Resource
3
+
4
+ belongs_to :add_on
5
+
6
+ define_attribute_methods %w(
7
+ ending_quantity
8
+ unit_amount_in_cents
9
+ )
10
+
11
+ def xml_keys
12
+ attributes.keys
13
+ end
14
+
15
+ embedded! true
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
1
  module Recurly
2
2
  module Version
3
- VERSION = "2.18.5"
3
+ VERSION = "2.18.10"
4
4
 
5
5
  class << self
6
6
  def inspect
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.18.5
4
+ version: 2.18.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-22 00:00:00.000000000 Z
11
+ date: 2020-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -249,6 +249,7 @@ files:
249
249
  - lib/recurly/subscription_add_on.rb
250
250
  - lib/recurly/tax_detail.rb
251
251
  - lib/recurly/tax_type.rb
252
+ - lib/recurly/tier.rb
252
253
  - lib/recurly/transaction.rb
253
254
  - lib/recurly/transaction/errors.rb
254
255
  - lib/recurly/usage.rb