input and output on data volume fields specified with k,m,g,or t
[freeside.git] / FS / FS / cust_main.pm
index 80111da..1224c88 100644 (file)
@@ -2,7 +2,7 @@ package FS::cust_main;
 
 use strict;
 use vars qw( @ISA @EXPORT_OK $DEBUG $me $conf @encrypted_fields
-             $import $skip_fuzzyfiles $ignore_expired_card );
+             $import $skip_fuzzyfiles $ignore_expired_card @paytypes);
 use vars qw( $realtime_bop_decline_quiet ); #ugh
 use Safe;
 use Carp;
@@ -70,6 +70,7 @@ $skip_fuzzyfiles = 0;
 $ignore_expired_card = 0;
 
 @encrypted_fields = ('payinfo', 'paycvv');
+@paytypes = ('', 'Personal checking', 'Personal savings', 'Business checking', 'Business savings');
 
 #ask FS::UID to run this stuff for us later
 #$FS::UID::callback{'FS::cust_main'} = sub { 
@@ -1221,6 +1222,7 @@ sub check {
     || $self->ut_numbern('referral_custnum')
     || $self->ut_textn('stateid')
     || $self->ut_textn('stateid_state')
+    || $self->ut_textn('invoice_terms')
   ;
   #barf.  need message catalogs.  i18n.  etc.
   $error .= "Please select an advertising source."
@@ -1335,6 +1337,7 @@ sub check {
   $error =    $self->ut_numbern('paystart_month')
            || $self->ut_numbern('paystart_year')
            || $self->ut_numbern('payissue')
+           || $self->ut_textn('paytype')
   ;
   return $error if $error;
 
@@ -2609,9 +2612,12 @@ sub realtime_bop {
     ( $content{account_number}, $content{routing_code} ) =
       split('@', $payinfo);
     $content{bank_name} = $o_payname;
-    $content{account_type} = 'CHECKING';
+    $content{bank_state} = $self->getfield('paystate');
+    $content{account_type} = uc($self->getfield('paytype')) || 'CHECKING';
     $content{account_name} = $payname;
     $content{customer_org} = $self->company ? 'B' : 'I';
+    $content{state_id}       = $self->getfield('stateid');
+    $content{state_id_state} = $self->getfield('stateid_state');
     $content{customer_ssn} = exists($options{'ss'})
                                ? $options{'ss'}
                                : $self->ss;
@@ -2773,15 +2779,7 @@ sub realtime_bop {
     unless ( $transaction->error_message ) {
 
       my $t_response;
-      #this should be normalized :/
-      #
-      # bad, ad-hoc B:OP:PayflowPro "transaction_response" BS
-      if ( $transaction->can('param')
-           && $transaction->param('transaction_response') ) {
-        $t_response = $transaction->param('transaction_response')
-
-      # slightly better, ad-hoc B:OP:TransactionCentral without "param"
-      } elsif ( $transaction->can('response_page') ) {
+      if ( $transaction->can('response_page') ) {
         $t_response = {
                         'page'    => ( $transaction->can('response_page')
                                          ? $transaction->response_page