chargebee 2.24.0 → 2.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a9362e4ef388e73d2664362adfc29ad58156c08
4
- data.tar.gz: 813149625fe51364a45da1c0e8fd97bd78ceb818
3
+ metadata.gz: 47e67b64038c0962879a8cdc8b5fcfdb9188f7a6
4
+ data.tar.gz: 21248229802c3b25e40c6a43a7ccc1a0d23b7fb4
5
5
  SHA512:
6
- metadata.gz: 65f7645d7b39d76d4c234828616995ddb03159978a0cf542b2732cafb81dab70923ee50d41c1ac893294197faff4870a729191702ee9578f6d9ecaa21e662b44
7
- data.tar.gz: 90c6412b8612dd53ad6a1d4c7eb54a4da0067e81aacb6814531329c27ebdf82c03d50ec853c8f29e834e0a76802cb44f03455218bc72687c5a50b40902682dc6
6
+ metadata.gz: 2c5dc16a5704ca0b088200f37d95b03d36c5e94e4723f21f636037c883e2073e1ce7d2191a8d0633f9e5549aea03dfbcf3a285aefa799051ee03fea8d7c69e73
7
+ data.tar.gz: 8809d69227fe4269056c867f8f98965195f34ea454f2deb0c843eb268c99060ad0b0f5d2b6d4dcc8ece1b0b75d4d4f9226ce5b33104f5e1354a402c668069567
data/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
1
+ ### v2.26.0 (2023-05-16)
2
+ * * *
3
+
4
+ #### New Feature:
5
+ * Added utility to pass **Idempotency key** along with request headers to allow a safe retry of POST requests.
6
+ * Added is_idempotency_replayed() utility to differentiate between original and replayed requests.
7
+ * Added get_response_headers() utility to fetch the response headers.
8
+
9
+
10
+ ### v2.25.0 (2023-04-28)
11
+ * * *
12
+
13
+ #### Fixes:
14
+ * SubscriptionId attribute has been maid as required in InAppSubscription resource.
15
+
16
+ #### New Attributes:
17
+ * TotalContractValueBeforeTax has been added to the ContractTerm resource.
18
+ * TotalContractValueBeforeTax#SubscriptionContractTerm has been added to the Subscription resource.
19
+ * TotalContractValueBeforeTax#SubscriptionEstimateContractTerm has been addded to the SubscriptionEstimate resource.
20
+ * CouponConstraints has been added to the Coupon resource.
21
+
22
+ #### New Resource:
23
+ * NonSubscription have been added.
24
+
25
+ #### Added Input Parameters:
26
+ * contract_term[total_amount_raised_before_tax]#ImportSubscriptionRequest, contract_term[total_amount_raised_before_tax]#ImportForItemsRequest, contract_term[total_amount_raised_before_tax]#ImportContractTermRequest and contract_term[total_amount_raised_before_tax]#ImportForCustomerRequest parameter has been added to Subscription resource.
27
+ * contract_term[total_contract_value_before_tax]#ImportContractTermRequest parameter has been added to Subscription resource.
28
+ * coupon_constraints[entity_type]#CreateForItemsRequestParams, coupon_constraints[type]#CreateForItemsRequestParams and coupon_constraints[value]#CreateForItemsRequestParams parameter has been added to the Coupon resource.
29
+ * coupon_constraints[entity_type]#UpdateForItemsRequestParams, coupon_constraints[type]#UpdateForItemsRequestParams and coupon_constraints[value]#UpdateForItemsRequestParams parameter has been added to the Coupon resource.
30
+ * export_type#CustomersRequest and export_type#SubscriptionsRequest parameter has been added to the Export resource.
31
+
32
+ #### New Enum Class:
33
+ * ExportType has been added.
34
+
35
+ #### New Enum values:
36
+ * pending_authorization has been added to StatusEnum#PaymentIntentPaymentAttempt to the PaymentIntent resource.
37
+
38
+
1
39
  ### v2.24.0 (2023-03-24)
2
40
  * * *
3
41
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargebee (2.24.0)
4
+ chargebee (2.26.0)
5
5
  cgi (>= 0.1.0, < 1.0.0)
6
6
  json_pure (~> 2.1)
7
7
  rest-client (>= 1.8, <= 2.0.2)
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Chargebee Ruby Client Library - API V2
2
+
3
+ [![gem](https://img.shields.io/gem/v/chargebee.svg?maxAge=2592000)](https://rubygems.org/gems/chargebee)
4
+ [![gem](https://img.shields.io/gem/dtv/chargebee.svg?maxAge=2592000)](https://rubygems.org/gems/chargebee)
5
+
6
+ This is the Ruby Library for integrating with Chargebee. Sign up for a Chargebee account {here}[https://www.chargebee.com].
7
+
8
+ Chargebee now supports two API versions - [V1](https://apidocs.chargebee.com/docs/api/v1) and [V2](https://apidocs.chargebee.com/docs/api), of which V2 is the latest release and all future developments will happen in V2. This library is for <b>API version V2</b>. If you’re looking for V1, head to [chargebee-v1 branch](https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1).
9
+
10
+ ## Installation
11
+
12
+ Install the latest version of the gem with the following command...
13
+
14
+ $ sudo gem install chargebee -v '~>2'
15
+
16
+
17
+ ## Requirements
18
+
19
+ * Ruby 1.9.3 or above.
20
+ * rest-client
21
+
22
+ ## Documentation
23
+
24
+ See our [Ruby API Reference](https://apidocs.chargebee.com/docs/api?lang=ruby "API Reference").
25
+
26
+ ## Usage
27
+
28
+ ### To create a new subscription:
29
+
30
+ ```ruby
31
+ ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
32
+ result = ChargeBee::Subscription.create({
33
+ :id => "sub_KyVqDh__dev__NTn4VZZ1",
34
+ :plan_id => "basic",
35
+ })
36
+ subscription = result.subscription
37
+ puts "created subscription is #{subscription}"
38
+ ```
39
+
40
+ ### Create an Idempotent Request
41
+
42
+ [Idempotency keys](https://apidocs.chargebee.com/docs/api) are passed along with request headers to allow a safe retry of POST requests.
43
+
44
+ ```ruby
45
+ require 'chargebee'
46
+ ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
47
+ result = ChargeBee::Customer.create({
48
+ :first_name => "John",
49
+ :last_name => "Doe",
50
+ :email => "john@test.com",
51
+ :locale => "fr-CA",
52
+ :billing_address => {
53
+ :first_name => "John",
54
+ :last_name => "Doe",
55
+ :line1 => "PO Box 9999",
56
+ :city => "Walnut",
57
+ :state => "California",
58
+ :zip => "91789",
59
+ :country => "US"
60
+ }
61
+ },
62
+ nil,
63
+ {"chargebee-idempotency-key" => "<<UUID>>"} # Replace <<UUID>> with a unique string
64
+ )
65
+ customer = result.customer
66
+ card = result.card
67
+ responseHeader = result.get_response_headers # Retrieves response headers
68
+ puts(responseHeader)
69
+ idempotencyReplayedValue = result.is_idempotency_replayed # Retrieves Idempotency replayed header value
70
+ puts(idempotencyReplayedValue)
71
+ ```
72
+ `is_idempotency_replayed` method can be accessed to differentiate between original and replayed requests.
73
+
74
+ ## License
75
+
76
+ See the LICENSE file.
77
+
data/chargebee.gemspec CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.5'
5
5
  s.required_ruby_version = '>= 1.9.3'
6
6
  s.name = 'chargebee'
7
- s.version = '2.24.0'
8
- s.date = '2023-03-24'
7
+ s.version = '2.26.0'
8
+ s.date = '2023-05-16'
9
9
  s.summary = "Ruby client for Chargebee API."
10
10
  s.description = "Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com."
11
11
 
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  Gemfile
32
32
  Gemfile.lock
33
33
  LICENSE
34
+ README.md
34
35
  README.rdoc
35
36
  Rakefile
36
37
  chargebee.gemspec
@@ -73,6 +74,7 @@ Gem::Specification.new do |s|
73
74
  lib/chargebee/models/item_family.rb
74
75
  lib/chargebee/models/item_price.rb
75
76
  lib/chargebee/models/model.rb
77
+ lib/chargebee/models/non_subscription.rb
76
78
  lib/chargebee/models/order.rb
77
79
  lib/chargebee/models/payment_intent.rb
78
80
  lib/chargebee/models/payment_source.rb
@@ -10,12 +10,17 @@ module ChargeBee
10
10
 
11
11
  attr_reader :next_offset
12
12
 
13
- def initialize(response, next_offset=nil)
13
+ def initialize(response, next_offset=nil, rheaders = nil)
14
14
  @response = response
15
+ @rheaders = rheaders
15
16
  @list = Array.new
16
17
  @next_offset = JSON.parse(next_offset).to_s if next_offset
17
18
  initItems()
18
19
  end
20
+
21
+ def get_response_headers()
22
+ @rheaders
23
+ end
19
24
 
20
25
  private
21
26
  def initItems()
@@ -2,7 +2,8 @@ module ChargeBee
2
2
  class ContractTerm < Model
3
3
 
4
4
  attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end,
5
- :total_contract_value, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
5
+ :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at,
6
+ :subscription_id, :remaining_billing_cycles
6
7
 
7
8
  # OPERATIONS
8
9
  #-----------
@@ -9,11 +9,15 @@ module ChargeBee
9
9
  attr_accessor :item_type, :currencies, :item_family_ids, :item_price_periods
10
10
  end
11
11
 
12
+ class CouponConstraint < Model
13
+ attr_accessor :entity_type, :type, :value
14
+ end
15
+
12
16
  attr_accessor :id, :name, :invoice_name, :discount_type, :discount_percentage, :discount_amount,
13
17
  :discount_quantity, :currency_code, :duration_type, :duration_month, :valid_till, :max_redemptions,
14
18
  :status, :apply_discount_on, :apply_on, :plan_constraint, :addon_constraint, :created_at, :archived_at,
15
19
  :resource_version, :updated_at, :included_in_mrr, :period, :period_unit, :plan_ids, :addon_ids,
16
- :item_constraints, :item_constraint_criteria, :redemptions, :invoice_notes, :meta_data
20
+ :item_constraints, :item_constraint_criteria, :redemptions, :invoice_notes, :meta_data, :coupon_constraints
17
21
 
18
22
  # OPERATIONS
19
23
  #-----------
@@ -0,0 +1,14 @@
1
+ module ChargeBee
2
+ class NonSubscription < Model
3
+
4
+ attr_accessor :app_id, :invoice_id, :customer_id, :charge_id
5
+
6
+ # OPERATIONS
7
+ #-----------
8
+
9
+ def self.process_receipt(id, params, env=nil, headers={})
10
+ Request.send('post', uri_path("non_subscriptions",id.to_s,"one_time_purchase"), params, env, headers)
11
+ end
12
+
13
+ end # ~NonSubscription
14
+ end # ~ChargeBee
@@ -38,7 +38,7 @@ module ChargeBee
38
38
  end
39
39
 
40
40
  class ContractTerm < Model
41
- attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
41
+ attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
42
42
  end
43
43
 
44
44
  class Discount < Model
@@ -5,8 +5,8 @@ module ChargeBee
5
5
  attr_accessor :entitlement_overrides
6
6
  end
7
7
 
8
- attr_accessor :id, :subscription_id, :feature_id, :feature_name, :feature_unit, :value, :name,
9
- :is_overridden, :is_enabled, :expires_at, :components
8
+ attr_accessor :subscription_id, :feature_id, :feature_name, :feature_unit, :value, :name, :is_overridden,
9
+ :is_enabled, :expires_at, :components
10
10
 
11
11
  # OPERATIONS
12
12
  #-----------
@@ -6,7 +6,7 @@ module ChargeBee
6
6
  end
7
7
 
8
8
  class ContractTerm < Model
9
- attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
9
+ attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
10
10
  end
11
11
 
12
12
  attr_accessor :id, :currency_code, :status, :trial_end_action, :next_billing_at, :pause_date,
@@ -15,11 +15,11 @@ module ChargeBee
15
15
  def self.send(method, url, params={}, env=nil, headers={})
16
16
  env ||= ChargeBee.default_env
17
17
  ser_params = Util.serialize(params)
18
- resp = Rest.request(method, url, env, ser_params||={}, headers)
18
+ resp, rheaders = Rest.request(method, url, env, ser_params||={}, headers)
19
19
  if resp.has_key?(:list)
20
- ListResult.new(resp[:list], resp[:next_offset])
20
+ ListResult.new(resp[:list], resp[:next_offset], rheaders)
21
21
  else
22
- Result.new(resp)
22
+ Result.new(resp, rheaders)
23
23
  end
24
24
  end
25
25
 
@@ -54,6 +54,7 @@ module ChargeBee
54
54
  rescue Exception => e
55
55
  raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
56
56
  end
57
+ rheaders = response.headers
57
58
  rbody = response.body
58
59
  rcode = response.code
59
60
  begin
@@ -68,7 +69,7 @@ module ChargeBee
68
69
  end
69
70
  end
70
71
  resp = Util.symbolize_keys(resp)
71
- resp
72
+ return resp, rheaders
72
73
  end
73
74
 
74
75
  def self.handle_for_error(e, rcode=nil, rbody=nil)
@@ -1,10 +1,26 @@
1
1
  module ChargeBee
2
2
  class Result
3
3
 
4
- def initialize(response)
5
- @response = response
4
+ IDEMPOTENCY_REPLAYED_HEADER = :chargebee_idempotency_replayed
5
+
6
+ def initialize(response, rheaders = nil)
7
+ @response = response
8
+ @rheaders = rheaders
9
+ end
10
+
11
+ def get_response_headers()
12
+ @rheaders
6
13
  end
7
14
 
15
+ def is_idempotency_replayed()
16
+ replayed_header = get_response_headers[IDEMPOTENCY_REPLAYED_HEADER]
17
+ if replayed_header != nil
18
+ return !!replayed_header
19
+ else
20
+ return false
21
+ end
22
+ end
23
+
8
24
  def subscription()
9
25
  subscription = get(:subscription, Subscription,
10
26
  {:subscription_items => Subscription::SubscriptionItem, :item_tiers => Subscription::ItemTier, :charged_items => Subscription::ChargedItem, :addons => Subscription::Addon, :event_based_addons => Subscription::EventBasedAddon, :charged_event_based_addons => Subscription::ChargedEventBasedAddon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress, :referral_info => Subscription::ReferralInfo, :contract_term => Subscription::ContractTerm, :discounts => Subscription::Discount});
@@ -178,7 +194,7 @@ module ChargeBee
178
194
 
179
195
  def coupon()
180
196
  coupon = get(:coupon, Coupon,
181
- {:item_constraints => Coupon::ItemConstraint, :item_constraint_criteria => Coupon::ItemConstraintCriteria});
197
+ {:item_constraints => Coupon::ItemConstraint, :item_constraint_criteria => Coupon::ItemConstraintCriteria, :coupon_constraints => Coupon::CouponConstraint});
182
198
  return coupon;
183
199
  end
184
200
 
@@ -313,6 +329,11 @@ module ChargeBee
313
329
  return in_app_subscription;
314
330
  end
315
331
 
332
+ def non_subscription()
333
+ non_subscription = get(:non_subscription, NonSubscription);
334
+ return non_subscription;
335
+ end
336
+
316
337
  def entitlement_override()
317
338
  entitlement_override = get(:entitlement_override, EntitlementOverride);
318
339
  return entitlement_override;
data/lib/chargebee.rb CHANGED
@@ -68,7 +68,7 @@ require File.dirname(__FILE__) + '/chargebee/models/token.rb'
68
68
 
69
69
  module ChargeBee
70
70
 
71
- VERSION = '2.24.0'
71
+ VERSION = '2.26.0'
72
72
 
73
73
  @@default_env = nil
74
74
  @@verify_ca_certs = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargebee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.24.0
4
+ version: 2.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajaraman S
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-24 00:00:00.000000000 Z
12
+ date: 2023-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure
@@ -107,6 +107,7 @@ files:
107
107
  - Gemfile
108
108
  - Gemfile.lock
109
109
  - LICENSE
110
+ - README.md
110
111
  - README.rdoc
111
112
  - Rakefile
112
113
  - chargebee.gemspec
@@ -149,6 +150,7 @@ files:
149
150
  - lib/chargebee/models/item_family.rb
150
151
  - lib/chargebee/models/item_price.rb
151
152
  - lib/chargebee/models/model.rb
153
+ - lib/chargebee/models/non_subscription.rb
152
154
  - lib/chargebee/models/order.rb
153
155
  - lib/chargebee/models/payment_intent.rb
154
156
  - lib/chargebee/models/payment_source.rb