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.



186
187
188
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 186

def amount
  @amount
end

#confirmed_atObject (readonly)

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



188
189
190
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 188

def confirmed_at
  @confirmed_at
end

#createdObject (readonly)

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



190
191
192
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 190

def created
  @created
end

#created_byObject (readonly)

The related Stripe objects that created this gift card transaction.



192
193
194
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 192

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).



194
195
196
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 194

def currency
  @currency
end

#descriptionObject (readonly)

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



196
197
198
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 196

def description
  @description
end

#gift_cardObject (readonly)

The gift card that this transaction occurred on



198
199
200
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 198

def gift_card
  @gift_card
end

#idObject (readonly)

Unique identifier for the object.



200
201
202
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 200

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.



202
203
204
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 202

def 
  @metadata
end

#objectObject (readonly)

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



204
205
206
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 204

def object
  @object
end

#statusObject (readonly)

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



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

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.



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

def transfer_group
  @transfer_group
end

Class Method Details

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

Cancel a gift card transaction



221
222
223
224
225
226
227
228
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 221

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



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

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



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

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



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

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



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

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



211
212
213
214
215
216
217
218
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 211

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



231
232
233
234
235
236
237
238
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 231

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