[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Re: LWP form posts
On Sep 9, 2004, at 9:26 AM, Michael D. Maynard wrote:
I have looked at WWW::Mechanize and I think that it might do what I am
trying to do, however, it is not installed on the 3rd party server
that the application will run on. I am looking into getting it
installed or having them switch to my server.
I am doing a PayPal IPN integration into our shopping cart system. I
have the callback working (as well as it can, I guess. From what I
have read in the forum, it is pretty buggy.). The way it works is you
do a from post to their server with the merchant's info and the
transactions details, the user logs into PayPal, does their thing and
PayPal sends them back to your site and updates you with the payment
status.
Server A is my server w/ Perl 5.8. Server B is 3rd party, but we
won't worry about them for now. Server C is PayPal (Apache/1.3.27
(Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a) scripting language unknown.
When I do a standard HTML form post everything works fine, except I
would like to do the form post with PERL and save the user a click
(Gee, how thoughtful...). When I use Perl from Server A to Server C,
the post goes OK. Server C responds with HTML, the PayPal login page.
They have everything written as relative to Server C so you get
broken images and JavaScript errors because Server A is now displaying
the content.
Every example that I have found for LWP assumes that Server A will be
handling the content, but I need to have Server C handle the content
returned. Authorize.net and PayFuse work great because they simple
reply with a Pass/Fail status, but PayPal requires login, etc. that
has to be done through their srever.
Clear as mud? Any thoughts?
Hmmm... We left out one computer, right?
D = web browser of customer who's actually needs to log into PayPal and
authorize the transaction.
So, what you're trying to do is:
1) D -> A Customer is cruising around on your server w/ their browser.
They do something and now they need to pay $$$ w/ PayPal
2) A -> C You submit whatever step 1 of PayPal IPN is to PayPal to
initiate the payment
3) C -> A PayPal throws HTML back to your server saying "Hi PayPal
customer! Log in!"
4) A -> D You redirect that HTML out to your customer's web browser so
the human can, indeed, log into PayPal.
5) D -> C Your customer is now clicking around on PayPal's server,
logging in, pushing buttons, whatever. Eventually they Do The Right
Thing, authorizing you to be paid. PayPal now redirects the customer
back to your server.
6) D -> A Customer is cruising around on your server again. You're
paid, everybody's happy. Capitalism continues to make the world go
'round.
Is that right, or am I drunk?
If that's what you're trying to do, then probably the trickiest thing
is getting steps 1-4 to flow in a single run of your Perl program. That
program would probably flow like this:
orderform.pl
- Customer has just clicked something. You need their money now. You
know their PayPal login ID and whatever else you need for PayPal IPN.
- orderform.pl uses LWP or WWW::Mechanize or whatever to hit PayPal
IPN on the back end. The customer has no idea this is occuring.
- PayPal responds with a bunch of HTML which happens to be a login
page. You slurp that HTML into $paypal_response, but you still haven't
returned anything to the customer. They still have no idea anything is
going on.
- orderform.pl examines $paypal_response. If it's a login page, then
we're happy. Spit $paypal_response out to STDOUT. This is the first and
only thing the customer web browser ever saw.
- orderform.pl exits, safe in the knowledge that PayPal will do the
Right Thing and re-direct the customer back to orderform.pl (or
whatever URL you want) whenever they're done clicking around in PayPal.
Does that help? -ponder-
Take care,
j