Class: Colt::CreditCard
- Inherits:
-
Object
- Object
- Colt::CreditCard
- Defined in:
- lib/colt/credit_card.rb
Class Method Summary collapse
-
.add(stripe_customer_id, stripe_token) ⇒ Object
Adds a new credit card as the active default card for an existing customer.
-
.save(stripe_token, description) ⇒ Object
Create a new credit card for a customer.
-
.update_expiration_date(stripe_customer_id, card_month, card_year) ⇒ Object
Update expiration date of an existing credit card for a customer Returns ?.
Class Method Details
.add(stripe_customer_id, stripe_token) ⇒ Object
Adds a new credit card as the active default card for an existing customer
Returns : ?
8 9 10 11 12 13 14 |
# File 'lib/colt/credit_card.rb', line 8 def self.add(stripe_customer_id, stripe_token) customer = Stripe::Customer.retrieve(stripe_customer_id) card = customer.sources.create(source: stripe_token) customer.default_card = card.id customer.save card end |
.save(stripe_token, description) ⇒ Object
Create a new credit card for a customer
Returns : ?
20 21 22 |
# File 'lib/colt/credit_card.rb', line 20 def self.save(stripe_token, description) Stripe::Customer.create(card: stripe_token, description: description) end |
.update_expiration_date(stripe_customer_id, card_month, card_year) ⇒ Object
Update expiration date of an existing credit card for a customer
Returns ?
28 29 30 31 32 33 34 |
# File 'lib/colt/credit_card.rb', line 28 def self.update_expiration_date(stripe_customer_id, card_month, card_year) customer = Stripe::Customer.retrieve(stripe_customer_id) card = customer.sources.first card.exp_month = card_month card.exp_year = card_year card.save end |