Comments (6)
I feel your pain :/ but that is very paypay/rails specific logic and kind of out of the scope of this gem.
That said, are you using spree? if so, your controller has to look kind of like this?
That's based on PayPal Express, but it's a bit similar. I've been trying open-source a decent version of the PayPal Adaptive payments for spree here, but haven't got the time to finish it.
Hope that makes scene and helps you a bit, anything else just post it here and I'll try to help as much as possible.
from active_paypal_adaptive_payment.
I've figured out how to put the URL together. It's
"https://www.sandbox.paypal.com/webscr?cmd=_ap-preapproval&preapprovalkey=" + @payment.preapproval_key
Then I have to go through the source to figure out how to assemble the options hash for preapprove_payment. If I can, when I'm through with all of this, I'll contribute to the documentation and code.
from active_paypal_adaptive_payment.
That URL is already being handled by the gem here.
Basically this is how a payment process should look like:
- Process the payment/order in your checkout_controller#payment action:
# req = the Hash with all the order/payment required options.
session[:adaptive_payment_response] = gateway.setup_purchase(req)
-
Then
session[:adaptive_payment_response]
should be full of a bunch
of PayPal info/crap regarding that first payment request. -
You then - in that #payment action - need to verify if its successfull.
if session[:adaptive_payment_response].success?
# confirmation key for the second request
redirect_to (gateway.redirect_url_for(session[:adaptive_payment_response][:pay_key])) # redirecting again...
else
gateway_error(session[:adaptive_payment_response])
redirect_to edit_order_checkout_url
end
-
Now you need another
checkout_controller#action
to receive what PayPal
is - again - sending you. The last and confirmed request. -
profit :/
from active_paypal_adaptive_payment.
Hi jpablobr,
Thanks for taking the time to explain this, but I'm not sure if it fits with what I'm doing.
On my site, users can request to receive periodic automatic orders of our products, so I need to set up the a pre approved payment agreement. I don't need to actually execute a payment at this point, just to set up the preapproval agreement so I can do the automatic payments in the future.
The first step is to use preapprove_payment to get the preapproval key. Then I have to send the user to paypal with the key so they can log into paypal and approve it. That's what I figured out in my previous post. I actually saw that url in the source code, but how am I supposed to use it in my code?
Once the user has authorized the preapproves payment key, I get an IPN to let my site know that it's been authorized. From the on, I should be able to use the key to make purchases without needing the user to log in. Haven't tried to figure that one out yet, though. : )
I'm loosely basing my approach to this on ryanb's railscasts for integrating paypal into a rails app.
from active_paypal_adaptive_payment.
I haven't played much with preapprove_payment
, but it should have to be similar to the other requests.
The gateway.setup_purchase(req)
(setup_purchase
) will build the request which in turn will give you the key
.
Then, the redirect_url_for
(in this case using Rail's redirect_to
):
redirect_to (gateway.redirect_url_for(session[:adaptive_payment_response][:pay_key]))
will send the user to PayPal's website to handle the specified type of request (in your case a preapprove_payment
). Once in there, based on what the user did, PayPal will send to your application one last "response" basically containing those user actions.
All these in the same way I mentioned on my previous comment.
One more caveat... that last request is not an IPN. IPNs are handled differently. However, the IPN is not required... but is obviously helpful since that will let your application know the status of the whole transaction. Basically without it you are blind, but the preapprove_payment
(successful or not) will be "successfully" completed (if the user accepted it or not). <3 PayPal
from active_paypal_adaptive_payment.
Hey I'm closing the issue since this is not specific to the gem... Feel free to open it again if you think is necessary.
from active_paypal_adaptive_payment.
Related Issues (20)
- What parameters does paypal send back when it redirects to my site? HOT 4
- Not receiving a response from the IPN when ipn_notification_url is called HOT 3
- :start_time and :end_time for preapproved payments do not include GMT offset HOT 2
- This transaction is invalid. Please return to the recipient's website and try again. HOT 5
- Inconsistent naming of IPN keys HOT 3
- its possible send ClientDetails Fields? HOT 3
- payment is completed without the sender logging in to paypal.com HOT 1
- No ipn field provided for preapprove_payment HOT 1
- Refund method NO_API_ACCESS_TO_RECEIVER HOT 4
- How to send a single payment to a single user? HOT 1
- How to send an implicit approval payment?
- Setting the item description for the Payee HOT 2
- payKey issue HOT 5
- Embedded payment not working?
- Chained payments not working?
- how i implement this in rails app
- item description, support for Embedded flow?
- Your tutorial video link does not work
- Set payments as "Family and friends"
- Adaptive Payment Refund functionality Issue The refund's Error receiver [email protected] wasn't part of the payment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_paypal_adaptive_payment.