Skip to content

Instantly share code, notes, and snippets.

@pioz
Created May 11, 2011 22:45
Show Gist options
  • Select an option

  • Save pioz/967559 to your computer and use it in GitHub Desktop.

Select an option

Save pioz/967559 to your computer and use it in GitHub Desktop.

Revisions

  1. Enrico created this gist May 11, 2011.
    35 changes: 35 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    require 'rubygems'
    require 'activemerchant'

    ActiveMerchant::Billing::Base.mode = :test
    paypal_options = {
    :login => 'xxx',
    :password => 'yyy',
    :signature => 'zzz'
    }
    ::PAYPAL_EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)

    response = PAYPAL_EXPRESS_GATEWAY.setup_purchase(1000,
    :ip => '127.0.0.1',
    :return_url => 'http://localhost:3000',
    :cancel_return_url => 'http://localhost:3000',
    :header_background_color => 'ff0000',
    :email => '[email protected]',
    :allow_note => false,
    :allow_guest_checkout => true,
    :locale => 'IT',
    :address => {
    :name => 'Enrico',
    :last_name => 'Pilotto',
    :address1 => 'via fuck yeah 12',
    :city => 'Padova',
    :state => 'Padova',
    :county => 'IT',
    :zip => 35100,
    :phone => '0499460022'
    }
    )

    url = PAYPAL_EXPRESS_GATEWAY.redirect_url_for(response.token)

    puts url