Skip to content

Instantly share code, notes, and snippets.

View sivabudh's full-sized avatar

Sivabudh Umpudh sivabudh

View GitHub Profile
@sivabudh
sivabudh / gist:1300211
Created October 20, 2011 01:45
Sample Paypal credentials
{
:login => "seller_1229899173_biz_api1.railscasts.com",
:password => "FXWU58S7KXFC6HBE",
:signature => "AGjv6SW.mTiKxtkm6L9DcSUCUgePAUDQ3L-kTdszkPG8mRfjaRZDYtSu"
}
@sivabudh
sivabudh / app\controllers\paypal_express_controller.rb
Created October 23, 2011 02:00
PaypalExpressController checkout
class PaypalExpressController < ApplicationController
before_filter :assigns_gateway
include ActiveMerchant::Billing
include PaypalExpressHelper
def checkout
total_as_cents, setup_purchase_params = get_setup_purchase_params @cart, request
setup_response = @gateway.setup_purchase(total_as_cents, setup_purchase_params)
redirect_to @gateway.redirect_url_for(setup_response.token)
YourApp::Application.configure do
# Some other stuff in development.rb
# Force ActiveMerchant into test mode
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
end
end
:ip => request.remote_ip,
:return_url => url_for(:action => 'review', :only_path => false),
:cancel_return_url => home_url,
module PaypalExpressHelper
def get_setup_purchase_params(cart, request)
subtotal, shipping, total = get_totals(cart)
return to_cents(total), {
:ip => request.remote_ip,
:return_url => url_for(:action => 'review', :only_path => false),
:cancel_return_url => home_url,
:subtotal => to_cents(subtotal),
:shipping => to_cents(shipping),
:handling => 0,
@sivabudh
sivabudh / gist:1350469
Created November 9, 2011 05:12
Sync Heroku
#!/usr/bin/env ruby
require "open-uri"
open("http://www.forkedelic.com") do |f|
puts "Successfully pinged Forkedelic.com at #{Time.now}"
end
@sivabudh
sivabudh / gist:1350475
Created November 9, 2011 05:16
LaunchDaemon Heroku
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.pac.HitForkedelic</string>
<key>ProgramArguments</key>
<array>
<string>/scripts/hit_forkedelic.rb</string>
@sivabudh
sivabudh / PaypalExpressController.rb
Created November 17, 2011 03:06
PaypalExpressController#review
class PaypalExpressController < ApplicationController
before_filter :assigns_gateway
include ActiveMerchant::Billing
include PaypalExpressHelper
def checkout
# implemented in the previous blog post
end
@sivabudh
sivabudh / PaypalExpressHelper.rb
Created November 17, 2011 03:34
PaypalExpressHelper#get_order_info
module PaypalExpressHelper
def get_setup_purchase_params(cart, request)
# implemented in the previous blog post
end
def get_order_info(gateway_response, cart)
subtotal, shipping, total = get_totals(cart)
{
shipping_address: gateway_response.address,
email: gateway_response.email,
@sivabudh
sivabudh / review.html.haml
Created November 17, 2011 03:51
review.html.haml
%h3 Example of rendering Order Information
%h4 Your Total
%p= "Subtotal: #{number_to_currency @order_info[:subtotal]}"
%p= "Shipping: #{number_to_currency @order_info[:shipping]}"
%p= "Total: #{number_to_currency @order_info[:total]}"
%h4 Shipping Address
%table
%tr