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)

Constant Summary collapse

OBJECT_NAME =
"card"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary

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

Class Method Details

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

Raises:

  • (NotImplementedError)


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

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)


61
62
63
64
65
66
67
# File 'lib/stripe/resources/card.rb', line 61

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)


36
37
38
39
40
41
42
# File 'lib/stripe/resources/card.rb', line 36

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)


28
29
30
31
32
33
34
# File 'lib/stripe/resources/card.rb', line 28

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



52
53
54
55
56
57
58
59
# File 'lib/stripe/resources/card.rb', line 52

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

#resource_urlObject



20
21
22
23
24
25
26
# File 'lib/stripe/resources/card.rb', line 20

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