module Colt class CreditCard # # Adds a new credit card as the active default card for an existing customer # # Returns : ? 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 # # Create a new credit card for a customer # # Returns : ? def self.save(stripe_token, description) Stripe::Customer.create(card: stripe_token, description: description) end # # Update expiration date of an existing credit card for a customer # # Returns ? 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 end end