Class: Stripe::Topup

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

Overview

To top up your Stripe balance, you create a top-up object. You can retrieve individual top-ups, as well as list all top-ups. Top-ups are identified by a unique, random ID.

Related guide: [Topping up your platform account](stripe.com/docs/connect/top-ups)

Defined Under Namespace

Classes: CancelParams, CreateParams, ListParams, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"topup"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

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, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

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

#amountObject (readonly)

Amount transferred.



153
154
155
# File 'lib/stripe/resources/topup.rb', line 153

def amount
  @amount
end

#balance_transactionObject (readonly)

ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up.



155
156
157
# File 'lib/stripe/resources/topup.rb', line 155

def balance_transaction
  @balance_transaction
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



157
158
159
# File 'lib/stripe/resources/topup.rb', line 157

def created
  @created
end

#currencyObject (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).



159
160
161
# File 'lib/stripe/resources/topup.rb', line 159

def currency
  @currency
end

#descriptionObject (readonly)

An arbitrary string attached to the object. Often useful for displaying to users.



161
162
163
# File 'lib/stripe/resources/topup.rb', line 161

def description
  @description
end

#expected_availability_dateObject (readonly)

Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up.



163
164
165
# File 'lib/stripe/resources/topup.rb', line 163

def expected_availability_date
  @expected_availability_date
end

#failure_codeObject (readonly)

Error code explaining reason for top-up failure if available (see [the errors section](stripe.com/docs/api#errors) for a list of codes).



165
166
167
# File 'lib/stripe/resources/topup.rb', line 165

def failure_code
  @failure_code
end

#failure_messageObject (readonly)

Message to user further explaining reason for top-up failure if available.



167
168
169
# File 'lib/stripe/resources/topup.rb', line 167

def failure_message
  @failure_message
end

#idObject (readonly)

Unique identifier for the object.



169
170
171
# File 'lib/stripe/resources/topup.rb', line 169

def id
  @id
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



171
172
173
# File 'lib/stripe/resources/topup.rb', line 171

def livemode
  @livemode
end

#metadataObject (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.



173
174
175
# File 'lib/stripe/resources/topup.rb', line 173

def 
  @metadata
end

#objectObject (readonly)

String representing the object’s type. Objects of the same type share the same value.



175
176
177
# File 'lib/stripe/resources/topup.rb', line 175

def object
  @object
end

#sourceObject (readonly)

The source field is deprecated. It might not always be present in the API response.



177
178
179
# File 'lib/stripe/resources/topup.rb', line 177

def source
  @source
end

#statement_descriptorObject (readonly)

Extra information about a top-up. This will appear on your source’s bank statement. It must contain at least one letter.



179
180
181
# File 'lib/stripe/resources/topup.rb', line 179

def statement_descriptor
  @statement_descriptor
end

#statusObject (readonly)

The status of the top-up is either ‘canceled`, `failed`, `pending`, `reversed`, or `succeeded`.



181
182
183
# File 'lib/stripe/resources/topup.rb', line 181

def status
  @status
end

#transfer_groupObject (readonly)

A string that identifies this top-up as part of a group.



183
184
185
# File 'lib/stripe/resources/topup.rb', line 183

def transfer_group
  @transfer_group
end

Class Method Details

.cancel(topup, params = {}, opts = {}) ⇒ Object

Cancels a top-up. Only pending top-ups can be canceled.



196
197
198
199
200
201
202
203
# File 'lib/stripe/resources/topup.rb', line 196

def self.cancel(topup, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/topups/%<topup>s/cancel", { topup: CGI.escape(topup) }),
    params: params,
    opts: opts
  )
end

.create(params = {}, opts = {}) ⇒ Object

Top up the balance of an account



206
207
208
# File 'lib/stripe/resources/topup.rb', line 206

def self.create(params = {}, opts = {})
  request_stripe_object(method: :post, path: "/v1/topups", params: params, opts: opts)
end

.field_remappingsObject



229
230
231
# File 'lib/stripe/resources/topup.rb', line 229

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



225
226
227
# File 'lib/stripe/resources/topup.rb', line 225

def self.inner_class_types
  @inner_class_types = {}
end

.list(params = {}, opts = {}) ⇒ Object

Returns a list of top-ups.



211
212
213
# File 'lib/stripe/resources/topup.rb', line 211

def self.list(params = {}, opts = {})
  request_stripe_object(method: :get, path: "/v1/topups", params: params, opts: opts)
end

.object_nameObject



16
17
18
# File 'lib/stripe/resources/topup.rb', line 16

def self.object_name
  "topup"
end

.update(topup, params = {}, opts = {}) ⇒ Object

Updates the metadata of a top-up. Other top-up details are not editable by design.



216
217
218
219
220
221
222
223
# File 'lib/stripe/resources/topup.rb', line 216

def self.update(topup, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/topups/%<topup>s", { topup: CGI.escape(topup) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

#cancel(params = {}, opts = {}) ⇒ Object

Cancels a top-up. Only pending top-ups can be canceled.



186
187
188
189
190
191
192
193
# File 'lib/stripe/resources/topup.rb', line 186

def cancel(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/topups/%<topup>s/cancel", { topup: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end