Created
March 1, 2013 20:01
-
-
Save nicholasjhenry/5067322 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Notes from: https://groups.google.com/d/msg/rubyparley/7grAQjnjwe0/A6PcFITW9U4J | |
| Also see: http://railscasts.com/episodes/146-paypal-express-checkout | |
| Use ActiveMerchant::Billing. When you're ready to have someone checkout, send them to a rails controller action Paypal#checkout. This will: | |
| 0. "gateway" is a ActiveMerchant::Billing::PaypalExpressGateway.new | |
| 1. send a message to gateway.setup_purchase. | |
| 2. #setup_purchase has a method redirect_url_for that you'll use to redirect the user to Paypal. | |
| 3. Paypal will redirect the user back to Paypal#complete | |
| 4. on the complete page, you show the user the order form again with a finalize button | |
| 5. Paypal#finalize will call gateway.purchase with the token -- so you could finally take their money with | |
| @purchase = gateway.purchase(session[:total_in_cents], | |
| :ip => request.remote_ip, | |
| :payer_id => session[:payer_id], | |
| :token => session[:token] | |
| ) | |
| unless @purchase.success? | |
| raise ActiveRecord::Rollback | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment