clean up parameters
authormark <mark>
Tue, 27 Oct 2009 01:22:40 +0000 (01:22 +0000)
committermark <mark>
Tue, 27 Oct 2009 01:22:40 +0000 (01:22 +0000)
lib/Business/OnlinePayment/Jety.pm

index c154d21..890152e 100644 (file)
@@ -13,7 +13,7 @@ use Tie::IxHash;
 $VERSION = '0.01';
 $me = 'Business::OnlinePayment::Jety';
 
-$DEBUG = 1;
+$DEBUG = 0;
 
 my @fields = (qw(
   username
@@ -31,6 +31,8 @@ my @fields = (qw(
   programdesc
   ref
   bankname
+  bankcity
+  bankstate
   accountaba
   accountdda
   amount
@@ -42,6 +44,8 @@ my %map = (
   last_name  => 'lastname',
   address    => 'address1',
   bank_name  => 'bankname',
+  bank_city  => 'bankcity',
+  bank_state => 'bankstate',
   account_number => 'accountdda',
   routing_code => 'accountaba',
 );
@@ -66,9 +70,14 @@ sub map_fields {
   die "Jety interface only supports Normal Authorization.\n"
     if(lc($content->{action}) ne 'normal authorization');
 
-  $content->{'function'} = 'ach';
+  $content->{'function'} = 'echeck';
   $content->{'programdesc'} = '415-462-1624 Business::OnlinePayment::Jety';
   $content->{'ref'} = time2str('%Y%m%d',time).'-'.int(rand(1000000));
+
+  $content->{'bankname'} ||= 'unknown';
+  $content->{'bankcity'} ||= 'unknown';
+  $content->{'bankstate'} ||= 'XX';
+
   return;
 }
 
@@ -77,6 +86,13 @@ sub submit {
   $Business::OnlinePayment::HTTPS::DEBUG = $DEBUG;
   $DB::single = $DEBUG; 
 
+  # strip existent but empty fields so that required_fields works right
+  foreach(keys(%{$self->{_content}})) {
+    delete $self->{_content}->{$_} 
+      if (!defined($self->{_content}->{$_} ) or
+           $self->{_content}->{$_} eq '');
+  }
+
   $self->required_fields(qw(
     type
     action