Forum

Thread tagged as: Question, Shop

Random Paypal failures, goes direct to cancel url

I've got my shop process working well and have tested it in the Paypal sandbox environment. I'm now trying to use a live Paypal account but I get occasional random failures where it goes direct to the cancel url without even trying to connect to Paypal.

It's an intermittent problem that has been plaguing me for weeks, but I think I've finally determined that if I refresh the page where I'm selecting payment method (Paypal or bank transfer) then the Paypal process fails. If I go back with items still in the cart and try again (re-entering address details) it fails again. But if I clear everything (using perch_member_log_out() and perch_shop_empty_cart() ), then it works again. [Edit: Even that is inconsistent.. it fails sometimes, but not others]

I'm not sure what is going on but I assume it must be something that is cached and causing the process to drop out. Can anyone shed any light on this? I can't go live with this until I can trust it to work every time, whatever the customer does. Thanks.

Alan Coggins

Alan Coggins 0 points

  • 2 years ago

Ah... I think it has to do with the passwordless checkout feature I'm using. Every time I test it out I'm making a new user but if I break or restart the process at a critical point it still "sees" the previous customer as being logged in. The new user gets created correctly in the Perch admin, but I'm still effectively logged in as the previous user.

Alan, I think it’s best to call perch_member_log_out after checkout on a password less checkout otherwise the member will still be logged in. The member is not logged out after checkout, only after the session ends or is explicitly logged out in code. This is so a member can choose in some setups to add/change the password and the member is then converted into a returnable member with a username and password.

Thanks Robert - yes, I'm still trying to get my head around all the possible scenarios. This issue would happen when a customer abandons the checkout process before finishing, then they come back later to start again. Say they get interrupted and navigate away, then come back and begin a whole new order. They'd still be logged in but wouldn't realise it.

I think I'll need to check for that somehow and show that they are still logged in and have already entered an address and therefore created an "account".

If using password less cart, your flow should not create an account before checkout, the account should be created upon checkout without the customers knowledge then log them out upon successfull checkout. It sounds as if your creating a passwordless guest account prior to checkout, which would result in the problems you describe.

You could use this example to check if customer is passwordless and log them out

<?php
    if (perch_member_is_passwordless()) {
        perch_member_log_out();
    }
?>

Ah, that's interesting. I have set up my checkout process in stages so I can understand what is going on. There is a cart.php page that shows the cart with adjustable quantities, then if you hit a "checkout" button it goes to an address.php page that collects the customer address using perch_shop_registration_form(). Once that is filled in, you hit a "next" button that goes to shipping.php for shipping options, but at this point the user has been created within Perch, haven't they? After shipping they go to another page to select payment option.

So it seems to be quite possible to bail out after the address.php page and not complete the process, but stay logged in.

Alan, I may be wrong as to when the account is created since I have been scanning the docs. So you may be right is your thoughts there on bailing after account creation. So it does leave me without a solution for you :(

It’s been a little while since I walked through the checkout process with perch.

I think the best solution may be to run a check on the address.php page - if they are logged in already, they should be redirected to shipping.php and not get a chance to recreate another account.

I can also display their delivery address on that shipping page and give them an option to cancel, clear everything and start again.

Thanks for your help Robert - much appreciated. It helped clarify my muddled thoughts. :-)

No... that didn't fix anything. I'm still getting random Paypal failures and I have absolutely no idea why.

I think it's time to give up on Perch Shop.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Alan,

The docs explain how you can troubleshoot failed payments: https://docs.grabaperch.com/addons/shop/gateways/paypal-express/#troubleshooting

Have you enabled debug and used PerchUtil::hold_redirects()as suggested in the docs? If you have, what does the error message say?

Hi Hussein,

Yes, I tried that. If it succeeds I get a long message giving me all the details about the paypal process. When it fails, it just kicks me straight to the cancel url and there is nothing meaningful. It doesn't seem to get anywhere near Paypal.

Don't worry about it. I've started working on moving it to Wordpress/Woocommerce. I think Perch Shop is out of my league.

Thanks anyway.