Class: Stripe::CustomerBalanceTransaction
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::CustomerBalanceTransaction
- 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 collapse
-
#amount ⇒ Object
readonly
The amount of the transaction.
-
#checkout_session ⇒ Object
readonly
The ID of the checkout session (if any) that created the transaction.
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#credit_note ⇒ Object
readonly
The ID of the credit note (if any) related to the transaction.
-
#currency ⇒ Object
readonly
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase.
-
#customer ⇒ Object
readonly
The ID of the customer the transaction belongs to.
-
#description ⇒ Object
readonly
An arbitrary string attached to the object.
-
#ending_balance ⇒ Object
readonly
The customer’s ‘balance` after the transaction was applied.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#invoice ⇒ Object
readonly
The ID of the invoice (if any) related to the transaction.
-
#livemode ⇒ Object
readonly
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
-
#metadata ⇒ Object
readonly
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#type ⇒ Object
readonly
Transaction type: ‘adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, `unapplied_from_invoice`, `checkout_session_subscription_payment`, or `checkout_session_subscription_payment_canceled`.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
- .field_remappings ⇒ Object
- .inner_class_types ⇒ Object
- .object_name ⇒ Object
- .retrieve(_id, _opts = {}) ⇒ Object
- .update(_id, _params = nil, _opts = nil) ⇒ Object
Instance Method Summary collapse
Methods included from APIOperations::Save
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, resource_url, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, #_get_inner_class_type, 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
Instance Attribute Details
#amount ⇒ Object (readonly)
The amount of the transaction. A negative value is a credit for the customer’s balance, and a positive value is a debit to the customer’s ‘balance`.
20 21 22 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 20 def amount @amount end |
#checkout_session ⇒ Object (readonly)
The ID of the checkout session (if any) that created the transaction.
22 23 24 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 22 def checkout_session @checkout_session end |
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
24 25 26 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 24 def created @created end |
#credit_note ⇒ Object (readonly)
The ID of the credit note (if any) related to the transaction.
26 27 28 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 26 def credit_note @credit_note end |
#currency ⇒ Object (readonly)
Three-letter [ISO currency code](www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](stripe.com/docs/currencies).
28 29 30 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 28 def currency @currency end |
#customer ⇒ Object (readonly)
The ID of the customer the transaction belongs to.
30 31 32 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 30 def customer @customer end |
#description ⇒ Object (readonly)
An arbitrary string attached to the object. Often useful for displaying to users.
32 33 34 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 32 def description @description end |
#ending_balance ⇒ Object (readonly)
The customer’s ‘balance` after the transaction was applied. A negative value decreases the amount due on the customer’s next invoice. A positive value increases the amount due on the customer’s next invoice.
34 35 36 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 34 def ending_balance @ending_balance end |
#id ⇒ Object (readonly)
Unique identifier for the object.
36 37 38 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 36 def id @id end |
#invoice ⇒ Object (readonly)
The ID of the invoice (if any) related to the transaction.
38 39 40 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 38 def invoice @invoice end |
#livemode ⇒ Object (readonly)
Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.
40 41 42 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 40 def livemode @livemode end |
#metadata ⇒ Object (readonly)
Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
42 43 44 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 42 def @metadata end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
44 45 46 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 44 def object @object end |
#type ⇒ Object (readonly)
Transaction type: ‘adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, `unapplied_from_invoice`, `checkout_session_subscription_payment`, or `checkout_session_subscription_payment_canceled`. See the [Customer Balance page](stripe.com/docs/billing/customer/balance#types) to learn more about transaction types.
46 47 48 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 46 def type @type end |
Class Method Details
.field_remappings ⇒ Object
72 73 74 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 72 def self.field_remappings @field_remappings = {} end |
.inner_class_types ⇒ Object
68 69 70 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 68 def self.inner_class_types @inner_class_types = {} end |
.object_name ⇒ Object
15 16 17 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 15 def self.object_name "customer_balance_transaction" end |
.retrieve(_id, _opts = {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 56 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
62 63 64 65 66 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 62 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_url ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/stripe/resources/customer_balance_transaction.rb', line 48 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 |