summaryrefslogtreecommitdiff
path: root/FS/FS/payment_gateway.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-12-03 10:36:03 -0600
committerJonathan Prykop <jonathan@freeside.biz>2016-12-03 10:36:03 -0600
commit9a8399783bb9d87ef662b4371bebe983d2781dce (patch)
treefd4e2fb4c1348b1d532f17d44884b5ed35752473 /FS/FS/payment_gateway.pm
parent0ed150d5dd7027513942b74eb362460bc7c2e884 (diff)
71513: Card tokenization [refund gateway choice]
Diffstat (limited to 'FS/FS/payment_gateway.pm')
-rw-r--r--FS/FS/payment_gateway.pm25
1 files changed, 18 insertions, 7 deletions
diff --git a/FS/FS/payment_gateway.pm b/FS/FS/payment_gateway.pm
index 170d37a..3500bf9 100644
--- a/FS/FS/payment_gateway.pm
+++ b/FS/FS/payment_gateway.pm
@@ -385,6 +385,23 @@ sub default_gateway {
return $payment_gateway;
}
+=item by_key_with_namespace GATEWAYNUM
+
+Like usual by_key, but makes sure namespace is set,
+and dies if not found.
+
+=cut
+
+sub by_key_with_namespace {
+ my $self = shift;
+ my $payment_gateway = $self->by_key(@_);
+ die "payment_gateway not found"
+ unless $payment_gateway;
+ $payment_gateway->gateway_namespace('Business::OnlinePayment')
+ unless $payment_gateway->gateway_namespace;
+ return $payment_gateway;
+}
+
=item by_key_or_default OPTIONS
Either returns the gateway specified by option gatewaynum, or the default gateway.
@@ -399,13 +416,7 @@ sub by_key_or_default {
my ($self,%options) = @_;
if ($options{'gatewaynum'}) {
- my $payment_gateway = $self->by_key($options{'gatewaynum'});
- # regardless of nofatal, which is only meant for handling lack of default gateway
- die "payment_gateway ".$options{'gatewaynum'}." not found"
- unless $payment_gateway;
- $payment_gateway->gateway_namespace('Business::OnlinePayment')
- unless $payment_gateway->gateway_namespace;
- return $payment_gateway;
+ return $self->by_key_with_namespace($options{'gatewaynum'});
} else {
return $self->default_gateway(%options);
}