I introduced 3rd party payment processor for our client. After successful payment user is redirected to notify-url, that causes now an infinite redirect loop in WordPress 4.3 (CiviCRM 4.6.8). Our membership payment form is embedded with the shortcode [civicrm component="contribution" id="2" mode="live"] in a WP page (/members/pay-fees/). Payments are registered correctly in CiviCRM.

I debugged the problem with PhpStorm Debugger and it seems, that redirect no. 2 returns correctly content for the thank you page, but after that WP launches do_action('template_redirect') in template-loader.php causing the redirect_canonical function to be run (in canonical.php). Because of the url in form of /?page=?redirect_canonical concludes, that user is needed to redirect to the front page with identical parameters, which leads to the erroneous redirect loop. After this rest of the loop seems to be related to the missing qfKey in CiviCRM.

So my question is how the user should be redirected to the correct WP page (/members/pay-fees/) after payment instead of redirecting user to the site root (/?page=CiviCRM...) or should the redirect_canonical be prevented?

Now in the PaytrailIPN (I modified a bit original 3rd party code) the redirect is done in following way:

2 Answers
2

I solved the problem by using Ramesh's suggestion as a starting point. Instead of introducing hard coded Thank you & Cancel pages I stored the permalink address of the WordPress page along the other invoice stuff during the creation of the payment in Paytrail extension:

I guess there should be more logic for handling different situations and upgrade hook implemented. This behaviour could be made also optional and support for Joomla and Drupal introduced (if needed), but now it solves the problem for the client.

BTW, double title on the contribution WordPress page should be eliminated. Is the display:none way to go?