diff options
Diffstat (limited to 'FS/bin')
-rwxr-xr-x | FS/bin/freeside-paymentech-upload | 17 | ||||
-rwxr-xr-x | FS/bin/freeside-upgrade | 7 | ||||
-rwxr-xr-x | FS/bin/freeside-void-payments | 49 |
3 files changed, 33 insertions, 40 deletions
diff --git a/FS/bin/freeside-paymentech-upload b/FS/bin/freeside-paymentech-upload index 06bef68be..3f8abc047 100755 --- a/FS/bin/freeside-paymentech-upload +++ b/FS/bin/freeside-paymentech-upload @@ -12,15 +12,15 @@ use FS::pay_batch; use FS::cust_pay_batch; use FS::Conf; -use vars qw( $opt_a $opt_t $opt_v ); -getopts('avt'); +use vars qw( $opt_a $opt_t $opt_v $opt_p ); +getopts('avtp:'); #$Net::SFTP::Foreign::debug = -1; sub usage { " Usage: freeside-paymentech-upload [ -v ] [ -t ] user batchnum - freeside-paymentech-upload -a [ -v ] [ -t ] user\n + freeside-paymentech-upload -a [ -p payby ] [ -v ] [ -t ] user\n " } my $user = shift or die &usage; @@ -31,8 +31,11 @@ my $zip_check = `which zip` or die "can't find zip executable\n"; my @batches; if($opt_a) { - @batches = qsearch('pay_batch', { status => 'O' } ); - die "No open batches found.\n" if !@batches; + my %criteria = (status => 'O'); + $criteria{'payby'} = uc($opt_p) if $opt_p; + @batches = qsearch('pay_batch', \%criteria); + die "No open batches found".($opt_p ? " of type '$opt_p'" : '').".\n" + if !@batches; } else { my $batchnum = shift; @@ -95,7 +98,7 @@ freeside-paymentech-upload - Transmit a payment batch to Chase Paymentech via SF =head1 SYNOPSIS - freeside-paymentech-upload [ -a ] [ -v ] [ -t ] user batchnum + freeside-paymentech-upload [ -a [ -p PAYBY ] ] [ -v ] [ -t ] user batchnum =head1 DESCRIPTION @@ -106,6 +109,8 @@ response file. -a: Send all open batches, instead of specifying a batchnum. +-p PAYBY: With -a, limit to batches of that payment type, e.g. -p CARD. + -v: Be verbose. -t: Send the transaction to the test server. diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index 97c704c91..f4ff1c28e 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -4,7 +4,7 @@ use strict; use vars qw($opt_d $opt_s $opt_q $opt_v $opt_r); use vars qw($DEBUG $DRY_RUN); use Getopt::Std; -use DBIx::DBSchema 0.31; +use DBIx::DBSchema 0.31; #0.39 use FS::UID qw(adminsuidsetup checkeuid datasrc driver_name); #getsecrets); use FS::CurrentUser; use FS::Schema qw( dbdef dbdef_dist reload_dbdef ); @@ -30,6 +30,11 @@ $FS::UID::callback_hack = 1; my $dbh = adminsuidsetup($user); $FS::UID::callback_hack = 0; +if ( driver_name =~ /^mysql/i ) { #until 0.39 is required above + eval "use DBIx::DBSchema 0.39;"; + die $@ if $@; +} + #needs to match FS::Schema... my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc; diff --git a/FS/bin/freeside-void-payments b/FS/bin/freeside-void-payments index 8c1f3dbdf..412033ccc 100755 --- a/FS/bin/freeside-void-payments +++ b/FS/bin/freeside-void-payments @@ -34,8 +34,9 @@ elsif($opt{'a'}) { or die "Agent has no payment gateway for method '$method'."; } -if(defined($opt{'X'}) and !qsearchs('reason', { reasonnum => opt{'X'} })) { - die "Cancellation reason not found: '".$opt{'X'}."'"; +if(defined($opt{'X'})) { + die "Cancellation reason not found: '".$opt{'X'}."'" + if(! qsearchs('reason', { reasonnum => $opt{'X'} } ) ); } my ($processor, $login, $password, $action, @bop_options) = @@ -132,21 +133,7 @@ if($opt{'v'}) { } sub usage { - die "Usage:\n\n freeside-void-payments [ options ] user - - options: - -a agentnum use agentnum's gateway information - -g gatewaynum use gatewaynum - -f file read transaction numbers from file - -c use ECHECK gateway instead of CARD - -r reason specify void reason (as a string) - -v be verbose - -s start-date - -e end-date limit by payment return date - -X reasonnum cancel customers whose payments are voided - (specify cancellation reason number) - -"; + die "Usage:\n\n freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] [ -v ] [ -n ] [-X reasonnum ] user\n"; } __END__ @@ -159,17 +146,10 @@ freeside-void-payments - Automatically void a list of returned payments. =head1 SYNOPSIS - freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] - [ -r 'reason' ] - [ -g gatewaynum | -a agentnum ] - [ -c ] [ -v ] - [ -X reasonnum ] - user + freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] [ -v ] [ -n ] user =head1 DESCRIPTION -=pod - Voids payments that were returned by the payment processor. Can be run periodically from crontab or manually after receiving a list of returned payments. Normally this is a meaningful operation only for @@ -182,12 +162,12 @@ generally how the processor will identify them later. -f: Read the list of authorization numbers from the specified file. If they are not from the default payment gateway, -g or -a must be given to identify the gateway. - + If -f is not given, the script will attempt to contact the gateway and download a list of returned transactions. To support this, the Business::OnlinePayment module for the processor must implement - the get_returns() method. For an example, see - Business::OnlinePayment::WesternACH. + the I<get_returns()> method. For an example, see + L<Business::OnlinePayment::WesternACH>. -s, -e: Specify the starting and ending dates for the void list. This has no effect if -f is given. The end date defaults to @@ -195,7 +175,7 @@ generally how the processor will identify them later. -r: The reason for voiding the payments, to be stored in the database. - -g: The FS::payment_gateway number for the gateway that handled + -g: The L<FS::payment_gateway> number for the gateway that handled these payments. If -f is not given, this determines which gateway will be contacted. This overrides -a. @@ -207,9 +187,12 @@ generally how the processor will identify them later. -v: Be verbose. - -X: Automatically cancel all packages belonging to customers whose - payments were returned. Requires a cancellation reasonnum - (from FS::reason). + -X: Automatically cancel all packages belonging to customers whose payments + were returned. Requires a cancellation reasonnum (from L<FS::reason>). + +A warning will be emitted for each transaction that can't be found. +This may happen if it's already been voided, or if the gateway +doesn't match. =head1 EXAMPLE @@ -230,7 +213,7 @@ day at 8:30 every morning: =head1 BUGS -Most payment gateways don't support it. +Most payment gateways don't support it, making the script largely useless. =head1 SEE ALSO |