Created
April 29, 2010 16:28
-
-
Save miloops/383852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PaypalHelper | |
PAYPAL_API_PEM = File.read(File.join(RAILS_ROOT, 'certs', 'paypal_api.pem')) | |
# paypal_transfer(100.0, "yacare@example.com", "USD", "Your earnings", "This is a receipt" | |
def paypal_transfer(amount, email, currency, subject = nil, note = nil) | |
gateway = ActiveMerchant::Billing::PaypalGateway.new(:login => APP_CONFIG[:paypal_api_username], | |
:password => APP_CONFIG[:paypal_api_password], | |
:pem => PAYPAL_API_PEM) | |
gateway.transfer amount_in_cents(amount), email, | |
:subject => subject, :note => note, :currency => currency | |
end | |
def amount_in_cents(amount) | |
(amount *100).round | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment