Skip to content

Instantly share code, notes, and snippets.

@ckuwanoe
Created May 6, 2015 23:54
Show Gist options
  • Save ckuwanoe/dc10c9f053205ba94fdc to your computer and use it in GitHub Desktop.
Save ckuwanoe/dc10c9f053205ba94fdc to your computer and use it in GitHub Desktop.
def update_card(subscription_params)
customer = Stripe::Customer.retrieve(self.stripe_customer_token)
card = customer.sources.create(source: subscription_params[:stripe_card_token])
card.save
customer.default_source = card.id
customer.save
rescue Stripe::InvalidRequestError => e
logger.error "Stripe error while updating card info: #{e.message}"
errors.add :base, "#{e.message}"
false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment