[bop-devel] Re: Business-OnlinePayment OnlinePayment.pm,1.16,1.17
Ivan Kohler
ivan at 420.am
Sun Nov 19 21:50:38 PST 2006
Can you take a quick look at the patch in
http://rt.cpan.org/Ticket/Display.html?id=22074
and see if there's any functional difference compared to your changes?
--
_ivan
On Mon, Nov 20, 2006 at 04:57:39AM +0000, Phil Lobbes wrote:
> Update of /home/cvs/cvsroot/Business-OnlinePayment
> In directory wavetail:/tmp/cvs-serv18276
>
> Modified Files:
> OnlinePayment.pm
> Log Message:
> * Add Class data %WrappedSubmitClassMethod to remember "wrapped" submits
> * Fix new() to check %WrappedSubmitClassMethod to avoid creating deep recursion
> * Minor documentation change in print statements use ',' instead of '.'
>
>
> Index: OnlinePayment.pm
> ===================================================================
> RCS file: /home/cvs/cvsroot/Business-OnlinePayment/OnlinePayment.pm,v
> retrieving revision 1.16
> retrieving revision 1.17
> diff -u -d -r1.16 -r1.17
> --- OnlinePayment.pm 10 Oct 2006 19:46:41 -0000 1.16
> +++ OnlinePayment.pm 20 Nov 2006 04:57:37 -0000 1.17
> @@ -10,6 +10,9 @@
> $VERSION = '3.00_04';
> $VERSION = eval $VERSION; # modperlstyle: convert the string into a number
>
> +# Remember subclasses we have "wrapped" submit() with _pre_submit()
> +my %WrappedSubmitClassMethod = ();
> +
> my %fields = (
> authorization => undef,
> error_message => undef,
> @@ -27,7 +30,6 @@
> transaction_type => undef,
> );
>
> -
> sub new {
> my($class,$processor,%data) = @_;
>
> @@ -55,15 +57,20 @@
> }
>
> unless ( $subclass->can('submit') eq $class->can('submit') ) {
> - no strict 'refs';
> - no warnings 'redefine';
> my $submit = qualify_to_ref('submit', $subclass);
>
> - $self->{_child_submit} = \&$submit;
> - *{"${subclass}::submit"} = sub {
> - my $self = shift;
> - $self->_pre_submit();
> - }
> + # "wrap" submit ONLY once, cache info for later calls to new()
> + if ( ! exists $WrappedSubmitClassMethod{$subclass} ) {
> + no warnings 'redefine';
> + no strict 'refs';
> +
> + $WrappedSubmitClassMethod{$subclass} = \&$submit;
> + *{"${subclass}::submit"} = sub {
> + my $self = shift;
> + $self->_pre_submit();
> + }
> + }
> + $self->{_child_submit} = $WrappedSubmitClassMethod{$subclass};
> }
>
> return $self;
> @@ -89,7 +96,7 @@
> }
> }
>
> -sub _pre_submit{
> +sub _pre_submit {
> my ($self) = @_;
> my $fraud_detection = $self->fraud_detect();
>
> @@ -213,9 +220,9 @@
> $transaction->submit();
>
> if($transaction->is_success()) {
> - print "Card processed successfully: ".$transaction->authorization()."\n";
> + print "Card processed successfully: ", $transaction->authorization(), "\n";
> } else {
> - print "Card was rejected: ".$transaction->error_message()."\n";
> + print "Card was rejected: ", $transaction->error_message(), "\n";
> }
>
> =head1 DESCRIPTION
>
--
_ivan
More information about the bop-devel
mailing list