404 on /wc-api/ppcp_order_return/
-
Hi,
When testing PayPal, I am now getting a 404 page not found when returning to the website after the payment is done on PayPal.
Can’t seem to understand where the problem is.
Any ideas?Thank you
-
Hi @xamax,
The return url should have several query parameters like the PayPal order ID, the WooCommerce order ID, and the order key. Do you see those query parameters?
If not, that is the reason the redirect is not working. The plugin requires those query parameters as a security check and if they are missing, the code for completing the payment is not executed.
Kind Regards
Hi, thank you for the prompt reply.
Yes, I see them. I just did not add them for readability (I paste it below, replacing the data with xxx). The order_id is correct.
wc-api/ppcp_order_return/?order_id=xxx&order_key=wc_order_xxxxx&payment_method=ppcp&token=xxx&PayerID=xxxx
WooCommerce version 8.3.1
-
This reply was modified 1 year, 11 months ago by
Massimo.
Hi @xamax,
It’s working fine on our end using WooCommerce 8.3.1. You might have a plugin that’s interfering with the WooCommerce api action that our plugin uses.
Are you using another PayPal plugin? I’d audit what you have changed on your site recently to see if any of those changes could have caused this behavior.
Kind Regards
Thank you. Yes, I confirm that on a clean install all works…however I can’t find which plugin is interfering with wc-api.
I am only using your payment plugins –Stripe (which works) and Paypal.
I disabled most of the plugins and I still et 404.
If you have an idea on how I could debug this, please let me know. I’ll keep trying and update this post if/when I find the issue.
Hi @xamax,
Try checking your permalink settings and play with those settings to see if that makes a difference.
If it works on a clean install, maybe you have something like a
.htaccessfile in your WordPress directory that’s altering how urls are parsed by your webserver.KInd Regards
Hi,
Thank you for your support.
Maybe I found the issue.
I use Polylang as the site is in multiple languages.
The URL is set to include the language, e.g.:
http://www.mysite.com/en/
http://www.mysite.com/fr/Say that I am on the /en/ page, after paying with PayPal the return URL is now:
http://www.mysite.com/wc-api/ppcp_order_return/?order_id=9132…
the /en/ is missing, that’s why I land on the 404.
If I add it manually from the 404-page, then it works as expected.
Now, how can I fix this?
Thank you!
The PayPal plugin uses the WooCommerce provided method
WooCommerce::<strong>api_request_url</strong>.https://plugins.trac.wordpress.org/browser/woocommerce/trunk/includes/class-woocommerce.php#L831
That method uses the WordPress
home_url()function and I suspect if you go to WordPress Admin > Settings > General your Site Address option is missing the locale portion of the url.Kind Regards
Hi,
I suspect ... WordPress Admin > Settings > General your Site Address option is missing the locale portion of the urlYes, and that is the expected behaviour.
When I echo home_url() the url is correct and includes /en/.
Thank you for the link in your reply!!
Looking at the source code, I saw on line 843:
$api_request_url = trailingslashit( home_url( '/wc-api/' . $request, $scheme ) );This is where the issue occurs! Looks like the path you set in ‘ ‘ overrides the url set by Polylang. However, you added a filter on line 851 (great!)
apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl )So here’s a little snippet that adds the language slug to the url:
function ppl_api_request_url($api_request_url, $request, $ssl) { $ppl_url = trailingslashit( home_url('/'.pll_current_language().'/wc-api/' . $request, $scheme ) ); return $ppl_url; } add_filter('woocommerce_api_request_url', 'ppl_api_request_url', 10, 3);Tested and works!
Thank you again for your help and support!
-
This reply was modified 1 year, 11 months ago by
Massimo.
-
This reply was modified 1 year, 11 months ago by
The topic ‘404 on /wc-api/ppcp_order_return/’ is closed to new replies.