diff options
| -rw-r--r-- | FS/FS/Conf.pm | 11 | ||||
| -rw-r--r-- | FS/FS/pay_batch/RBC.pm | 130 | ||||
| -rwxr-xr-x | httemplate/search/cust_pay_batch.cgi | 8 | 
3 files changed, 145 insertions, 4 deletions
| diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 5afa142e2..3df23263d 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2392,7 +2392,7 @@ worry that config_items is freeside-specific and icky.      'type'        => 'select',      'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch',                         'csv-chase_canada-E-xactBatch', 'BoM', 'PAP', -                       'paymentech', 'ach-spiritone', +                       'paymentech', 'ach-spiritone', 'RBC'                      ]    }, @@ -2412,7 +2412,7 @@ worry that config_items is freeside-specific and icky.      'description' => 'Fixed (unchangeable) format for electronic check batches.',      'type'        => 'select',      'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP', -                       'paymentech', 'ach-spiritone', +                       'paymentech', 'ach-spiritone', 'RBC'                       ]    }, @@ -2452,6 +2452,13 @@ worry that config_items is freeside-specific and icky.    },    { +    'key'         => 'batchconfig-RBC', +    'section'     => 'billing', +    'description' => 'Configuration for Royal Bank of Canada PDS batching, four lines: 1. Client number, 2. Short name, 3. Long name, 4. Transaction code.', +    'type'        => 'textarea', +  }, + +  {      'key'         => 'payment_history-years',      'section'     => 'UI',      'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.', diff --git a/FS/FS/pay_batch/RBC.pm b/FS/FS/pay_batch/RBC.pm new file mode 100644 index 000000000..dc6095ccc --- /dev/null +++ b/FS/FS/pay_batch/RBC.pm @@ -0,0 +1,130 @@ +package FS::pay_batch::RBC; + +use strict; +use vars qw(@ISA %import_info %export_info $name); +use Date::Format 'time2str'; +use FS::Conf; + +my $conf; +my ($client_num, $shortname, $longname, $trans_code, $i); + +$name = 'RBC'; +# Royal Bank of Canada ACH Direct Payments Service + +%import_info = ( +  'filetype'    => 'fixed', +  'formatre'    =>  +  '^(.).{18}(.{4}).{15}(.{19}).{6}(.{30}).{17}(.{9})(.{18}).{6}(.{14}).{23}(.).{9}$', +  'fields' => [ qw( +    recordtype +    batchnum +    paybatchnum +    custname +    bank +    payinfo +    paid +    status +    ) ], +  'hook' => sub { +      my $hash = shift; +      $hash->{'paid'} = sprintf("%.df", $hash->{'paid'} / 100 ); +      $hash->{'_date'} = time; +      $hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'bank'}; +  }, +  'approved'    => sub {  +      my $hash = shift; +      $hash->{'status'} eq ' ' +  }, +  'declined'    => sub { +      my $hash = shift; +      grep { $hash->{'status'} eq $_ } ('E', 'R', 'U', 'T'); +  }, +  'end_hook'    => sub { +      my( $hash, $total, $line ) = @_; +      $total = sprintf("%.2f", $total); +      my $batch_total = sprintf("%.2f", substr($line, 140, 18) / 100); +      return "Our total $total does not match bank total $batch_total!" +        if $total != $batch_total; +      ''; +  }, +  'end_condition' => sub { +      my $hash = shift; +      $hash->{recordtype} == '3'; # Account Trailer Record +  }, +); + +%export_info = ( +  init => sub { +    $conf = shift; +    ($client_num, +     $shortname, +     $longname, +     $trans_code,  +     ) = $conf->config("batchconfig-RBC"); +    $i = 1; +  }, +  header => sub {  +    my $pay_batch = shift; +    '000001'. +    'A'. +    'HDR'. +    sprintf("%10s", $client_num). +    sprintf("%-30s", $longname). +    sprintf("%04u", $pay_batch->batchnum). +    time2str("%Y%j", $pay_batch->download). +    'CAD'. +    '1'. +    ' ' x 87  # filler/reserved fields +    ; +  }, +  row => sub { +    my ($cust_pay_batch, $pay_batch) = @_; +    my ($account, $aba) = split('@', $cust_pay_batch->payinfo); +    $i++; +    sprintf("%06u", $i). +    'D'. +    sprintf("%3s",$trans_code). +    sprintf("%10s",$client_num). +    ' '. +    sprintf("%-19s", $cust_pay_batch->paybatchnum). +    '00'. +    sprintf("%09u", $aba). +    sprintf("%-18s", $account). +    ' '. +    sprintf("%010u",$cust_pay_batch->amount*100). +    '      '. +    time2str("%Y%j", $pay_batch->download). +    sprintf("%-30s", $cust_pay_batch->cust_main->first . ' ' . +                     $cust_pay_batch->cust_main->last). +    'E'. # English +    ' '. +    sprintf("%-15s", $shortname). +    'CAD'. +    ' '. +    'CAN'. +    '    '. +    'N' # no customer optional information follows +    ; +# Note: IAT Address Information and Remittance records are not  +# supported. This means you probably can't process payments  +# destined to U.S. bank accounts.  If you need this feature, contact  +# Freeside Internet Services. +  }, +  footer => sub { +    my ($pay_batch, $batchcount, $batchtotal) = @_; +    sprintf("%06u", $i + 1). +    'Z'. +    'TRL'. +    sprintf("%10s", $client_num). +    ' ' x 20 . +    sprintf("%06u", $batchcount). +    sprintf("%014u", $batchtotal*100). +    '00' . +    '000000' . # total number of customer information records +    ' ' x 84 +    ; +  }, +); + +1; + diff --git a/httemplate/search/cust_pay_batch.cgi b/httemplate/search/cust_pay_batch.cgi index 2056876b6..4a42fc344 100755 --- a/httemplate/search/cust_pay_batch.cgi +++ b/httemplate/search/cust_pay_batch.cgi @@ -147,7 +147,9 @@ if ( $pay_batch ) {                      qq!<OPTION VALUE="PAP">80 byte file for TD Canada Trust PAP Batch</OPTION>!.                      qq!<OPTION VALUE="BoM">Bank of Montreal ECA batch</OPTION>!.                      qq!<OPTION VALUE="ach-spiritone">Spiritone ACH batch</OPTION>!. -                    qq!<OPTION VALUE="paymentech">Chase Paymentech</OPTION>!. +                    qq!<OPTION VALUE="paymentech">Chase Paymentech XML</OPTION>!. +                    qq!<OPTION VALUE="paymentech_vt">Chase Paymentech Virtual Terminal</OPTION>!. +                    qq!<OPTION VALUE="RBC">Royal Bank of Canada PDS</OPTION>!.                      qq!</SELECT>!;      }      $html_init .= qq!<INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum"><INPUT TYPE="submit" VALUE="Download"></FORM><BR>!; @@ -172,7 +174,9 @@ if ( $pay_batch ) {                      qq!<OPTION VALUE="PAP">264 byte results for TD Canada Trust PAP Batch</OPTION>!.                      qq!<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION>!.                      qq!<OPTION VALUE="ach-spiritone">Spiritone ACH batch</OPTION>!. -                    qq!<OPTION VALUE="paymentech">Chase Paymentech</OPTION>!. +                    qq!<OPTION VALUE="paymentech">Chase Paymentech XML</OPTION>!. +                    qq!<OPTION VALUE="paymentech_vt">Chase Paymentech Virtual Terminal</OPTION>!. +                    qq!<OPTION VALUE="RBC">Royal Bank of Canada PDS</OPTION>!.                      qq!</SELECT><BR>!;      }      $html_init .= qq!<INPUT TYPE="hidden" NAME="batchnum" VALUE="$batchnum">!; | 
