summaryrefslogtreecommitdiff
path: root/FS/FS/payment_gateway.pm
diff options
context:
space:
mode:
authorivan <ivan>2008-03-02 01:31:39 +0000
committerivan <ivan>2008-03-02 01:31:39 +0000
commit53547a802d5c76be967cc14301fc8a692f0fe066 (patch)
tree54f1d62bf4b0e1cde08249798339358437fa9693 /FS/FS/payment_gateway.pm
parentc21f9fadde9100aedb8c4cfc35629bc3294ba91e (diff)
add payment gateway disabling (and move payment gateway browse over to new template)
Diffstat (limited to 'FS/FS/payment_gateway.pm')
-rw-r--r--FS/FS/payment_gateway.pm55
1 files changed, 54 insertions, 1 deletions
diff --git a/FS/FS/payment_gateway.pm b/FS/FS/payment_gateway.pm
index a5cdd9d..35b4f08 100644
--- a/FS/FS/payment_gateway.pm
+++ b/FS/FS/payment_gateway.pm
@@ -2,8 +2,9 @@ package FS::payment_gateway;
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 @@ sub check {
$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