Forums / Bug Reports / Payment method messages not reset in tpl_checkout_success_default.php

Payment method messages not reset in tpl_checkout_success_default.php

Views: 819

Results 1 to 3 of 3
10 Jul 2013, 1:57 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Payment method messages not reset in tpl_checkout_success_default.php

If a payment method (like authorizenet_aim) sets a value into the session variable 'payment_method_messages', those messages are displayed on the checkout success page. If a message was set by one payment method and the customer, during the same session, chose to create another order using a different payment method then those same messages would be displayed to the customer at the conclusion of the second order ... since the session variable is never reset.

Current code fragment in tpl_checkout_success_default.php:

<!-- bof payment-method-alerts -->
<?php
if (isset($_SESSION['payment_method_messages']) && $_SESSION['payment_method_messages'] != '') {
?>
  <div class="content">
  <?php echo $_SESSION['payment_method_messages']; ?>
  </div>
<?php
}
?>
<!-- eof payment-method-alerts -->

Proposed addition in red:

<!-- bof payment-method-alerts -->
<?php
if (isset($_SESSION['payment_method_messages']) && $_SESSION['payment_method_messages'] != '') {
?>
  <div class="content">
  <?php echo $_SESSION['payment_method_messages']; ?>
  </div>
<?php
  unset($_SESSION['payment_method_messages']);
}
?>
<!-- eof payment-method-alerts -->
10 Jul 2013, 3:07 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Payment method messages not reset in tpl_checkout_success_default.php

Good catch of a rare scenario.

As far as fixing, rather than add more business logic to the template, it's probably better to change it like this:

  • add to the header_php file: ```
    $additional_payment_messages = '';
    if (isset($_SESSION['payment_method_messages']) && $_SESSION['payment_method_messages'] != '') {
    $additional_payment_messages = $_SESSION['payment_method_messages'];
    unset($_SESSION['payment_method_messages']);
    }

- edit the template file:```
<!-- bof payment-method-alerts -->
<?php
if (isset($additional_payment_messages) && $additional_payment_messages != '') {
?>
  <div class="content">
  <?php echo $additional_payment_messages; ?>
  </div>
<?php
}
?>
<!-- eof payment-method-alerts -->

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Jul 2013, 6:04 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,110
Plugin Contributions:
56

Re: Payment method messages not reset in tpl_checkout_success_default.php

Thanks, DrByte, I was just being lazy in my proposed fix.