Class: Stripe::CustomerBalanceTransaction

Inherits:
APIResource show all
Extended by:
APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/customer_balance_transaction.rb

Overview

Each customer has a [Balance](stripe.com/docs/api/customers/object#customer_object-balance) value, which denotes a debit or credit that’s automatically applied to their next invoice upon finalization. You may modify the value directly by using the [update customer API](stripe.com/docs/api/customers/update), or by creating a Customer Balance Transaction, which increments or decrements the customer’s ‘balance` by the specified `amount`.

Related guide: [Customer balance](stripe.com/docs/billing/customer/balance)

Constant Summary collapse

OBJECT_NAME =
"customer_balance_transaction"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

Attributes inherited from APIResource

#save_with_parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Class Method Details

.retrieve(_id, _opts = {}) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
28
29
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 25

def self.retrieve(_id, _opts = {})
  raise NotImplementedError,
        "Customer Balance Transactions cannot be retrieved without a customer ID. " \
        "Retrieve a Customer Balance Transaction using `Customer.retrieve_balance_transaction('cus_123', 'cbtxn_123')`"
end

.update(_id, _params = nil, _opts = nil) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
34
35
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 31

def self.update(_id, _params = nil, _opts = nil)
  raise NotImplementedError,
        "Customer Balance Transactions cannot be retrieved without a customer ID. " \
        "Update a Customer Balance Transaction using `Customer.update_balance_transaction('cus_123', 'cbtxn_123', params)`"
end

Instance Method Details

#resource_urlObject



17
18
19
20
21
22
23
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 17

def resource_url
  if !respond_to?(:customer) || customer.nil?
    raise NotImplementedError,
          "Customer Balance Transactions cannot be accessed without a customer ID."
  end
  "#{Customer.resource_url}/#{CGI.escape(customer)}/balance_transactions/#{CGI.escape(id)}"
end