Forums / Bug Reports / [Done 155b] collectsCardDataOnsite: payment-class not creating correctly-named fields

[Done 155b] collectsCardDataOnsite: payment-class not creating correctly-named fields

Views: 1,480

Results 1 to 2 of 2
30 Aug 2016, 5:11 PM
#1
lat9 avatar

lat9

Administrator

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

[Done 155b] collectsCardDataOnsite: payment-class not creating correctly-named fields

When a payment method (e.g. authorizenet_aim) collects card data onsite, there is supposed to be a hidden variable created for that payment method so that the jQuery running on the checkout_payment page "knows" this condition.

The processing that's supposed to insert that field is the *selection *function of /includes/classes/payment.php, but the hidden-input's name is winding up as _collects_onsite instead of (for example) authorizenet_aim_collects_onsite.

The issue is that that function's using the wrong variable name to create that/those hidden variables. The function needs to be changed from:

  function selection() {
    $selection_array = array();
    if (is_array($this->modules)) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ($GLOBALS[$class]->enabled) {
          $selection = $GLOBALS[$class]->selection();
          if (isset($GLOBALS[$class]->collectsCardDataOnsite) && $GLOBALS[$class]->collectsCardDataOnsite == true) {
            $selection['fields'][] = array('title' => '',
                                         'field' => zen_draw_hidden_field($this->code . '_collects_onsite', 'true', 'id="' . $this->code. '_collects_onsite"'),
                                         'tag' => '');

          }
          if (is_array($selection)) $selection_array[] = $selection;
        }
      }
    }
    return $selection_array;
  }

to

  function selection() {
    $selection_array = array();
    if (is_array($this->modules)) {
      reset($this->modules);
      while (list(, $value) = each($this->modules)) {
        $class = substr($value, 0, strrpos($value, '.'));
        if ($GLOBALS[$class]->enabled) {
          $selection = $GLOBALS[$class]->selection();
          if (isset($GLOBALS[$class]->collectsCardDataOnsite) && $GLOBALS[$class]->collectsCardDataOnsite == true) {
            $selection['fields'][] = array('title' => '',
                                         'field' => zen_draw_hidden_field([B]$class[/B] . '_collects_onsite', 'true', 'id="' . [B]$class[/B]. '_collects_onsite"'),
                                         'tag' => '');

          }
          if (is_array($selection)) $selection_array[] = $selection;
        }
      }
    }
    return $selection_array;
  }
12 Oct 2016, 1:18 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: [Done 155b] collectsCardDataOnsite: payment-class not creating correctly-named fields

.
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.