Class: ChargebeeRails::MeteredBilling

Inherits:
Object
  • Object
show all
Defined in:
lib/chargebee_rails/metered_billing.rb

Class Method Summary collapse

Class Method Details

.add_addon_charge(invoice_id, addon_id, addon_quantity = 1) ⇒ Object

Add addon charge to pending invoice

  • Args :

    • invoice_id -> the pending invoice id

    • addon_id -> the id of the addon in chargebee

    • addon_quantity -> the quantity of addon, defaults to 1

  • Returns :

    • the chargebee pending invoice

For more details on the addon_charge for pending invoice, refer Add addon item to pending invoice



34
35
36
37
38
39
# File 'lib/chargebee_rails/metered_billing.rb', line 34

def add_addon_charge(invoice_id, addon_id, addon_quantity=1)
  ChargeBee::Invoice.add_addon_charge(invoice_id, {
    addon_id: addon_id,
    addon_quantity: addon_quantity
  }).invoice
end

.add_charge(invoice_id, amount, description) ⇒ Object

Add charge to pending invoice

  • Args :

    • invoice_id -> the pending invoice id

    • amount -> the charge on item to be added

    • description -> the description of the added item

  • Returns :

    • the chargebee pending invoice

For more details on the add_charge for pending invoice, refer Add charge item to pending invoice



16
17
18
19
20
21
# File 'lib/chargebee_rails/metered_billing.rb', line 16

def add_charge(invoice_id, amount, description)
  ChargeBee::Invoice.add_charge(invoice_id, {
    amount: amount, 
    description: description
  }).invoice
end

.close_invoice(invoice_id) ⇒ Object

Close pending invoice

  • Args :

    • invoice_id -> the pending invoice id

  • Returns :

    • the chargebee invoice

For more details on closing pending invoice, refer Close a pending invoice



50
51
52
# File 'lib/chargebee_rails/metered_billing.rb', line 50

def close_invoice(invoice_id)
  ChargeBee::Invoice.close(invoice_id).invoice
end