diff options
author | ivan <ivan> | 2011-10-21 23:08:15 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-10-21 23:08:15 +0000 |
commit | 80e675c7305768010f8b08ef2ebdfb936432e84d (patch) | |
tree | b4abb8da1f85844ad03f7c4430768d69048ea17e /FS/bin/freeside-eftca-upload | |
parent | 9111b460e3bc7613294cf5da0aaad3a4b11d8dc0 (diff) |
agent-virt batches and batchconfig-eftcanada config (argh!), RT#14859
Diffstat (limited to 'FS/bin/freeside-eftca-upload')
-rwxr-xr-x | FS/bin/freeside-eftca-upload | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/FS/bin/freeside-eftca-upload b/FS/bin/freeside-eftca-upload index b50115365..45a358b23 100755 --- a/FS/bin/freeside-eftca-upload +++ b/FS/bin/freeside-eftca-upload @@ -38,15 +38,11 @@ else { } my $conf = new FS::Conf; -my @batchconf = $conf->config('batchconfig-eft_canada'); -my $username = $batchconf[0] or die "no EFT Canada batch username configured\n"; -my $password = $batchconf[1] or die "no EFT Canada batch password configured\n"; my $tmpdir = tempdir( CLEANUP => 1 ); #DIR=>somewhere? -my @filenames; - foreach my $pay_batch (@batches) { + my $batchnum = $pay_batch->batchnum; my $filename = time2str('%Y%m%d', time) . '-' . sprintf('%06d.csv',$batchnum); print STDERR "Exporting batch $batchnum to $filename...\n" if $opt_v; @@ -54,27 +50,27 @@ foreach my $pay_batch (@batches) { open OUT, ">$tmpdir/$filename"; print OUT $text; close OUT; - push @filenames, $filename; -} -my $host = 'ftp.eftcanada.com'; -print STDERR "Connecting to $username\@$host...\n" if $opt_v; + my @batchconf = $conf->config('batchconfig-eft_canada', $pay_batch->agentnum); + my $user = $batchconf[0] or die "no EFT Canada batch username configured\n"; + my $pass = $batchconf[1] or die "no EFT Canada batch password configured\n"; + + my $host = 'ftp.eftcanada.com'; + print STDERR "Connecting to $user\@$host...\n" if $opt_v; -my $sftp = Net::SFTP::Foreign->new( host => $host, - user => $username, - password => $password, - timeout => 30, + my $sftp = Net::SFTP::Foreign->new( host => $host, + user => $user, + password => $pass, + timeout => 30, ); -die "failed to connect to '$username\@$host'\n(".$sftp->error.")\n" - if $sftp->error; + die "failed to connect to '$user\@$host'\n(".$sftp->error.")\n" + if $sftp->error; -foreach my $filename (@filenames) { $sftp->put("$tmpdir/$filename", "$filename") or die "failed to upload file (".$sftp->error.")\n"; -} -$FS::UID::AutoCommit = 0; -foreach my $pay_batch (@batches) { + undef $sftp; #$sftp->disconnect; + # Auto-approve and close the batch. Some false laziness with manual_approve. my $batchnum = $pay_batch->batchnum; my $error; @@ -86,7 +82,6 @@ foreach my $pay_batch (@batches) { $error ||= $pay_batch->set_status('R'); die "error closing batch $batchnum: $error\n\n" if $error; } -dbh->commit; print STDERR "Finished!\n" if $opt_v; |