Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created May 11, 2012 18:23
Show Gist options
  • Save coderforhire/2661497 to your computer and use it in GitHub Desktop.
Save coderforhire/2661497 to your computer and use it in GitHub Desktop.
def make_purchase(user)
if valid?
amount = (DO YOUR CONVERSION STUFF HERE)
cu = Stripe::Customer.retrieve(user.stripe_customer_token)
cu.card = stripe_card_token # obtained with Stripe.js
cu.save
customer = Stripe::Charge.create(customer: user.stripe_customer_token, description: user.email, amount: 500, currency: 'usd')
save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment