Allowed nonessential fields to be left undefined
authormark <mark>
Tue, 23 Jun 2009 05:25:34 +0000 (05:25 +0000)
committermark <mark>
Tue, 23 Jun 2009 05:25:34 +0000 (05:25 +0000)
lib/Business/OnlinePayment/WesternACH.pm

index e18a122..94ba800 100644 (file)
@@ -22,6 +22,20 @@ my $defaults = {
   schedule     => 'live',
 };
 
+my $required = { map { $_ => 1 } ( qw(
+  login
+  password
+  command
+  amount
+  tender_type
+  _full_name
+  routing_code
+  check_number
+  _check_type 
+))};
+
+
+
 # Structure of the XML request document
 # Right sides of the hash entries are Business::OnlinePayment 
 # field names.  Those that start with _ are local method names.
@@ -144,7 +158,11 @@ sub build {
     elsif(exists($defaults->{$val})) {
       $data->{$k} = $defaults->{$val};
     }
-    # 6. Fail.
+    # 6. If the value is not required, use an empty string.
+    elsif(! $required->{$val}) {
+      $data->{$k} = '';
+    }
+    # 7. Fail.
     else {
       croak "Missing request field: '$val'";
     }