chargebee 2.62.0 → 2.64.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
  SHA256:
3
- metadata.gz: ff7a17d81ecf4007b81e194edf0ec10af8faff50b39f1773b65db699958b3285
4
- data.tar.gz: 24ffe480a8a4d1d7035d1ecc4f61c5bf4dffb5b788a52738ab622df27e3dc15d
3
+ metadata.gz: fe14c7cb3dc2b603cd7c604c383759913f023c9a7ea6a35c9a1ce4856f4525ce
4
+ data.tar.gz: 4e6d015e8e33c469f4a389be822ca917ebc2075fccc63b7c1ff6591190716b7a
5
5
  SHA512:
6
- metadata.gz: 3400c6d3c123c1893e8e9e25468984ac08d8224c1af84983f96d8e25f60f57afea0c6124ed7f85cb98d875e912ac6cd9af26a503b2324d02944b1a3f4641d426
7
- data.tar.gz: '09d289c3b9df185e11b87a79ff76df2a06426ae9f4b0baa2187378b33af04cd78c4212a009b0f96d0f7bf47761a148d4bb228f093e35551b883f5b0ab4a6e4fe'
6
+ metadata.gz: c4c935501f85f6a9ec2e3927df5c7e89b28039825a2e12c8434a38266f47bc0447474bb6392f2ec6b37406c7e893f2324a98ab0843e81b182d321a60dfa148fb
7
+ data.tar.gz: c6a285b0be75c689686eef529c6ae9b0447ecc1958341e8a9aa5a232ee45c648016d9a8ca71b08a0bc4994adf8b1e62af4cf79bda03c5286317c04717823f3ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,45 @@
1
+ ### v2.64.0 (2025-11-10)
2
+ * * *
3
+
4
+ ### Error Handling
5
+ - Added new `ForbiddenError` class that inherits from `Error`
6
+ - Enhanced `handle_for_error` method to detect and handle 403 status codes
7
+ - Provides clear error message: "Access forbidden. You do not have permission to access this resource."
8
+
9
+ ### Code Quality Improvements
10
+ - Renamed `lib/chargebee/nativeRequest.rb` → `lib/chargebee/native_request.rb` to follow Ruby naming conventions
11
+ - Refactored `handle_for_error` to return error objects instead of raising them inline (cleaner separation of concerns)
12
+ - Added YARD documentation for `handle_for_error` method
13
+
14
+ ### Testing
15
+ - Added comprehensive test coverage for 403 error scenarios
16
+
17
+ ### v2.63.0 (2025-10-28)
18
+ * * *
19
+
20
+ ### New Attributes:
21
+ * reference_transactions has been added to Invoice.
22
+ * payment_attempts[] has been added to PaymentIntent.
23
+ * checkout_details has been added to PaymentIntent#PaymentAttempt.
24
+ * line_item_id has been added to CreditNoteEstimate#Discount.
25
+ * line_item_id has been added to CreditNote#Discount.
26
+ * line_item_id has been added to InvoiceEstimate#Discount.
27
+ * line_item_id has been added to Invoice#Discount.
28
+ * line_item_id has been added to InvoiceEstimate#Discount.
29
+ * line_item_id has been added to Quote#Discount.
30
+ * line_item_id has been added to QuoteLineGroup#Discount.
31
+
32
+ ### Modified Attributes:
33
+ * omnichannel_subscription_item_offers has been made optional attribute from required attribute.
34
+
35
+ ### New Input Parameters:
36
+ * discount[line_item_id] has been added to CreditNote#ImportCreditNoteRequest.
37
+ * discount[line_item_id] has been added to CreditNote#ImportInvoiceRequest.
38
+
39
+ ### New Enums:
40
+ * OMNICHANNEL_TRANSACTION_CREATED has been added to EventTypeEnum.
41
+ * DEUTSCHE_BANK has been added to Gateway.
42
+
1
43
  ### v2.62.0 ( 2025-09-23)
2
44
  * * *
3
45
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargebee (2.62.0)
4
+ chargebee (2.64.0)
5
5
  cgi (>= 0.1.0, < 1.0.0)
6
6
 
7
7
  GEM
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.62.0'
8
- s.date = '2025-09-23'
7
+ s.version = '2.64.0'
8
+ s.date = '2025-11-10'
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
  s.metadata = {
@@ -140,7 +140,7 @@ Gem::Specification.new do |s|
140
140
  lib/chargebee/models/usage_file.rb
141
141
  lib/chargebee/models/virtual_bank_account.rb
142
142
  lib/chargebee/models/webhook_endpoint.rb
143
- lib/chargebee/nativeRequest.rb
143
+ lib/chargebee/native_request.rb
144
144
  lib/chargebee/request.rb
145
145
  lib/chargebee/rest.rb
146
146
  lib/chargebee/result.rb
@@ -8,6 +8,8 @@ module ChargeBee
8
8
  end
9
9
  end
10
10
 
11
+ class ForbiddenError < Error; end
12
+
11
13
  class IOError < Error; end
12
14
 
13
15
  class APIError < Error
@@ -22,7 +22,7 @@ module ChargeBee
22
22
  end
23
23
 
24
24
  class Discount < Model
25
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
25
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
26
26
  end
27
27
 
28
28
  class Tax < Model
@@ -18,7 +18,7 @@ module ChargeBee
18
18
  end
19
19
 
20
20
  class Discount < Model
21
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
21
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
22
22
  end
23
23
 
24
24
  class Tax < Model
@@ -26,7 +26,7 @@ module ChargeBee
26
26
  end
27
27
 
28
28
  class Discount < Model
29
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
29
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
30
30
  end
31
31
 
32
32
  class Tax < Model
@@ -41,6 +41,10 @@ module ChargeBee
41
41
  attr_accessor :txn_id, :applied_amount, :applied_at, :txn_status, :txn_date, :txn_amount
42
42
  end
43
43
 
44
+ class ReferenceTransaction < Model
45
+ attr_accessor :applied_amount, :applied_at, :txn_id, :txn_status, :txn_date, :txn_amount, :txn_type, :amount_capturable, :authorization_reason
46
+ end
47
+
44
48
  class DunningAttempt < Model
45
49
  attr_accessor :attempt, :transaction_id, :dunning_type, :created_at, :txn_status, :txn_amount
46
50
  end
@@ -93,10 +97,10 @@ module ChargeBee
93
97
  :first_invoice, :new_sales_amount, :has_advance_charges, :term_finalized, :is_gifted, :generated_at,
94
98
  :expected_payment_date, :amount_to_collect, :round_off_amount, :line_items, :line_item_tiers,
95
99
  :line_item_discounts, :line_item_taxes, :line_item_credits, :line_item_addresses, :discounts,
96
- :taxes, :tax_origin, :linked_payments, :dunning_attempts, :applied_credits, :adjustment_credit_notes,
97
- :issued_credit_notes, :linked_orders, :notes, :shipping_address, :billing_address, :statement_descriptor,
98
- :einvoice, :void_reason_code, :deleted, :tax_category, :vat_number_prefix, :channel, :business_entity_id,
99
- :site_details_at_creation
100
+ :taxes, :tax_origin, :linked_payments, :reference_transactions, :dunning_attempts, :applied_credits,
101
+ :adjustment_credit_notes, :issued_credit_notes, :linked_orders, :notes, :shipping_address, :billing_address,
102
+ :statement_descriptor, :einvoice, :void_reason_code, :deleted, :tax_category, :vat_number_prefix,
103
+ :channel, :business_entity_id, :site_details_at_creation
100
104
 
101
105
  # OPERATIONS
102
106
  #-----------
@@ -26,7 +26,7 @@ module ChargeBee
26
26
  end
27
27
 
28
28
  class Discount < Model
29
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
29
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
30
30
  end
31
31
 
32
32
  class Tax < Model
@@ -2,12 +2,16 @@ module ChargeBee
2
2
  class PaymentIntent < Model
3
3
 
4
4
  class PaymentAttempt < Model
5
- attr_accessor :id, :status, :payment_method_type, :id_at_gateway, :error_code, :error_text, :created_at, :modified_at, :error_detail
5
+ attr_accessor :id, :status, :payment_method_type, :id_at_gateway, :error_code, :error_text, :checkout_details, :created_at, :modified_at, :error_detail
6
+ end
7
+
8
+ class PaymentAttempt < Model
9
+ attr_accessor :id, :status, :payment_method_type, :id_at_gateway, :error_code, :error_text, :checkout_details, :created_at, :modified_at, :error_detail
6
10
  end
7
11
 
8
12
  attr_accessor :id, :status, :currency_code, :amount, :gateway_account_id, :expires_at, :reference_id,
9
13
  :payment_method_type, :success_url, :failure_url, :created_at, :modified_at, :resource_version,
10
- :updated_at, :customer_id, :gateway, :active_payment_attempt, :business_entity_id
14
+ :updated_at, :customer_id, :gateway, :active_payment_attempt, :payment_attempts, :business_entity_id
11
15
 
12
16
  # OPERATIONS
13
17
  #-----------
@@ -18,7 +18,7 @@ module ChargeBee
18
18
  end
19
19
 
20
20
  class Discount < Model
21
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
21
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
22
22
  end
23
23
 
24
24
  class Tax < Model
@@ -14,7 +14,7 @@ module ChargeBee
14
14
  end
15
15
 
16
16
  class Discount < Model
17
- attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
17
+ attr_accessor :amount, :description, :line_item_id, :entity_type, :discount_type, :entity_id, :coupon_set_code
18
18
  end
19
19
 
20
20
  class Tax < Model
@@ -167,26 +167,33 @@ module ChargeBee
167
167
  end
168
168
  end
169
169
 
170
+ # Handle errors returned by the ChargeBee API.
171
+ #
172
+ # @param rcode [Integer] HTTP status code.
173
+ # @param rbody [String] HTTP response body.
174
+ #
175
+ # @return [ChargeBee::Error] Appropriate ChargeBee error object.
170
176
  def self.handle_for_error(rcode, rbody)
171
177
  return Error.new("No response returned by ChargeBee API. HTTP status code: #{rcode}") if rcode == 204
178
+ return ForbiddenError.new("Access forbidden. You do not have permission to access this resource.") if rcode == 403
172
179
  begin
173
180
  error_obj = JSON.parse(rbody)
174
181
  error_obj = Util.symbolize_keys(error_obj)
175
182
  rescue Exception => e
176
- raise Error.new("Error response not in JSON format. The http status code is #{rcode} \n #{rbody.inspect}", e)
183
+ return Error.new("Error response not in JSON format. The http status code is #{rcode} \n #{rbody.inspect}", e)
177
184
  end
178
- type = error_obj[:type]
179
- case type
185
+
186
+ case error_obj[:type]
180
187
  when "payment"
181
- raise PaymentError.new(rcode, error_obj)
188
+ PaymentError.new(rcode, error_obj)
182
189
  when "operation_failed"
183
- raise OperationFailedError.new(rcode, error_obj)
190
+ OperationFailedError.new(rcode, error_obj)
184
191
  when "invalid_request"
185
- raise InvalidRequestError.new(rcode, error_obj)
192
+ InvalidRequestError.new(rcode, error_obj)
186
193
  when "ubb_batch_ingestion_invalid_request"
187
- raise UbbBatchIngestionInvalidRequestError.new(rcode, error_obj)
194
+ UbbBatchIngestionInvalidRequestError.new(rcode, error_obj)
188
195
  else
189
- raise APIError.new(rcode, error_obj)
196
+ APIError.new(rcode, error_obj)
190
197
  end
191
198
  end
192
199
 
@@ -106,7 +106,7 @@ module ChargeBee
106
106
 
107
107
  def invoice()
108
108
  invoice = get(:invoice, Invoice,
109
- {:line_items => Invoice::LineItem, :line_item_tiers => Invoice::LineItemTier, :line_item_discounts => Invoice::LineItemDiscount, :line_item_taxes => Invoice::LineItemTax, :line_item_credits => Invoice::LineItemCredit, :line_item_addresses => Invoice::LineItemAddress, :discounts => Invoice::Discount, :taxes => Invoice::Tax, :tax_origin => Invoice::TaxOrigin, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :statement_descriptor => Invoice::StatementDescriptor, :einvoice => Invoice::Einvoice, :site_details_at_creation => Invoice::SiteDetailsAtCreation});
109
+ {:line_items => Invoice::LineItem, :line_item_tiers => Invoice::LineItemTier, :line_item_discounts => Invoice::LineItemDiscount, :line_item_taxes => Invoice::LineItemTax, :line_item_credits => Invoice::LineItemCredit, :line_item_addresses => Invoice::LineItemAddress, :discounts => Invoice::Discount, :taxes => Invoice::Tax, :tax_origin => Invoice::TaxOrigin, :linked_payments => Invoice::LinkedPayment, :reference_transactions => Invoice::ReferenceTransaction, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :statement_descriptor => Invoice::StatementDescriptor, :einvoice => Invoice::Einvoice, :site_details_at_creation => Invoice::SiteDetailsAtCreation});
110
110
  return invoice;
111
111
  end
112
112
 
@@ -302,7 +302,7 @@ module ChargeBee
302
302
 
303
303
  def payment_intent()
304
304
  payment_intent = get(:payment_intent, PaymentIntent,
305
- {:payment_attempt => PaymentIntent::PaymentAttempt});
305
+ {:payment_attempt => PaymentIntent::PaymentAttempt, :payment_attempts => PaymentIntent::PaymentAttempt});
306
306
  return payment_intent;
307
307
  end
308
308
 
@@ -582,7 +582,7 @@ module ChargeBee
582
582
 
583
583
  def invoices()
584
584
  invoices = get_list(:invoices, Invoice,
585
- {:line_items => Invoice::LineItem, :line_item_tiers => Invoice::LineItemTier, :line_item_discounts => Invoice::LineItemDiscount, :line_item_taxes => Invoice::LineItemTax, :line_item_credits => Invoice::LineItemCredit, :line_item_addresses => Invoice::LineItemAddress, :discounts => Invoice::Discount, :taxes => Invoice::Tax, :tax_origin => Invoice::TaxOrigin, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :statement_descriptor => Invoice::StatementDescriptor, :einvoice => Invoice::Einvoice, :site_details_at_creation => Invoice::SiteDetailsAtCreation});
585
+ {:line_items => Invoice::LineItem, :line_item_tiers => Invoice::LineItemTier, :line_item_discounts => Invoice::LineItemDiscount, :line_item_taxes => Invoice::LineItemTax, :line_item_credits => Invoice::LineItemCredit, :line_item_addresses => Invoice::LineItemAddress, :discounts => Invoice::Discount, :taxes => Invoice::Tax, :tax_origin => Invoice::TaxOrigin, :linked_payments => Invoice::LinkedPayment, :reference_transactions => Invoice::ReferenceTransaction, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :statement_descriptor => Invoice::StatementDescriptor, :einvoice => Invoice::Einvoice, :site_details_at_creation => Invoice::SiteDetailsAtCreation});
586
586
  return invoices;
587
587
  end
588
588
 
data/lib/chargebee.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/chargebee/environment'
2
- require File.dirname(__FILE__) + '/chargebee/nativeRequest'
2
+ require File.dirname(__FILE__) + '/chargebee/native_request'
3
3
  require File.dirname(__FILE__) + '/chargebee/util'
4
4
  require File.dirname(__FILE__) + '/chargebee/request'
5
5
  require File.dirname(__FILE__) + '/chargebee/result'
@@ -98,7 +98,7 @@ require File.dirname(__FILE__) + '/chargebee/models/offer_fulfillment'
98
98
 
99
99
  module ChargeBee
100
100
 
101
- VERSION = '2.62.0'
101
+ VERSION = '2.64.0'
102
102
 
103
103
  @@default_env = nil
104
104
  @@verify_ca_certs = true
@@ -141,6 +141,19 @@ module ChargeBee
141
141
  end
142
142
  end
143
143
 
144
+ it "raises ForbiddenError for 403 status code" do
145
+ stub_request(:get, "https://dummy.chargebee.com/test").to_return(
146
+ body: "<html>\r\n<head><title>403 Forbidden</title></head>\r\n<body>\r\n<center><h1>403 Forbidden</h1></center>\r\n</body>\r\n</html>\r\n",
147
+ status: 403
148
+ )
149
+
150
+ expect {
151
+ NativeRequest.request(:get, "/test", env)
152
+ }.to raise_error(ForbiddenError) do |err|
153
+ expect(err.message).to eq("Access forbidden. You do not have permission to access this resource.")
154
+ end
155
+ end
156
+
144
157
  it "retries once on HTTP 503 and succeeds on second attempt" do
145
158
  stub_request(:get, "https://dummy.chargebee.com/test")
146
159
  .to_return({ status: 503, body: "temporary error" },
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.62.0
4
+ version: 2.64.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: 2025-09-23 00:00:00.000000000 Z
12
+ date: 2025-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cgi
@@ -181,7 +181,7 @@ files:
181
181
  - lib/chargebee/models/usage_file.rb
182
182
  - lib/chargebee/models/virtual_bank_account.rb
183
183
  - lib/chargebee/models/webhook_endpoint.rb
184
- - lib/chargebee/nativeRequest.rb
184
+ - lib/chargebee/native_request.rb
185
185
  - lib/chargebee/request.rb
186
186
  - lib/chargebee/rest.rb
187
187
  - lib/chargebee/result.rb