If this is your first visit, check our documentation. To post, register or login.
Forums / Addon Payment Modules / AuthorizeNet_AIM emulator/eprocessingnetwork observer plugin problem

AuthorizeNet_AIM emulator/eprocessingnetwork observer plugin problem

Started by jondaley on 27 Sep 2024, 11:20 AM · Views: 1,483

Results 1 to 2 of 2
27 Sep 2024, 11:20 AM
#1
jondaley avatar

jondaley

New Zenner

Join Date:
Jun 2005
Posts:
11
Plugin Contributions:
0

AuthorizeNet_AIM emulator/eprocessingnetwork observer plugin problem

PHP 8.2 if that matters. USPS plugin installed.

I just upgraded to 2.0.1 so I thought I would try to reset the credit card processor and do it the right way, as I've had a variety of plugins over the years. I removed all old plugins (ceon, etc) and so just have the base authorizenet_aim plugin activated and configured.

Following directions from a comment within the plugin, it directed me to create an observer:

+++ includes/classes/observers/auto.authorizenet_aim.php
<?php
// An auto-loaded observer that enables switching processor to eprocessingnetwork
class zcObserverAuthorizenetAim extends base{
  public function __construct(){
    $this->attach($this, array('NOTIFY_PAYMENT_AUTHNET_MODE_SELECTION'));
  }

  public function update(&$class, $eventID, $mode, &$p2, &$p3, &$p4, &$p5, &$p6, &$p7){
    error_log(print_r($class, true) . "\neventid".print_r($eventID, true). "\np2:".print_r($p2, true)."\nmode:".print_r($mode, true));

    if($eventID != "NOTIFY_PAYMENT_AUTHNET_MODE_SELECTION")
      return;
    
    if($mode == "AIM")
        $mode = "eProcessing";
  }
}

The problem is that the $mode parameter is read-only (even if I add an &) and the $class->mode variable is private, so the comment in the authorizenet_aim module appears to be incorrect.

I can get it to work if I modify the core code directly:

Index: includes/modules/payment/authorizenet_aim.php
===================================================================
--- includes/modules/payment/authorizenet_aim.php    (revision 30655)
+++ includes/modules/payment/authorizenet_aim.php    (working copy)
@@ -619,9 +619,9 @@
     }
 
     // set URL
-    $this->mode = 'AIM';
+    $this->mode = 'eProcessing';
$this->notify('NOTIFY_PAYMENT_AUTHNET_MODE_SELECTION', $this->mode, $submit_data);

But, it would be nice for the notify trigger to work correctly. I don't know if the right answer is to make the mode variable public or to pass in the parameter to the notify() as a second/third parameter so then it can be edited (and if that method is done) then the switch($this->mode) below would need to be changed as well.

28 Sep 2024, 7:40 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: AuthorizeNet_AIM emulator/eprocessingnetwork observer plugin problem

Yes, it was intended that using $class->mode = 'whatever' would suffice. But you're right, the fact that it's a private property breaks that. I can't find the eProcessing observer I used to do that originally, so I don't know what hoop I used to get around that before.

Three approaches you could take. All require editing the aim file though.

  • instead of private declare it public, so your observer can work
  • hard-code eprocessing instead of AIM, no observer required
  • pass another parameter, perhaps $new_mode. First set it to null before the notify call, then pass it in the notifier (receive in observer with &), and then after the notifier check if it's non-null and set $this->mode to $new_mode (again only if not null, since the observer will update it).

Any of those will work.

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