Recommended Posts

I can't say how grateful I am to Larry for this book. I already used the first example to set up a e-business, selling a digital product, and now I am close to finishing a second one, based on the book's second example. I am hardly a PHP wizard but I have learned so much from Larry's books. I know how to read and debug the PHP code and the MySQL stored procedures and I can figure out what changes to make in order to tweak the example code to my requirements.

But at the moment, I am a bit stuck. Two of the concepts for the Coffee store I really like: no user registration and payment processing over IPN without exiting the website. For the latter, the book uses Authorize.net as a payment gateway, but because only American customers can avail of their service, Larry recently in his blog explained how the same would work with PayPal's Website Payments Pro. You can probably imagine my disappointment when last night I discovered that PayPal only offers to service to customers in the UK.

So now I am back to Website Payments Standard/Express Checkout. I have looked at other gateways such as Moneybookers.com and none offer something similar to Payments Pro.

Here is my question: What changes (and at what point in the check out process) would I have to make to convert the payment method in example 2 to Website Payments Standard/Express Checkout? I may still end up using Moneybookers.com because they offer national debit cards and their fees even seem better than PayPal's. In some European countries, PayPal didn't really catch on or -quite undeservedly, I think- got bad publicity.

Share this post

Link to post

Share on other sites

Thanks for the nice words. In answer to your question, you'd generally make the same changes that I made in the posting that explains how to use PayPal's Website Payments Pro. It's just a matter of changing the URL, changing the names of the input parameters, and then changing the references to the output parameters. The fundamental part, the request, will be the same kind of process.

Share this post

Link to post

Share on other sites

I just finished implementing Paypal's Express Checkout with fairly little difficulty. It runs on a very similar set of principles, as Larry stated, and there are even settings to make it that much more like website payment's pro.

Either way, you will still have to do all of the IPN integration.

Now, forgive me if I misunderstood you, but let me clarify: to my knowledge, if you do checkout with paypal express checkout, the user will always have to leave the site to log into paypal.

By default, when you do express checkout, you pass info to paypal, including a total estimate, the user logs in, confirms that they want to do the order, and then is returned to your site with a token id. At this point, the transaction is not official, and it is up to you to communicate with paypals site that you want to make the payment official.

However, if you would like it to behave more similarly to website payments standard, there is an option in the express-checkout account to have the payment completed on paypal's site.

Share this post

Link to post

Share on other sites

To be absolutely clear, if you do PayPal Website Payments Standard, the user has to leave your site and go to PayPal. If you do PayPal Website Payments Pro, the user does not leave your site. Express Checkout is possible with both, I believe. In other words Pro/Standard are possible avenues for the merchant to use; Express Checkout is an option the user has as an alternative to the full, formal login.

Share this post

Link to post

Share on other sites

I am making good progress with the changes that are required for PayPal's Website Payments Standard. Most changes were on the billing.php page because all those credit card values don't have to be captured. I have used the 'phone' field to get a valid value for 'cc_last_four' and that works. I can pass on values successfully to the Sandbox. So far so good.

But the PayPal button is causing an issue on 'billing.php', too: as in fact 2 POSTs are being done, the PayPal 'Submit' wins while skipping the billing form's validation and the call to the 'add_order' stored procedure. As a consequence, no rows are being added to the 'order' and 'order_contents' tables and the session has no $_SESSION['order_total'] nor $_SESSION['order_id'].

As you can see, for testing purposes I am using $total instead of $_SESSION['order_total'] but don't have a $_SESSION['order_id']. Can you think of a way I can use the jQuery script to achieve that both forms are being posted as intended?

BTW, by now you are a household name here. My daughter, 9 years old, specifically loves to ask whether I am reading Larry ULLMAN again, with a strong emphasis on your last name. She points out that "ULL" in Irish means "apple". Poor kids, in Ireland, Irish is mandatory in primary and secondary school but only 5 % of the population speaks the language.

Share this post

Link to post

Share on other sites

So, considering your other thread, is this still an open issue for you?

Thanks for the nice words. I had no idea that ULL is "apple" in Irish. There's a bit of Irish in my family (as with almost all American families), but not the Ullmans. That name is German, from the town of Uhl.

My wife and I were in Ireland for a week six years ago, by the way. Spent a couple of days in Dublin, a night in Kilkenny (great), and a couple of days in Galway. I came down with the Black Death as part of my European experience, so didn't get to see much of Galway, but otherwise really enjoyed myself there. Will definitely go back some day.

Share this post

Link to post

Share on other sites

Yeah, that issue is still open for me ;-( How can I POST the two forms in billing.php?

It took me a while to figure out how to pass values to PayPal and I got that working. I thought, I'd share that on this forum because it is so simple to accomplish but nowhere is it explained on PayPal's help pages. But now with the button, the call to the stored procedure is being bypassed so there are no values for 'order_total' and 'order_id'.

Somehow, I have a feeling that the jQuery script can do that but I don't see how (yet). Any help/suggestions are most welcome!

Yes, Ireland is a beautiful place, especially Kerry, Clare (Cliffs of Moher!) and Galway. I live in Cork which calls itself "the real capital". I hope, you get to make that second trip!

Share this post

Link to post

Share on other sites

Or let me rephrase the issue: how can I use something like the 'gateway_process.php' file to submit the POST to PayPal and to re-direct the user to PayPal's site, while 'billing.php' does the POST that calls the stored procedure and inserts the order into the 'order' and 'order_contents' tables? Using 'gateway_process.php' would have the added benefit of hiding all those values (including my PayPal ID or seller email) from prying eyes.

I have only a vague understanding of cURL, maybe a cURL session could accomplish that.

Obviously, I also have to retrieve PayPal's response (your ipn script in the 1st example) so the 'transaction' table can be updated.

Finally, I am using the extended ipn.php file to retrieve PayPal's response and add it to the 'transactions' table. That requires minor change to the table and the stored procedure ('CALL add_transaction') because the response values from PayPal are slightly different from the one Authorize returns, mainly I had to change 'tid' from BIGINT to VARCHAR(20).

Of course, the flow for the second example is now a bit different so there is some work left. I think, I will have to add a check for the PayPal response to the final.php so a value can be assigned to '$_SESSION['response_code']' there instead of on the 'billing.php' page.

Share this post

Link to post

Share on other sites

BTW, the good thing from this approach is that all those important "hidden" values are no longer in the PayPal button and therefore not visible in the source code. Recently, there was a scam that affected third party sellers on Amazon: scammers used the seller email address to fool sellers into believing that Amazon had received payment from buyers and goods could be released!

Share this post

Link to post

Share on other sites

Sorry, I've been "in the weeds" here and haven't been able to respond. It sounds like you've been figuring this out and thanks for sharing your solutions. Let me know if you still have questions and I'll try to do better about responding!

Share this post

Link to post

Share on other sites

No to worry. It is working very nicely now and I am very happy with the new process (no values in the PayPal button, but passed on through HEADER() in 'gateway_process.php'). But as the user moves to the PayPal site, the sending of the confirmation email depends on his completing the process and returning to the 'final.php' on my site . If for some reason the user abandons that process after his payment, he won't receive the email.

So at the moment, I am working on integrating email_receipt.php into the ipn.php file. That shouldn't be too difficult because PayPal returns the order_id that can be used in a stored procedure that runs a simple query: