X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-paymentech-download;h=16ac3c23b66c27c59b7e51bd58663aa78112f6e5;hp=48dfe9b4b7127497412d76874028091d9cf1fc2c;hb=15a4e1674694b76ecc2af87de479aabe370ac03d;hpb=2b2f85d3b20ea18fe432e18f26bfe3feb07088f1 diff --git a/FS/bin/freeside-paymentech-download b/FS/bin/freeside-paymentech-download index 48dfe9b4b..16ac3c23b 100755 --- a/FS/bin/freeside-paymentech-download +++ b/FS/bin/freeside-paymentech-download @@ -2,26 +2,24 @@ use strict; use Getopt::Std; +use Date::Format qw(time2str); +use File::Temp qw(tempdir); #0.19 for ->newdir() interface, not in 5.10.0 use Net::SFTP::Foreign; +use Expect; use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); use FS::pay_batch; use FS::cust_pay_batch; use FS::Conf; -use Date::Format 'time2str'; -use File::Temp; - use vars qw( $opt_t $opt_v $opt_a ); getopts('vta:'); #$Net::SFTP::Foreign::debug = -1; -sub usage { ' +sub usage { " Usage: - paymentech-download [ -v ] [ -t ] [ -a archivedir ] user - -' -} + freeside-paymentech-download [ -v ] [ -t ] [ -a archivedir ] user\n +" } my $user = shift or die &usage; adminsuidsetup $user; @@ -33,7 +31,10 @@ if ( $opt_a ) { unless -w $opt_a; } -my $tmpdir = File::Temp->newdir(); +my $unzip_check = `which unzip` or die "can't find unzip executable\n"; + +#my $tmpdir = File::Temp->newdir(); +my $tmpdir = tempdir( CLEANUP => 1 ); #DIR=>somewhere? my $conf = new FS::Conf; my @batchconf = $conf->config('batchconfig-paymentech'); @@ -41,7 +42,8 @@ my @batchconf = $conf->config('batchconfig-paymentech'); my $username = $batchconf[3] or die "no Paymentech batch username configured\n"; my $password = $batchconf[4] or die "no Paymentech batch password configured\n"; -my $host = ($opt_t ? 'orbitalbatchvar.paymentech.net' : 'orbitalbatch.paymentech.net'); +my $host = ($opt_t ? 'orbitalbatchvar.paymentech.net' + : 'orbitalbatch.paymentech.net'); print STDERR "Connecting to $username\@$host...\n" if $opt_v; my $sftp = Net::SFTP::Foreign->new( host => $host, @@ -66,9 +68,10 @@ BATCH: foreach my $filename (@files) { } #unzip file - system("unzip -P $password -q $tmpdir/${filename}_resp.zip -d $tmpdir"); + system('unzip', '-P', $password, '-q', + "$tmpdir/${filename}_resp.zip", '-d', $tmpdir); if(! -f "$tmpdir/${filename}_resp.xml") { - warn "failed to extract ${filename}_resp.xml\n"; + warn "failed to extract ${filename}_resp.xml from ${filename}_resp.zip\n"; next BATCH; } @@ -102,9 +105,7 @@ print STDERR "Finished!\n" if $opt_v; =head1 NAME -paymentech-download - -paymentech-download - Retrieve payment batch responses from Chase Paymentech. +freeside-paymentech-download - Retrieve payment batch responses from Chase Paymentech. =head1 SYNOPSIS