Class: Stripe::Card

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

Overview

You can store multiple cards on a customer in order to charge the customer later. You can also store multiple debit cards on a recipient in order to transfer to those cards later.

Related guide: [Card payments with Sources](stripe.com/docs/sources/cards)

Defined Under Namespace

Classes: Networks

Constant Summary collapse

OBJECT_NAME =
"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::List

list

Methods included from APIOperations::Save

included, #save

Methods included from APIOperations::Delete

included

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, 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

#accountObject (readonly)

The account this card belongs to. This attribute will not be in the card object if the card belongs to a customer or recipient instead. This property is only available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is ‘application`, which includes Custom accounts.



24
25
26
# File 'lib/stripe/resources/card.rb', line 24

def 
  @account
end

#address_cityObject (readonly)

City/District/Suburb/Town/Village.



26
27
28
# File 'lib/stripe/resources/card.rb', line 26

def address_city
  @address_city
end

#address_countryObject (readonly)

Billing address country, if provided when creating card.



28
29
30
# File 'lib/stripe/resources/card.rb', line 28

def address_country
  @address_country
end

#address_line1Object (readonly)

Address line 1 (Street address/PO Box/Company name).



30
31
32
# File 'lib/stripe/resources/card.rb', line 30

def address_line1
  @address_line1
end

#address_line1_checkObject (readonly)

If ‘address_line1` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.



32
33
34
# File 'lib/stripe/resources/card.rb', line 32

def address_line1_check
  @address_line1_check
end

#address_line2Object (readonly)

Address line 2 (Apartment/Suite/Unit/Building).



34
35
36
# File 'lib/stripe/resources/card.rb', line 34

def address_line2
  @address_line2
end

#address_stateObject (readonly)

State/County/Province/Region.



36
37
38
# File 'lib/stripe/resources/card.rb', line 36

def address_state
  @address_state
end

#address_zipObject (readonly)

ZIP or postal code.



38
39
40
# File 'lib/stripe/resources/card.rb', line 38

def address_zip
  @address_zip
end

#address_zip_checkObject (readonly)

If ‘address_zip` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.



40
41
42
# File 'lib/stripe/resources/card.rb', line 40

def address_zip_check
  @address_zip_check
end

#allow_redisplayObject (readonly)

This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to “unspecified”.



42
43
44
# File 'lib/stripe/resources/card.rb', line 42

def allow_redisplay
  @allow_redisplay
end

#available_payout_methodsObject (readonly)

A set of available payout methods for this card. Only values from this set should be passed as the ‘method` when creating a payout.



44
45
46
# File 'lib/stripe/resources/card.rb', line 44

def available_payout_methods
  @available_payout_methods
end

#brandObject (readonly)

Card brand. Can be ‘American Express`, `Diners Club`, `Discover`, `Eftpos Australia`, `Girocard`, `JCB`, `MasterCard`, `UnionPay`, `Visa`, or `Unknown`.



46
47
48
# File 'lib/stripe/resources/card.rb', line 46

def brand
  @brand
end

#countryObject (readonly)

Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you’ve collected.



48
49
50
# File 'lib/stripe/resources/card.rb', line 48

def country
  @country
end

#currencyObject (readonly)

Three-letter [ISO code for currency](www.iso.org/iso-4217-currency-codes.html) in lowercase. Must be a [supported currency](docs.stripe.com/currencies). Only applicable on accounts (not customers or recipients). The card can be used as a transfer destination for funds in this currency. This property is only available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is ‘application`, which includes Custom accounts.



50
51
52
# File 'lib/stripe/resources/card.rb', line 50

def currency
  @currency
end

#customerObject (readonly)

The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead.



52
53
54
# File 'lib/stripe/resources/card.rb', line 52

def customer
  @customer
end

#cvc_checkObject (readonly)

If a CVC was provided, results of the check: ‘pass`, `fail`, `unavailable`, or `unchecked`. A result of unchecked indicates that CVC was provided but hasn’t been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see [Check if a card is valid without a charge](support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge).



54
55
56
# File 'lib/stripe/resources/card.rb', line 54

def cvc_check
  @cvc_check
end

#default_for_currencyObject (readonly)

Whether this card is the default external account for its currency. This property is only available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is ‘application`, which includes Custom accounts.



56
57
58
# File 'lib/stripe/resources/card.rb', line 56

def default_for_currency
  @default_for_currency
end

#deletedObject (readonly)

Always true for a deleted object



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

def deleted
  @deleted
end

#descriptionObject (readonly)

A high-level description of the type of cards issued in this range. (For internal use only and not typically available in standard API requests.)



58
59
60
# File 'lib/stripe/resources/card.rb', line 58

def description
  @description
end

#dynamic_last4Object (readonly)

(For tokenized numbers only.) The last four digits of the device account number.



60
61
62
# File 'lib/stripe/resources/card.rb', line 60

def dynamic_last4
  @dynamic_last4
end

#exp_monthObject (readonly)

Two-digit number representing the card’s expiration month.



62
63
64
# File 'lib/stripe/resources/card.rb', line 62

def exp_month
  @exp_month
end

#exp_yearObject (readonly)

Four-digit number representing the card’s expiration year.



64
65
66
# File 'lib/stripe/resources/card.rb', line 64

def exp_year
  @exp_year
end

#fingerprintObject (readonly)

Uniquely identifies this particular card number. You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example. For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.

*As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card—one for India and one for the rest of the world.*



68
69
70
# File 'lib/stripe/resources/card.rb', line 68

def fingerprint
  @fingerprint
end

#fundingObject (readonly)

Card funding type. Can be ‘credit`, `debit`, `prepaid`, or `unknown`.



70
71
72
# File 'lib/stripe/resources/card.rb', line 70

def funding
  @funding
end

#idObject (readonly)

Unique identifier for the object.



72
73
74
# File 'lib/stripe/resources/card.rb', line 72

def id
  @id
end

#iinObject (readonly)

Issuer identification number of the card. (For internal use only and not typically available in standard API requests.)



74
75
76
# File 'lib/stripe/resources/card.rb', line 74

def iin
  @iin
end

#issuerObject (readonly)

The name of the card’s issuing bank. (For internal use only and not typically available in standard API requests.)



76
77
78
# File 'lib/stripe/resources/card.rb', line 76

def issuer
  @issuer
end

#last4Object (readonly)

The last four digits of the card.



78
79
80
# File 'lib/stripe/resources/card.rb', line 78

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



80
81
82
# File 'lib/stripe/resources/card.rb', line 80

def 
  @metadata
end

#nameObject (readonly)

Cardholder name.



82
83
84
# File 'lib/stripe/resources/card.rb', line 82

def name
  @name
end

#networksObject (readonly)

Attribute for field networks



84
85
86
# File 'lib/stripe/resources/card.rb', line 84

def networks
  @networks
end

#objectObject (readonly)

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



86
87
88
# File 'lib/stripe/resources/card.rb', line 86

def object
  @object
end

#regulated_statusObject (readonly)

Status of a card based on the card issuer.



88
89
90
# File 'lib/stripe/resources/card.rb', line 88

def regulated_status
  @regulated_status
end

#statusObject (readonly)

For external accounts that are cards, possible values are ‘new` and `errored`. If a payout fails, the status is set to `errored` and [scheduled payouts](stripe.com/docs/payouts#payout-schedule) are stopped until account details are updated.



90
91
92
# File 'lib/stripe/resources/card.rb', line 90

def status
  @status
end

#tokenization_methodObject (readonly)

If the card number is tokenized, this is the method that was used. Can be ‘android_pay` (includes Google Pay), `apple_pay`, `masterpass`, `visa_checkout`, or null.



92
93
94
# File 'lib/stripe/resources/card.rb', line 92

def tokenization_method
  @tokenization_method
end

Class Method Details

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

Raises:

  • (NotImplementedError)


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

def self.delete(id, params = {}, opts = {})
  raise NotImplementedError,
        "Card cannot be deleted without a customer ID or an account " \
        "ID. Delete a card using `Customer.delete_source(" \
        "'customer_id', 'card_id')` or " \
        "`Account.delete_external_account('account_id', 'card_id')`"
end

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

Raises:

  • (NotImplementedError)


137
138
139
140
141
142
143
# File 'lib/stripe/resources/card.rb', line 137

def self.list(filters = {}, opts = {})
  raise NotImplementedError,
        "Cards cannot be listed without a customer ID or an account " \
        "ID. List cards using `Customer.list_sources(" \
        "'customer_id')` or " \
        "`Account.list_external_accounts('account_id')`"
end

.object_nameObject



16
17
18
# File 'lib/stripe/resources/card.rb', line 16

def self.object_name
  "card"
end

.retrieve(_id, _opts = nil) ⇒ Object

Raises:

  • (NotImplementedError)


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

def self.retrieve(_id, _opts = nil)
  raise NotImplementedError,
        "Card cannot be retrieved without a customer ID or an account " \
        "ID. Retrieve a card using `Customer.retrieve_source(" \
        "'customer_id', 'card_id')` or " \
        "`Account.retrieve_external_account('account_id', 'card_id')`"
end

.update(_id, _params = nil, _opts = nil) ⇒ Object

Raises:

  • (NotImplementedError)


104
105
106
107
108
109
110
# File 'lib/stripe/resources/card.rb', line 104

def self.update(_id, _params = nil, _opts = nil)
  raise NotImplementedError,
        "Card cannot be updated without a customer ID or an account ID. " \
        "Update a card using `Customer.update_source('customer_id', " \
        "'card_id', update_params)` or `Account.update_external_account(" \
        "'account_id', 'card_id', update_params)`"
end

Instance Method Details

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



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

def delete(params = {}, opts = {})
  request_stripe_object(
    method: :delete,
    path: resource_url.to_s,
    params: params,
    opts: opts
  )
end

#resource_urlObject



96
97
98
99
100
101
102
# File 'lib/stripe/resources/card.rb', line 96

def resource_url
  if respond_to?(:customer) && !customer.nil? && !customer.empty?
    "#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
  elsif respond_to?(:account) && !.nil? && !.empty?
    "#{Account.resource_url}/#{CGI.escape()}/external_accounts/#{CGI.escape(id)}"
  end
end