- content() now returns empty hash if no content is defined
authorplobbes <plobbes>
Tue, 29 Aug 2006 19:45:55 +0000 (19:45 +0000)
committerplobbes <plobbes>
Tue, 29 Aug 2006 19:45:55 +0000 (19:45 +0000)
- 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

index bf27b0d..2a9cee0 100644 (file)
@@ -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();