Jump to content

Cached output from ModuleFrontController


Pelleplutt

Recommended Posts

Hi, 

 

I am struggling with one of the steps in developing a payment module and I am hoping for some experienced help here. 

 

The basic steps of the payment is:

 

1. From the checkout create an API call to our payment service, this will return an URL to a webpage where to complete the payment (this url will be unique for each payment)

 

2. Display the url in an iframe hosted within the store to the user

 

3. Once the steps of the payment is completed the user will be redirected to the "Thank you for your payment" page. 

 

 

This is easy enough and all works really brilliantly in my test environments. When testing it in a real production store however I am experiencing problems with what appears to be caching.

 

i hook hookPayment() and set an url for initiating the payment to

 

$context->link->getModuleLink('mymodule', 'iframe', array(), true));
and the iframe controller essentially does:
 
class MyModuleIframeModuleFrontController extends ModuleFrontController {
    public function initContent()
    {
        $url = $mymodule->retrievePaymentUrl();
        $this->context->smarty->assign(array(
                    'iframe_url' => $url
                    ));


        $this->setTemplate('iframe.tpl');
    }
}
Where $mymodule->retrievePaymentUrl() does an RPC call and retreives the URL from our service. 
 
The template iframe.tpl does:
 
{nocache}
    <iframe src="{$iframe_url}" style="width:100%;height:600px;border:none"></iframe>
{/nocache}
The basic mechanism works in my test environments and everything is fine. However in the production environment the end result is that when I start the payment a second time I will get the same url as the previous payment did. I.e. the initContent() method does not run, and the rendered template is the same as the time before (Which is a disaster for payments obviously). Force-reloading the page in the web browser causes the code to run and a new url to be returned. But the problem persists the next time I return and make a payment... 

 

I cannot seem to find a viable solution to this and testing is tedious as I cannot really reproduce it in any other environment then a customers live store. 

 

Does anybody have any clue about this? I am using the modulefrontcontroller wrong?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...