Sha256: c9986439b103fd30420614b4694b7027466d7ce778542d929fbfe0565431aecd
Contents?: true
Size: 1.23 KB
Versions: 37
Compression:
Stored size: 1.23 KB
Contents
require_dependency "ishapi/application_controller" module Ishapi class PaymentsController < ApplicationController def create authorize! :open_permission, ::Ishapi begin profile = IshModels::UserProfile.find_by( :email => params[:email] ) invoice = Ish::Invoice.find_by( :number => params[:number] ) payment = Ish::Payment.new :invoice => invoice, :profile => profile, :amount => params[:amount] amount_cents = ( params[:amount].to_f * 100 ).to_i ::Stripe.api_key = STRIPE_SK acct = Stripe::Account.create( :country => 'US', :type => 'custom' ) charge = ::Stripe::Charge.create( :amount => amount_cents, :currency => 'usd', :source => params[:token][:id], :destination => { :account => acct, } ) puts! charge, 'charge' # byebug payment.charge = JSON.parse( charge.to_json ) if payment.save render :json => { :status => :ok } else render :status => 404, :json => {} end rescue Mongoid::Errors::DocumentNotFound => e puts! e, 'e' render :status => 404, :json => {} end end end end
Version data entries
37 entries across 37 versions & 1 rubygems