[freeside-commits] freeside/FS/FS payment_gateway.pm,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Sat Mar 1 17:31:41 PST 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv16361/FS/FS
Modified Files:
payment_gateway.pm
Log Message:
add payment gateway disabling (and move payment gateway browse over to new template)
Index: payment_gateway.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/payment_gateway.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- payment_gateway.pm 17 Aug 2005 22:23:45 -0000 1.1
+++ payment_gateway.pm 2 Mar 2008 01:31:38 -0000 1.2
@@ -2,8 +2,9 @@
use strict;
use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
use FS::option_Common;
+use FS::agent_payment_gateway;
@ISA = qw( FS::option_Common );
@@ -133,6 +134,58 @@
$self->SUPER::check;
}
+=item agent_payment_gateway
+
+Returns any agent overrides for this payment gateway.
+
+=cut
+
+sub agent_payment_gateway {
+ my $self = shift;
+ qsearch('agent_payment_gateway', { 'gatewaynum' => $self->gatewaynum } );
+}
+
+=item disable
+
+Disables this payment gateway: deletes all associated agent_payment_gateway
+overrides and sets the I<disabled> field to "B<Y>".
+
+=cut
+
+sub disable {
+ my $self = shift;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ foreach my $agent_payment_gateway ( $self->agent_payment_gateway ) {
+ my $error = $agent_payment_gateway->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "error deleting agent_payment_gateway override: $error";
+ }
+ }
+
+ $self->disabled('Y');
+ my $error = $self->replace();
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "error disabling payment_gateway: $error";
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
+}
+
=back
=head1 BUGS
More information about the freeside-commits
mailing list