Class: Filly::CreditCard
- Inherits:
-
Object
- Object
- Filly::CreditCard
- Defined in:
- lib/filly/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 stripe_customer_id : Stripe customer to update the credit card expiration date card_month : The credit card expiration month card_year : The credit card expiration year.
Class Method Details
.add(stripe_customer_id, stripe_token) ⇒ Object
Adds a new credit card as the active default card for an existing customer
stripe_customer_id : Stripe customer to add a new credit card stripe_token : Token representing the credit card
Returns : Stripe::Card object
12 13 14 15 16 17 18 |
# File 'lib/filly/credit_card.rb', line 12 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
stripe_token : Token representing the credit card description : The description for the transaction
Returns : Stripe::Customer
28 29 30 |
# File 'lib/filly/credit_card.rb', line 28 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
stripe_customer_id : Stripe customer to update the credit card expiration date card_month : The credit card expiration month card_year : The credit card expiration year
Returns : Stripe::Card object
41 42 43 44 45 46 47 |
# File 'lib/filly/credit_card.rb', line 41 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 |