'Transaction not redirecting back to website

I setup payment processing via a Hosted Payment Page. I am using a full redirect and made sure to include a full website in the redirect.init method (http://WEBSITE/response.php)

When I do a transaction I get the following errors:

Your transaction has been successful but there was a problem connecting back to the merchant's web site. Please contact the merchant and advise them that you received this error message.

Full Page Redirect Code:

<script>
$(document).ready(function () {
   jsonFromRequestEndpoint = <?php echo $hppJson; ?>;
   RealexHpp.setHppUrl("https://pay.sandbox.realexpayments.com/pay");                    
   RealexHpp.redirect.init("creditSubmit", "https://WEBSITE/response_globalPay.php", jsonFromRequestEndpoint);
   $('#creditSubmit').click();
});
</script>


Solution 1:[1]

You usually get this error when you are testing on a local environment.

If you want to test on a local environment, you need to expose your local environment to the internet - we are using ngrok for this, but you can use any other service that helps you do that.

After you get the URL from the service mentioned above, just replace the WEBSITE with it.

Everything should work as expected after you've done this.

Solution 2:[2]

Please be sure that you are defining your Hpp Response URL ("https://WEBSITE/response_globalPay.php") only on the client side. Make sure that you are not defining it again in the server side while generating the payment request json.

I was doing the same mistake of defining it on the client side as well as server side code where I was generating the payment request json.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ahumulescu
Solution 2 Bikramjeet