X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch.pm;h=f41b3e38b21da552de74139c5a6cd3146631902b;hb=771e64b732c69902be5552d53d4a7a1199d5fca3;hp=3a069149f8a0342a6eab16187abc4b413d425c90;hpb=91dbe4c3834f38d428367d9a1e2c6cf9ea9d84a4;p=freeside.git diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 3a069149f..f41b3e38b 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -1,21 +1,19 @@ package FS::pay_batch; +use base qw( FS::Record ); use strict; -use vars qw( @ISA $DEBUG %import_info %export_info $conf ); +use vars qw( $DEBUG %import_info %export_info $conf ); +use Scalar::Util qw(blessed); +use IO::Scalar; +use List::Util qw(sum); use Time::Local; use Text::CSV_XS; -use FS::Record qw( dbh qsearch qsearchs ); -use FS::Conf; -use FS::cust_pay; -use FS::agent; use Date::Parse qw(str2time); use Business::CreditCard qw(cardtype); -use Scalar::Util 'blessed'; -use IO::Scalar; use FS::Misc qw(send_email); # for error notification -use List::Util qw(sum); - -@ISA = qw(FS::Record); +use FS::Record qw( dbh qsearch qsearchs ); +use FS::Conf; +use FS::cust_pay; =head1 NAME @@ -147,22 +145,10 @@ sub check { Returns the L<FS::agent> object for this batch. -=cut - -sub agent { - qsearchs('agent', { 'agentnum' => $_[0]->agentnum }); -} - =item cust_pay_batch Returns all L<FS::cust_pay_batch> objects for this batch. -=cut - -sub cust_pay_batch { - qsearch('cust_pay_batch', { 'batchnum' => $_[0]->batchnum }); -} - =item rebalance =cut @@ -234,6 +220,36 @@ I<format> - an L<FS::pay_batch> module I<gateway> - an L<FS::payment_gateway> object for a batch gateway. This takes precedence over I<format>. +Supported format keys (defined in the specified FS::pay_batch module) are: + +I<filetype> - CSV, fixed, variable, XML + +I<fields> - list of field names for each row/line + +I<formatre> - regular expression for fixed filetype + +I<parse> - for variable filetype + +I<xmlkeys> - for XML filetype + +I<xmlrow> - for XML filetype + +I<begin_condition> - sub, ignore all lines before this returns true + +I<end_condition> - sub, stop processing lines when this returns true + +I<end_hook> - sub, runs immediately after end_condition returns true + +I<skip_condition> - sub, skip lines when this returns true + +I<hook> - sub, runs before approved/declined conditions are checked + +I<approved> - sub, returns true when approved + +I<declined> - sub, returns true when declined + +I<close_condition> - sub, decide whether or not to close the batch + =cut sub import_results { @@ -450,12 +466,10 @@ sub import_results { } -use MIME::Base64; -use Storable 'thaw'; use Data::Dumper; sub process_import_results { my $job = shift; - my $param = thaw(decode_base64(shift)); + my $param = shift; $param->{'job'} = $job; warn Dumper($param) if $DEBUG; my $gatewaynum = delete $param->{'gatewaynum'}; @@ -735,7 +749,8 @@ sub import_from_gateway { $total += $cust_pay_batch->paid; } else { - $error = $cust_pay_batch->decline($item->error_message); + $error = $cust_pay_batch->decline($item->error_message, + $item->failure_status); } if ( $error ) { @@ -764,7 +779,7 @@ sub import_from_gateway { my $body = "Import from gateway ".$gateway->label."\n".$error_text; send_email( to => $mail_on_error, - from => $conf->config('invoice_from'), + from => $conf->invoice_from_full(), subject => $subject, body => $body, );