From 35db2ac9839db1d33e7c15af4af464deaea3355d Mon Sep 17 00:00:00 2001 From: plobbes Date: Tue, 29 Aug 2006 19:45:55 +0000 Subject: [PATCH] - content() now returns empty hash if no content is defined - build_subs now uses can() so it doesn't redefine subs (and generate warnings) - DOC: SYNOPSIS now uses correct "card_number" and not "cardnumber" --- OnlinePayment.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OnlinePayment.pm b/OnlinePayment.pm index bf27b0d..2a9cee0 100644 --- a/OnlinePayment.pm +++ b/OnlinePayment.pm @@ -39,7 +39,6 @@ my %fields = ( sub new { - my($class,$processor,%data) = @_; Carp::croak("unspecified processor") unless $processor; @@ -143,7 +142,7 @@ sub content { if($params{'type'}) { $self->transaction_type($params{'type'}); } %{$self->{'_content'}} = %params; } - return %{$self->{'_content'}}; + return exists $self->{'_content'} ? %{$self->{'_content'}} : (); } sub required_fields { @@ -197,8 +196,9 @@ sub dump_contents { # AutoLoader::AUTOLOAD, instead of passing up the chain sub build_subs { my $self = shift; - no warnings 'redefine'; + foreach(@_) { + next if($self->can($_)); eval "sub $_ { my \$self = shift; if(\@_) { \$self->{$_} = shift; } return \$self->{$_}; }"; } } @@ -217,11 +217,11 @@ Business::OnlinePayment - Perl extension for online payment processing my $transaction = new Business::OnlinePayment($processor, %processor_info); $transaction->content( - type => 'Visa', - amount => '49.95', - cardnumber => '1234123412341238', - expiration => '0100', - name => 'John Q Doe', + type => 'Visa', + amount => '49.95', + card_number => '1234123412341238', + expiration => '0100', + name => 'John Q Doe', ); $transaction->submit(); -- 2.20.1