Skip to content

Instantly share code, notes, and snippets.

@farhan-syed
Created September 14, 2015 04:05
Show Gist options
  • Save farhan-syed/5839ea39608de1e94f72 to your computer and use it in GitHub Desktop.
Save farhan-syed/5839ea39608de1e94f72 to your computer and use it in GitHub Desktop.
class ChargeController < ApplicationController
def index
decimal = params["price"]
cents = decimal.to_s.sub('.','').to_i
puts cents
Stripe.api_key = "sk_test_XXXXXXXXXXXXXXXXX"
begin
charge = Stripe::Charge.create(
:amount => cents,
:currency => "usd",
:source => params["stripeToken"],
:description => "Example charge",
:destination => params["stipeConnectedAccount"],
:application_fee => 100
)
rescue Stripe::CardError => e
# The card has been declined
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment