Final Thank You is rendering badly.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #27882

I have just finished writing a payment plugin for Sage/Peachtree (the plugin HikaShop provides for SagePay is for their European gateway, apparently. Not the U.S. processing system.) It's based upon the Paypal Pro plugin's structure, and is working beautifully except that when the final Thank You page is rendered, the progress bar and thank you note are rendered before the template is drawn. Apparently it has some sequential problem in the page construction, probably involving the output cache.

I'm about to go compare again to other plugins to see if I have mangled a line in there somewhere, making it render the plugin response directly instead of feeding it to the output cache.

If anyone has any suggestions that might cut this search short, I'd appreciate the help.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #27892

That sounds like you have an ob_flush() somewhere in your plugin which displays the thank you page to the browser instead of leaving it in the output cache to be displayed by joomla inside the template.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #27998

Not that easy. There are no cache-related commands anywhere in the custom code.

Any details about the page flow difference between #plugin_end.php and #plugin_thanks.php? (I'm seeing either one or the other used in various other payment plugins and have no explanation a difference.) Are they called differently? Is it just a naming difference? Does it alter the text of the long configuration string used during checkout that determines what elements are shown on each page of the checkout process?

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #28001

These files are called by the plugin itself. You could have their code directly in the main plugin file. Or you could change their name to whatever you want (as well as their name in the main plugin file) and it would work the same.
Also, different persons code differently and the plugins were made by different people so that might explain the differences.
Usually, the end file is shown at the end of the checkout for the redirection to the payment gateway or to display the end message (when there is no redirection like for example with the bank transfer plugin). And the thanks file is to display a thank you message at the end, when the user comes back from the payment gateway.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #28329

Still having no luck tracking this down. There are absolutely no cache commands, and no echo or print commands, just sprint - which, by putting strings directly into variables, shouldn't affect the cache settings.


As with most of the payment plugins I've examined, "onBeforeOrderCreate" is used to handle the communication with the remote server, which authorizes or declines the purchase via curl communications. by the time another method is called by HikaShop, this process is fully resolved: emails have been sent to either confirm or deny the purchase, notices have been sent and put into the application messaging system.

"onAfterOrderConfirm" is used to empty the now-purchased shopping cart, and used "require" to load the template for the "End" or "Thanks" page. It is at this point that the "End" template is printed to the browser. Using ob_get_status, I know that an output buffer already exists, but this require does not render to it. There are no buffer commands in the other payment examples I've seen.

Here's a symptom I don't understand: the program generated progress bar is being inserted in the browser AFTER the "End" template, even though it appears before that content. If I put a "die" statement in the code immediately after the "onAfterOrderConfirm" "require" method, the "End" template is sent to the browser, but the progress bar is not rendered at all, which means it isn't rendered until after the "onAfterOrderConfirm" is completed, and is sent to the browser later. The only way I know for it to precede the already sent text is that it is inserted via javascript - with moo tools already having been called, that is possible.

To sum up: The "End" template is called and rendered, the "onAfterOrderConfirm" function ends, the progress bar is INSERTED before the previously delivered End text, THEN the layout template is rendered and delivered. Since headers have been already sent by the time the layout template HTML is delivered, some basic HTML processes, such as the character set declaration is not executed properly, not to mention that the progress bar and thank you text appears above the entire layout.

There is definitely something inside of Hikashop being triggered early, and I can't find anything that can do that in my code. All the errors take place in "onAfterOrderConfirm", and that method just isn't that complicated.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #28330

BTW, my "End" template can be completely blank, and the progress bar is still rendered before the rest of the page is delivered.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #28359

So that means that it doesn't come from the onAfterOrderConfirm but from your onBeforeOrderCreate function.
I suppose that you don't have the problem with other payment plugins. So if you empty the onBeforeOrderCreate function, it should display properly right ?

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #28414

I've planned on taking a look at that in particular today.

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #28435

OK, examining the "onBeforeOrderCreate" method led to one command I overlooked before: (remember, this plugin is based almost entirely upon the existing PayPal Pro payment plugin provided by HikaShop)

$order->history->history_data = ob_get_clean();

This takes place after an approved curl exchange with the provider, while the $order object data is being collected from the various payment ingredients. Nowhere in this process is there an echo or print statement (or any command I recognize that would write to the output buffer), and there appears to be nothing within that buffer dump. I suspect it is being dumped into a database field that is ultimately displayed in the order's Admin Order Record's History table as "Information", since the history_data field and the history_package_id fields are the only fields in that DB record that are receiving no data.

When I comment that line out, the page prints normally. I am inclined to leave it disabled, since I see no way for any data to reach that variable upon success, and no Order record is created upon failure. I'm simply at a loss as to why it exists within my source example, the PayPal Pro plugin, since I can't see how its code would receive data any more than mine would.

Upon a successful order from a remote processor, is there any information that is normally stored within this field?


Other than that housekeeping question, all my problems seem to be identified and cleared up now. Thank you for your assistance.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #28459

That makes sense.

That line in the paypal pro plugin is there to gather the debug information when you activate the corresponding function as well as gather the curl errors if any.
So it's normal that the buffer is empty normally.

You can of course put nothing in that history_data variable. It's not a problem. It's just a field where you can put some information if you want in order to display it in the history of the order (errors or payment info).

Please Log in or Create an account to join the conversation.

  • Posts: 18
  • Thank you received: 2
13 years 1 month ago #28470

Excellent. Thank you very much for your help.

Please Log in or Create an account to join the conversation.

Time to create page: 0.048 seconds
Powered by Kunena Forum