From a3deab8366fdd1cdc702007d9bb3e9fdace52d67 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 13 Jul 2012 10:59:53 -0700 Subject: [PATCH] initial commit --- .gitignore | 6 +++ Changes | 4 ++ KeyBank.pm | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MANIFEST | 8 ++++ Makefile.PL | 20 ++++++++++ README | 45 +++++++++++++++++++++++ ignore.txt | 12 ++++++ t/00-load.t | 9 +++++ t/manifest.t | 13 +++++++ t/pod.t | 12 ++++++ 10 files changed, 247 insertions(+) create mode 100644 .gitignore create mode 100644 Changes create mode 100644 KeyBank.pm create mode 100644 MANIFEST create mode 100644 Makefile.PL create mode 100644 README create mode 100644 ignore.txt create mode 100644 t/00-load.t create mode 100644 t/manifest.t create mode 100644 t/pod.t diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9788afa --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +blib/ +*.sw? +Makefile +Makefile.old +MYMETA.yml +pm_to_blib diff --git a/Changes b/Changes new file mode 100644 index 0000000..b7ed855 --- /dev/null +++ b/Changes @@ -0,0 +1,4 @@ +Revision history for Business-BatchPayment-KeyBank + +0.01 unreleased + diff --git a/KeyBank.pm b/KeyBank.pm new file mode 100644 index 0000000..6c5eafd --- /dev/null +++ b/KeyBank.pm @@ -0,0 +1,118 @@ +package Business::BatchPayment::KeyBank; + +use 5.006; +use strict; +use warnings; +our $VERSION = '0.01'; + +=head1 NAME + +Business::BatchPayment::KeyBank - Key Bank check lockbox format + +=head1 VERSION + +Version 0.01 + +=head1 USAGE + +See L for general usage notes. This is a +one-way, non-transport processor; you must supply the file to be +received. + +=head2 SYNOPSIS + +use Business::BatchPayment; + +my $processor = Business::BatchPayment->create( KeyBank => + input => 'mybatch.csv'); + +my @items = $processor->receive; + +=head2 PROCESSOR ATTRIBUTES + +None. + +=cut + +use DateTime; +use Text::CSV_XS; +use Digest::MD5 qw( md5_hex ); + +use Moose; +with 'Business::BatchPayment::Processor'; + +sub incoming { 1 } +sub format_item { '' } + +has '_csv' => ( + is => 'ro', + default => sub { Text::CSV_XS->new() }, +); + +sub parse_batch_id { + my ($self, $content) = @_; + # we just need it to be unique... + return md5_hex($content); +} + +sub parse_item { + my ($self, $row) = @_; + $self->_csv->parse($row); + if ( !$self->_csv->status ) { + die $self->_csv->error_diag . "\n"; + } + my @f = $self->_csv->fields; + foreach (@f) { + s/^\s+//; + s/\s+$//; + } + # INVOICEID, ACCOUNT_NUMBER, POSTDATE, AMOUNT, CHECK_NUMBER + # date in YYYYMMDD format + $f[2] =~ /^(\d{4})(\d{2})(\d{2})$/ or die "bad process date '$f[2]'\n"; + my $dt = eval { DateTime->new( year => $1, month => $2, day => $3 ) } + or die "bad process date '$f[2]'\n"; + + my $amount = $f[3] / 100; + Business::BatchPayment->create(Item => + action => 'payment', + payment_type => 'ECHECK', + invoice_number => $f[0], + customer_id => $f[1], + payment_date => $dt, + amount => $amount, + check_number => $f[3], + order_number => $f[3], #? + approved => 1, + ); +} + +__PACKAGE__->meta->make_immutable; + +=head1 AUTHOR + +Mark Wells, + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc Business::BatchPayment::KeyBank + +Commercial support is available from Freeside Internet Services, Inc. + +L + +=head1 LICENSE AND COPYRIGHT + +Copyright 2012 Mark Wells. + +This program is free software; you can redistribute it and/or modify it +under the terms of either: the GNU General Public License as published +by the Free Software Foundation; or the Artistic License. + +See http://dev.perl.org/licenses/ for more information. + + +=cut + +1; diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..43891a7 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,8 @@ +Changes +KeyBank.pm +Makefile.PL +MANIFEST This list of files +README +t/00-load.t +t/manifest.t +t/pod.t diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..8c3a103 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,20 @@ +use 5.006; +use strict; +use warnings; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'Business::BatchPayment::KeyBank', + AUTHOR => q{Mark Wells }, + VERSION_FROM => 'KeyBank.pm', + ABSTRACT_FROM => 'KeyBank.pm', + ($ExtUtils::MakeMaker::VERSION >= 6.3002 + ? ('LICENSE'=> 'perl') + : ()), + PL_FILES => {}, + PREREQ_PM => { + 'Test::More' => 0, + }, + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + clean => { FILES => 'Business-BatchPayment-KeyBank-*' }, +); diff --git a/README b/README new file mode 100644 index 0000000..3f2c81e --- /dev/null +++ b/README @@ -0,0 +1,45 @@ +Business-BatchPayment-KeyBank + +Business::BatchPayment interface for Key Bank check lockbox service. + +INSTALLATION + +To install this module, run the following commands: + + perl Makefile.PL + make + make test + make install + +SUPPORT AND DOCUMENTATION + +After installing, you can find documentation for this module with the +perldoc command. + + perldoc Business::BatchPayment::KeyBank + +You can also look for information at: + + RT, CPAN's request tracker (report bugs here) + http://rt.cpan.org/NoAuth/Bugs.html?Dist=Business-BatchPayment-KeyBank + + AnnoCPAN, Annotated CPAN documentation + http://annocpan.org/dist/Business-BatchPayment-KeyBank + + CPAN Ratings + http://cpanratings.perl.org/d/Business-BatchPayment-KeyBank + + Search CPAN + http://search.cpan.org/dist/Business-BatchPayment-KeyBank/ + + +LICENSE AND COPYRIGHT + +Copyright (C) 2012 Mark Wells + +This program is free software; you can redistribute it and/or modify it +under the terms of either: the GNU General Public License as published +by the Free Software Foundation; or the Artistic License. + +See http://dev.perl.org/licenses/ for more information. + diff --git a/ignore.txt b/ignore.txt new file mode 100644 index 0000000..976f448 --- /dev/null +++ b/ignore.txt @@ -0,0 +1,12 @@ +blib* +Makefile +Makefile.old +Build +Build.bat +_build* +pm_to_blib* +*.tar.gz +.lwpcookies +cover_db +pod2htm*.tmp +Business-BatchPayment-KeyBank-* diff --git a/t/00-load.t b/t/00-load.t new file mode 100644 index 0000000..2ef2f09 --- /dev/null +++ b/t/00-load.t @@ -0,0 +1,9 @@ +#!perl -T + +use Test::More tests => 1; + +BEGIN { + use_ok( 'Business::BatchPayment::KeyBank' ) || print "Bail out!\n"; +} + +diag( "Testing Business::BatchPayment::KeyBank $Business::BatchPayment::KeyBank::VERSION, Perl $], $^X" ); diff --git a/t/manifest.t b/t/manifest.t new file mode 100644 index 0000000..45eb83f --- /dev/null +++ b/t/manifest.t @@ -0,0 +1,13 @@ +#!perl -T + +use strict; +use warnings; +use Test::More; + +unless ( $ENV{RELEASE_TESTING} ) { + plan( skip_all => "Author tests not required for installation" ); +} + +eval "use Test::CheckManifest 0.9"; +plan skip_all => "Test::CheckManifest 0.9 required" if $@; +ok_manifest(); diff --git a/t/pod.t b/t/pod.t new file mode 100644 index 0000000..ee8b18a --- /dev/null +++ b/t/pod.t @@ -0,0 +1,12 @@ +#!perl -T + +use strict; +use warnings; +use Test::More; + +# Ensure a recent version of Test::Pod +my $min_tp = 1.22; +eval "use Test::Pod $min_tp"; +plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; + +all_pod_files_ok(); -- 2.11.0