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: CreatedBy

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.



37
38
39
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 37

def amount
  @amount
end

#confirmed_atObject (readonly)

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



39
40
41
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 39

def confirmed_at
  @confirmed_at
end

#createdObject (readonly)

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



41
42
43
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 41

def created
  @created
end

#created_byObject (readonly)

The related Stripe objects that created this gift card transaction.



43
44
45
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 43

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



45
46
47
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 45

def currency
  @currency
end

#descriptionObject (readonly)

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



47
48
49
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 47

def description
  @description
end

#gift_cardObject (readonly)

The gift card that this transaction occurred on



49
50
51
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 49

def gift_card
  @gift_card
end

#idObject (readonly)

Unique identifier for the object.



51
52
53
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 51

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.



53
54
55
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 53

def 
  @metadata
end

#objectObject (readonly)

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



55
56
57
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 55

def object
  @object
end

#statusObject (readonly)

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



57
58
59
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 57

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.



59
60
61
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 59

def transfer_group
  @transfer_group
end

Class Method Details

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

Cancel a gift card transaction



72
73
74
75
76
77
78
79
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 72

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



92
93
94
95
96
97
98
99
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 92

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



102
103
104
105
106
107
108
109
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 102

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

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

List gift card transactions for a gift card



112
113
114
115
116
117
118
119
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 112

def self.list(filters = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/gift_cards/transactions",
    params: filters,
    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



122
123
124
125
126
127
128
129
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 122

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



62
63
64
65
66
67
68
69
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 62

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



82
83
84
85
86
87
88
89
# File 'lib/stripe/resources/gift_cards/transaction.rb', line 82

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