Class: Stripe::GiftCard

Inherits:
APIResource show all
Extended by:
APIOperations::Create
Defined in:
lib/stripe/resources/gift_card.rb

Overview

Represents third-party gift cards that can be used as a payment method through Stripe.

Constant Summary collapse

OBJECT_NAME =
"gift_card"

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 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?, field_encodings, #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

#brandObject (readonly)

The brand of the gift card.



15
16
17
# File 'lib/stripe/resources/gift_card.rb', line 15

def brand
  @brand
end

#exp_monthObject (readonly)

The expiration month of the gift card.



17
18
19
# File 'lib/stripe/resources/gift_card.rb', line 17

def exp_month
  @exp_month
end

#exp_yearObject (readonly)

The expiration year of the gift card.



19
20
21
# File 'lib/stripe/resources/gift_card.rb', line 19

def exp_year
  @exp_year
end

#fingerprintObject (readonly)

Uniquely identifies this particular gift card number. You can use this attribute to check whether two gift cards are the same.



21
22
23
# File 'lib/stripe/resources/gift_card.rb', line 21

def fingerprint
  @fingerprint
end

#idObject (readonly)

Unique identifier for the object.



23
24
25
# File 'lib/stripe/resources/gift_card.rb', line 23

def id
  @id
end

#last4Object (readonly)

The last four digits of the gift card number.



25
26
27
# File 'lib/stripe/resources/gift_card.rb', line 25

def last4
  @last4
end

#last_operationObject (readonly)

The last operation performed on this gift card.



27
28
29
# File 'lib/stripe/resources/gift_card.rb', line 27

def last_operation
  @last_operation
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



29
30
31
# File 'lib/stripe/resources/gift_card.rb', line 29

def livemode
  @livemode
end

#objectObject (readonly)

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



31
32
33
# File 'lib/stripe/resources/gift_card.rb', line 31

def object
  @object
end

Class Method Details

.activate(gift_card, params = {}, opts = {}) ⇒ Object

Activates a third-party gift card and optionally sets its balance.



44
45
46
47
48
49
50
51
# File 'lib/stripe/resources/gift_card.rb', line 44

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

.cashout(gift_card, params = {}, opts = {}) ⇒ Object

Cashout a third-party gift card by zeroing its balance.



64
65
66
67
68
69
70
71
# File 'lib/stripe/resources/gift_card.rb', line 64

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

.check_balance(gift_card, params = {}, opts = {}) ⇒ Object

Checks the balance of a third-party gift card.



84
85
86
87
88
89
90
91
# File 'lib/stripe/resources/gift_card.rb', line 84

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

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

Creates a gift card object.



94
95
96
# File 'lib/stripe/resources/gift_card.rb', line 94

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

.field_remappingsObject



142
143
144
# File 'lib/stripe/resources/gift_card.rb', line 142

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



138
139
140
# File 'lib/stripe/resources/gift_card.rb', line 138

def self.inner_class_types
  @inner_class_types = {}
end

.object_nameObject



10
11
12
# File 'lib/stripe/resources/gift_card.rb', line 10

def self.object_name
  "gift_card"
end

.reload(gift_card, params = {}, opts = {}) ⇒ Object

Reloads a third-party gift card by adding the specified amount to its balance.



109
110
111
112
113
114
115
116
# File 'lib/stripe/resources/gift_card.rb', line 109

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

.void_operation(gift_card, params = {}, opts = {}) ⇒ Object

Voids a previously performed gift card operation.



129
130
131
132
133
134
135
136
# File 'lib/stripe/resources/gift_card.rb', line 129

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

Instance Method Details

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

Activates a third-party gift card and optionally sets its balance.



34
35
36
37
38
39
40
41
# File 'lib/stripe/resources/gift_card.rb', line 34

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

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

Cashout a third-party gift card by zeroing its balance.



54
55
56
57
58
59
60
61
# File 'lib/stripe/resources/gift_card.rb', line 54

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

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

Checks the balance of a third-party gift card.



74
75
76
77
78
79
80
81
# File 'lib/stripe/resources/gift_card.rb', line 74

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

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

Reloads a third-party gift card by adding the specified amount to its balance.



99
100
101
102
103
104
105
106
# File 'lib/stripe/resources/gift_card.rb', line 99

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

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

Voids a previously performed gift card operation.



119
120
121
122
123
124
125
126
# File 'lib/stripe/resources/gift_card.rb', line 119

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