Jump to content
Larry Ullman's Book Forums

No Paypal Website Payments Pro In Europe (Well, Only Uk)


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.

 

Greetings from the Emerald Isle and thanks for any help!

 

 

Michael

Link to comment
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.

 

By the way, where are you in Ireland?

  • Upvote 1
Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Hi Larry,

 

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'].

 

Now I understand why you are using the jQuery script at the end of 'billing.html' (as you explain in http://www.larryullman.com/downloads/EffortlessECommerce_BONUS_Ch10.pdf). But how can I make that work for all those lovely hidden values in the PayPal button? How can I force the POST of the billing form?

 

Just look at all I want to pass on:

 

<input type="hidden" name="cmd" value="_xclick">

<input type="hidden" name="business" value="seller@gmail.com">

<input type="hidden" name="currency_code" value="EUR">

<input type="hidden" name="button_subtype" value="services">

<input type="hidden" name="no_note" value="0">

<input type="hidden" name="cn" value="Add special instructions to the seller">

<input type="hidden" name="rm" value="1">

<input type="hidden" name="return" value="https://mysite.com/final.php">

<input type="hidden" name="cancel_return" value="https://mysite.com/cart.php">

<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">

<input type="hidden" name="address_override" value="1">

<input type="hidden" name="item_name" value="Invoice # <?php echo $_SESSION['customer_id']; ?> ">

<input type="hidden" name="email" value="<?php echo $_SESSION['email']; ?>">

<input type="hidden" name="first_name" value="<?php echo $_SESSION['cc_first_name']; ?>">

<input type="hidden" name="last_name" value="<?php echo $_SESSION['cc_last_name']; ?>">

<input type="hidden" name="address1" value="<?php echo $_SESSION['cc_address']; ?>">

<input type="hidden" name="city" value="<?php echo $_SESSION['cc_city']; ?>">

<input type="hidden" name="zip" value="<?php echo $_SESSION['cc_zip']; ?>">

<input type="hidden" name="country" value="<?php echo $_SESSION['cc_state']; ?>">

<input type="hidden" name="amount" value="<?php echo $total - $_SESSION['shipping'] ; ?>">

<input type="hidden" name="shipping" value="<?php echo $_SESSION['shipping']; ?>">

<input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">

<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">

 

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.

 

Thanks for all your help!

 

 

Michael

Link to comment
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.

Link to comment
Share on other sites

Hi Larry,

 

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!

 

Kind regards,

 

 

Michael

Link to comment
Share on other sites

Hi Larry,

 

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.

 

I hope, I have explained things clearly!

 

Kind regards,

 

 

Michael

Link to comment
Share on other sites

Hi all,

 

I have the PayPal Website Payments Standard for the second example working. I have moved most of the values that have to be passed on to PayPal, to the 'gateway_setup.php' file:

 

$data['cmd'] = '_xclick';
$data['business'] = 'seller@gmail.com';
$data['currency_code'] = 'EUR';
$data['button_subtype'] = 'services';
$data['no_note'] = '0';
$data['cn'] = 'Add special instructions to seller';
$data['no_shipping'] = '1';
$data['rm'] = '1';
$data['return'] = 'https://mysite.com/final.php';
$data['cancel_return'] = 'https://mysitecom/cart.php';
$data['bn'] = 'PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted';
$data['address_override'] = '0';
$data['item_name'] = 'Invoice # '.$customer_id;
$data['email'] = $_SESSION['email'];
$data['first_name'] = $cc_first_name;
$data['last_name'] = $cc_last_name;
$data['address1'] = $cc_address;
$data['city'] = $cc_city;
$data['zip'] = $cc_zip;
$data['country'] = $cc_state;

to the gateway_setup.php file

 

In gateway_process.php, the variable values are established:

$data['amount'] = $order_total - $_SESSION['shipping'];
$data['shipping'] = $_SESSION['shipping'];
$data['custom'] = $customer_id;
$data['invoice'] = $_SESSION['order_id'];

 

And in the same file, HEADER() redirects the user to PayPal's site while passing on the information to PayPal:

 

// Convert the data:
$post_string = '';
foreach( $data as $k => $v ) {
   $post_string .= "$k=" . urlencode($v) . "&";
}
$post_string = rtrim($post_string, '& ');
header("location:https://www.sandbox.paypal.com/cgi-bin/webscr?".$post_string);

 

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.

Almost there, almost! :-)

 

Regards ,

 

 

Michael

Link to comment
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!

Link to comment
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!

Link to comment
Share on other sites

Hi Larry,

 

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:

SELECT c.email FROM customers c, orders o, transactions t
WHERE c.id=o.customer_id AND o.id=t.id
AND t.id= [PayPal's returned order_id]

 

Once that works, I am done!

 

Regards,

 

 

Michael

Link to comment
Share on other sites

  • 2 weeks later...
 Share

×
×
  • Create New...