Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while payment redirection in some hosting provider due to caching #56

Open
knit-pay opened this issue Feb 24, 2022 · 1 comment
Open

Comments

@knit-pay
Copy link
Contributor

Hello Team

I encountered another rare issue. This happens with websites on some hosting providers. Some hosting providers by default cache the homepage of the website. because of which filter_has_var( INPUT_GET, 'payment_redirect' ) always returns false even if payment_redirect and key are available in the URL.

if ( ! filter_has_var( INPUT_GET, 'payment_redirect' ) || ! filter_has_var( INPUT_GET, 'key' ) ) {

I suggested 2 of my clients contact the hosting providers and remove the caching on the homepage, and this solved the issue. But most of such clients think that this is the issue with the plugin instead of hosting. because they don't contact us.

Proposed Solution: If at the function below, we will change the URL format to an SEO-friendly URL for the hosting which supports SEO-friendly URL, this issue will get resolved. If hosting does not support SEO-friendly URL, we can continue to use this method.

$url = add_query_arg(

The same issue is there with handle_returns and various other functions also.

What do you think? Can we fix this issue anyhow?

@remcotolsma
Copy link
Member

Good catch, we should be able to fix that. In our PayPal gateway integration we (ab)use the REST API for this:

The advantage of the WordPress REST API is the ease of registering endpoints which automatically work with 'Plain Permalinks' (Ugly Permalink) and 'Pretty Permalinks':

We could use an endpoint like /wp-json/pronamic-pay/v1/payments/:payment_id/redirect?key=:key. Downside is that it's not common to output HTML via REST API endpoints (required for 'redirect' via HTML).

Maybe we should split this up too:

flowchart TD
    A[Start] --> B{HTTP or HTML?}
    B -->|HTTP| C[Redirect to gateway]
    B -->|HTML| D[Redirect to WordPress page]
    D --> E[Auto submit HTML form]
Loading

The question then is whether we make use of a regular WordPress page for the HTML 'redirect' or opt for custom rewrite rule. I think we should go for a custom rewrite rule so that we can use 'Pretty Permalinks', something like:

/:namespace/payments/:payment_id/redirect?key=:key

@remcotolsma remcotolsma moved this to Todo in Pronamic Pay Apr 12, 2022
knit-pay added a commit to knit-pay/wp-pay-core that referenced this issue Feb 10, 2024
knit-pay added a commit to knit-pay/wp-pay-core that referenced this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants