Class: Stripe::GiftCards::Transaction

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

Overview

A gift card transaction represents a single transaction on a referenced gift card. A transaction is in one of three states, ‘confirmed`, `held` or `canceled`. A `confirmed` transaction is one that has added/deducted funds. A `held` transaction has created a temporary hold on funds, which can then be cancelled or confirmed. A `held` transaction can be confirmed into a `confirmed` transaction, or canceled into a `canceled` transaction. A `canceled` transaction has no effect on a gift card’s balance.

Defined Under Namespace

Classes: CancelParams, ConfirmParams, CreateParams, CreatedBy, ListParams, RetrieveParams, UpdateParams

Constant Summary collapse

OBJECT_NAME =
"gift_cards.transaction"

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

#==, #[], #[]=, 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)

The amount of this transaction. A positive value indicates that funds were added to the gift card. A negative value indicates that funds were removed from the gift card.



207
208
209
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 207

def amount
  @amount
end

#confirmed_atObject (readonly)

Time at which the transaction was confirmed. Measured in seconds since the Unix epoch.



210
211
212
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 210

def confirmed_at
  @confirmed_at
end

#createdObject (readonly)

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



213
214
215
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 213

def created
  @created
end

#created_byObject (readonly)

The related Stripe objects that created this gift card transaction.



216
217
218
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 216

def created_by
  @created_by
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).



219
220
221
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 219

def currency
  @currency
end

#descriptionObject (readonly)

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



222
223
224
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 222

def description
  @description
end

#gift_cardObject (readonly)

The gift card that this transaction occurred on



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

def gift_card
  @gift_card
end

#idObject (readonly)

Unique identifier for the object.



228
229
230
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 228

def id
  @id
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.



231
232
233
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 231

def 
  @metadata
end

#objectObject (readonly)

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



234
235
236
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 234

def object
  @object
end

#statusObject (readonly)

Status of this transaction, one of ‘held`, `confirmed`, or `canceled`.



237
238
239
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 237

def status
  @status
end

#transfer_groupObject (readonly)

A string that identifies this transaction as part of a group. See the [Connect documentation](stripe.com/docs/connect/separate-charges-and-transfers) for details.



240
241
242
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 240

def transfer_group
  @transfer_group
end

Class Method Details

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

Cancel a gift card transaction



253
254
255
256
257
258
259
260
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 253

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

.confirm(id, params = {}, opts = {}) ⇒ Object

Confirm a gift card transaction



273
274
275
276
277
278
279
280
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 273

def self.confirm(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/gift_cards/transactions/%<id>s/confirm", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

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

Create a gift card transaction



283
284
285
286
287
288
289
290
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 283

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

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

List gift card transactions for a gift card



293
294
295
296
297
298
299
300
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 293

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

.object_nameObject



18
19
20
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 18

def self.object_name
  "gift_cards.transaction"
end

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

Update a gift card transaction



303
304
305
306
307
308
309
310
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 303

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

Instance Method Details

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

Cancel a gift card transaction



243
244
245
246
247
248
249
250
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 243

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

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

Confirm a gift card transaction



263
264
265
266
267
268
269
270
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 263

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