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



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

def amount
  @amount
end

#confirmed_atObject (readonly)

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



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

def confirmed_at
  @confirmed_at
end

#createdObject (readonly)

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



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

def created
  @created
end

#created_byObject (readonly)

The related Stripe objects that created this gift card transaction.



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

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



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

def currency
  @currency
end

#descriptionObject (readonly)

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



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

def description
  @description
end

#gift_cardObject (readonly)

The gift card that this transaction occurred on



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

def gift_card
  @gift_card
end

#idObject (readonly)

Unique identifier for the object.



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

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.



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

def 
  @metadata
end

#objectObject (readonly)

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



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

def object
  @object
end

#statusObject (readonly)

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



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

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.



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

def transfer_group
  @transfer_group
end

Class Method Details

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

Cancel a gift card transaction



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

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



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

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



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

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



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

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



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

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



202
203
204
205
206
207
208
209
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 202

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



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

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