chargebee 2.10.1 → 2.12.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.
@@ -6,7 +6,7 @@ module ChargeBee
6
6
  end
7
7
 
8
8
  class BankAccount < Model
9
- attr_accessor :last4, :name_on_account, :bank_name, :mandate_id, :account_type, :echeck_type, :account_holder_type
9
+ attr_accessor :last4, :name_on_account, :first_name, :last_name, :bank_name, :mandate_id, :account_type, :echeck_type, :account_holder_type, :email
10
10
  end
11
11
 
12
12
  class AmazonPayment < Model
@@ -52,6 +52,10 @@ module ChargeBee
52
52
  Request.send('post', uri_path("payment_sources",id.to_s,"update_card"), params, env, headers)
53
53
  end
54
54
 
55
+ def self.update_bank_account(id, params={}, env=nil, headers={})
56
+ Request.send('post', uri_path("payment_sources",id.to_s,"update_bank_account"), params, env, headers)
57
+ end
58
+
55
59
  def self.verify_bank_account(id, params, env=nil, headers={})
56
60
  Request.send('post', uri_path("payment_sources",id.to_s,"verify_bank_account"), params, env, headers)
57
61
  end
@@ -20,7 +20,7 @@ module ChargeBee
20
20
  attr_accessor :id, :name, :invoice_name, :description, :price, :currency_code, :period, :period_unit,
21
21
  :trial_period, :trial_period_unit, :trial_end_action, :pricing_model, :charge_model, :free_quantity,
22
22
  :setup_cost, :downgrade_penalty, :status, :archived_at, :billing_cycles, :redirect_url, :enabled_in_hosted_pages,
23
- :enabled_in_portal, :addon_applicability, :tax_code, :taxjar_product_code, :avalara_sale_type,
23
+ :enabled_in_portal, :addon_applicability, :tax_code, :hsn_code, :taxjar_product_code, :avalara_sale_type,
24
24
  :avalara_transaction_type, :avalara_service_type, :sku, :accounting_code, :accounting_category1,
25
25
  :accounting_category2, :accounting_category3, :accounting_category4, :is_shippable, :shipping_frequency_period,
26
26
  :shipping_frequency_period_unit, :resource_version, :updated_at, :giftable, :claim_url, :free_quantity_in_decimal,
@@ -0,0 +1,11 @@
1
+ module ChargeBee
2
+ class TaxWithheld < Model
3
+
4
+ attr_accessor :id, :user, :reference_number, :description, :type, :payment_method, :date, :currency_code,
5
+ :amount, :exchange_rate
6
+
7
+ # OPERATIONS
8
+ #-----------
9
+
10
+ end # ~TaxWithheld
11
+ end # ~ChargeBee
@@ -39,8 +39,8 @@ module ChargeBee
39
39
  :user => api_key,
40
40
  :headers => headers,
41
41
  :payload => payload,
42
- :open_timeout => 50,
43
- :timeout => 100
42
+ :open_timeout => env.connect_timeout,
43
+ :timeout => env.read_timeout
44
44
  }.merge(ssl_opts)
45
45
 
46
46
  begin
@@ -59,7 +59,13 @@ module ChargeBee
59
59
  begin
60
60
  resp = JSON.parse(rbody)
61
61
  rescue Exception => e
62
- raise Error.new("Response not in JSON format. Probably not a ChargeBee response \n #{rbody.inspect}",e)
62
+ if rbody.include? "503"
63
+ raise Error.new("Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime. \n type: internal_temporary_error, \n http_status_code: 503, \n error_code: internal_temporary_error,\n content: #{rbody.inspect}",e)
64
+ elsif rbody.include? "504"
65
+ raise Error.new("The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com. \n type: gateway_timeout, \n http_status_code: 504, \n error_code: gateway_timeout,\n content: #{rbody.inspect}",e)
66
+ else
67
+ raise Error.new("Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com. \n type: internal_error, \n http_status_code: 500, \n error_code: internal_error,\n content: #{rbody.inspect}",e)
68
+ end
63
69
  end
64
70
  resp = Util.symbolize_keys(resp)
65
71
  resp
@@ -24,7 +24,7 @@ module ChargeBee
24
24
 
25
25
  def customer()
26
26
  customer = get(:customer, Customer,
27
- {:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :relationship => Customer::Relationship, :parent_account_access => Customer::ParentAccountAccess, :child_account_access => Customer::ChildAccountAccess});
27
+ {:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :entity_identifiers => Customer::EntityIdentifier, :relationship => Customer::Relationship, :parent_account_access => Customer::ParentAccountAccess, :child_account_access => Customer::ChildAccountAccess});
28
28
  return customer;
29
29
  end
30
30
 
@@ -71,13 +71,18 @@ module ChargeBee
71
71
 
72
72
  def invoice()
73
73
  invoice = get(:invoice, Invoice,
74
- {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :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});
74
+ {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :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, :einvoice => Invoice::Einvoice});
75
75
  return invoice;
76
76
  end
77
77
 
78
+ def tax_withheld()
79
+ tax_withheld = get(:tax_withheld, TaxWithheld);
80
+ return tax_withheld;
81
+ end
82
+
78
83
  def credit_note()
79
84
  credit_note = get(:credit_note, CreditNote,
80
- {:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
85
+ {:einvoice => CreditNote::Einvoice, :line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
81
86
  return credit_note;
82
87
  end
83
88
 
@@ -276,7 +281,7 @@ module ChargeBee
276
281
 
277
282
  def credit_notes()
278
283
  credit_notes = get_list(:credit_notes, CreditNote,
279
- {:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
284
+ {:einvoice => CreditNote::Einvoice, :line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
280
285
  return credit_notes;
281
286
  end
282
287
 
@@ -292,9 +297,15 @@ module ChargeBee
292
297
  return hierarchies;
293
298
  end
294
299
 
300
+ def downloads()
301
+ downloads = get_list(:downloads, Download,
302
+ {});
303
+ return downloads;
304
+ end
305
+
295
306
  def invoices()
296
307
  invoices = get_list(:invoices, Invoice,
297
- {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :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});
308
+ {:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :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, :einvoice => Invoice::Einvoice});
298
309
  return invoices;
299
310
  end
300
311
 
@@ -1,56 +1,56 @@
1
- module ChargeBee
2
- module Util
3
-
4
- def self.serialize(value, prefix = nil, idx = nil)
5
- serialized = {}
6
- case value
7
- when Hash
8
- value.each do |k, v|
9
- if(v.kind_of? Hash or v.kind_of? Array)
10
- serialized.merge!(serialize(v, k))
11
- else
12
- key = "#{(prefix!=nil) ? prefix:''}#{(prefix!=nil) ? '['+k.to_s+']' : k}#{(idx != nil) ? '['+idx.to_s+']':''}"
13
- serialized.merge!({key => as_str(v)})
14
- end
15
- end
16
- when Array
17
- value.each_with_index do |v, i|
18
- serialized.merge!(serialize(v, prefix, i))
19
- end
20
- else
21
- if(idx != nil and prefix != nil)
22
- key = "#{prefix}[#{idx.to_s}]"
23
- serialized.merge!({key => as_str(value)})
24
- else
25
- raise ArgumentError.new("only hash or arrays are allowed as value")
26
- end
27
- end
28
- serialized
29
- end
30
-
31
- def self.symbolize_keys(object)
32
- case object
33
- when Hash
34
- new = {}
35
- object.each do |key, value|
36
- key = (key.to_sym rescue key) || key
37
- new[key] = symbolize_keys(value)
38
- end
39
- new
40
- when Array
41
- object.map { |value| symbolize_keys(value) }
42
- else
43
- object
44
- end
45
- end
46
-
47
- def self.as_str(value)
48
- if(value == nil)
49
- return ''
50
- else
51
- return value.to_s
52
- end
53
- end
54
-
55
- end
56
- end
1
+ module ChargeBee
2
+ module Util
3
+
4
+ def self.serialize(value, prefix = nil, idx = nil)
5
+ serialized = {}
6
+ case value
7
+ when Hash
8
+ value.each do |k, v|
9
+ if(v.kind_of? Hash or v.kind_of? Array)
10
+ serialized.merge!(serialize(v, k))
11
+ else
12
+ key = "#{(prefix!=nil) ? prefix:''}#{(prefix!=nil) ? '['+k.to_s+']' : k}#{(idx != nil) ? '['+idx.to_s+']':''}"
13
+ serialized.merge!({key => as_str(v)})
14
+ end
15
+ end
16
+ when Array
17
+ value.each_with_index do |v, i|
18
+ serialized.merge!(serialize(v, prefix, i))
19
+ end
20
+ else
21
+ if(idx != nil and prefix != nil)
22
+ key = "#{prefix}[#{idx.to_s}]"
23
+ serialized.merge!({key => as_str(value)})
24
+ else
25
+ raise ArgumentError.new("only hash or arrays are allowed as value")
26
+ end
27
+ end
28
+ serialized
29
+ end
30
+
31
+ def self.symbolize_keys(object)
32
+ case object
33
+ when Hash
34
+ new = {}
35
+ object.each do |key, value|
36
+ key = (key.to_sym rescue key) || key
37
+ new[key] = symbolize_keys(value)
38
+ end
39
+ new
40
+ when Array
41
+ object.map { |value| symbolize_keys(value) }
42
+ else
43
+ object
44
+ end
45
+ end
46
+
47
+ def self.as_str(value)
48
+ if(value == nil)
49
+ return ''
50
+ else
51
+ return value.to_s
52
+ end
53
+ end
54
+
55
+ end
56
+ end
data/lib/chargebee.rb CHANGED
@@ -53,7 +53,7 @@ require File.dirname(__FILE__) + '/chargebee/models/usage.rb'
53
53
 
54
54
  module ChargeBee
55
55
 
56
- VERSION = '2.10.1'
56
+ VERSION = '2.12.0'
57
57
 
58
58
  @@default_env = nil
59
59
  @@verify_ca_certs = true
@@ -89,5 +89,12 @@ module ChargeBee
89
89
  @@user_agent
90
90
  end
91
91
 
92
+ def self.update_connect_timeout_secs(connect_timeout)
93
+ @@default_env.connect_timeout = connect_timeout
94
+ end
95
+
96
+ def self.update_read_timeout_secs(read_timeout)
97
+ @@default_env.read_timeout = read_timeout
98
+ end
92
99
  end
93
100