perrin has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Business::OnlinePayment for the first time. When the new() method is called more than once during the life of a program (very common with a batch script or mod_perl), I get a whole bunch of warnings about redefined subs. This has been reported, and there is a simple patch for it, but this experience is making me lose faith in the module. How could other people have used this without running into this problem? Not everyone could have been running it under CGI.

So, my question is, are there any people out there using this module in a non-CGI environment successfully? Credit card processing is not a place where you want to have any nagging distrust for a module.

The bug seems to be in the core module, but FYI I am using the AuthorizeNet subclass with it at the moment.

  • Comment on Business::OnlinePayment sub redefined warnings

Replies are listed 'Best First'.
Re: Business::OnlinePayment sub redefined warnings
by runrig (Abbot) on Jun 03, 2005 at 22:25 UTC
    (Not really answering your question, but) it does seem like a long time for a simple bug to be open, but there are several developer releases, and maybe he's just being careful about what gets released. I'd do the patch differently anyway, moving the first call to build_subs outside of new() so the first bunch of subs get defined upon use of the module, and change the body of the sub to:
    foreach my $attrib (@_) { no strict 'refs'; *$attrib = sub { my $self = shift; $self->{$attrib} = shift if @_; return $self->{$attrib}; } unless defined &$attrib; }
    But maybe that's just MHO :-)

    Oh, and to answer your question, I think a lot of people just ignore warnings in their error logs :-)

Re: Business::OnlinePayment sub redefined warnings
by jasonk (Parson) on Jun 05, 2005 at 07:41 UTC

    The bugs haven't been fixed primarily because there are dozens of people who have written subclasses to go with it and I no longer work with e-commerce, so I was reluctant to change things that may break other people's subclasses by trying to update a module that I don't even really use anymore (and I don't have access to the test environments for any of the processors anymore).

    Ivan Kohler has taken over maintenance on many of the subclasses that I used to maintain (and has written many more) and has been working on the next generation of the module. You can find more information on his effort as well as a developer mailing list you can join if you are interested in helping him out at http://420.am/business-onlinepayment/ng.html.

    I've left the last version of it that I wrote on CPAN simply because there are so many people using it, but I'm not actively maintaining it.


    We're not surrounded, we're in a target-rich environment!
      Thanks for the response, Jason. I'll check in on the new list.
Re: Business::OnlinePayment sub redefined warnings
by zentara (Cardinal) on Jun 04, 2005 at 11:51 UTC
    I looked at the code which required the "patch".
    $ perl -MBusiness::OnlinePayment -we 'for( 1..2 ) { \ my $tx= Business::OnlinePayment->new('AuthorizeNet'); }'
    From what I can tell, this is not a bug, because you are trying to redefine $tx as you work thru the loop.

    Usually when you use multiple instance of a module, you name your "instances of the module" differently, like $tx and $tx1. Usually you would use a hash, like

    my %tx; for(1..2){ $tx{$_}{'object'}=Business::OnlinePayment->new('AuthorizeNet'); }
    The other technique is to only have 1 B::OP object going at any one time, and undef it at the end of each processing loop.

    But I havn't actually tried the module, so I may be missing something. ;-)


    I'm not really a human, but I play one on earth. flash japh
      You are missing something. The variable names are irrelevant -- you get the same warnings if you use different variables. It's also perfectly legal to overwrite a variable with a new instance of an object, but that has nothing to do with the bug.