diff options
author | ivan <ivan> | 2006-11-14 02:54:07 +0000 |
---|---|---|
committer | ivan <ivan> | 2006-11-14 02:54:07 +0000 |
commit | 085d6dcbe3a137d8d8ad0b04b6d9c0af1516ee5e (patch) | |
tree | f353aa6c1c3e5e9e2a37d9dff370c20a44e945b5 /FS/FS/ClientAPI | |
parent | 3758ad3cb13752bbbebb2c42fcc398bdb1ffdc6a (diff) |
add card-types configuration value for self-service
Diffstat (limited to 'FS/FS/ClientAPI')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 73 |
1 files changed, 51 insertions, 22 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index aa8ff9e..c0fb46b 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -204,33 +204,62 @@ sub payment_info { #generic ## - my $conf = new FS::Conf; - my %states = map { $_->state => 1 } - qsearch('cust_main_county', { - 'country' => $conf->config('countrydefault') || 'US' - } ); - use vars qw($payment_info); #cache for performance - $payment_info ||= { + unless ( $payment_info ) { + + my $conf = new FS::Conf; + my %states = map { $_->state => 1 } + qsearch('cust_main_county', { + 'country' => $conf->config('countrydefault') || 'US' + } ); + + my %card_types = ( + #displayname #value (Business::CreditCard) + "VISA" => "VISA card", + "MasterCard" => "MasterCard", + "Discover" => "Discover card", + "American Express" => "American Express card", + "Diner's Club/Carte Blanche" => "Diner's Club/Carte Blanche", + "enRoute" => "enRoute", + "JCB" => "JCB", + "BankCard" => "BankCard", + "Switch" => "Switch", + "Solo" => "Solo", + ); + my @conf_card_types = grep { ! /^\s*$/ } $conf->config('card-types'); + if ( @conf_card_types ) { + #perhaps the hash is backwards for this, but this way works better for + #usage in selfservice + %card_types = map { $_ => $card_types{$_} } + grep { + my $d = $_; + grep { $card_types{$d} eq $_ } @conf_card_types + } + keys %card_types; + } - #list all counties/states/countries - 'cust_main_county' => - [ map { $_->hashref } qsearch('cust_main_county', {}) ], + $payment_info = { - #shortcut for one-country folks - 'states' => - [ sort { $a cmp $b } keys %states ], + #list all counties/states/countries + 'cust_main_county' => + [ map { $_->hashref } qsearch('cust_main_county', {}) ], - 'card_types' => { - 'VISA' => 'VISA card', - 'MasterCard' => 'MasterCard', - 'Discover' => 'Discover card', - 'American Express' => 'American Express card', - 'Switch' => 'Switch', - 'Solo' => 'Solo', - }, + #shortcut for one-country folks + 'states' => + [ sort { $a cmp $b } keys %states ], - }; + 'card_types' => { + 'VISA' => 'VISA card', + 'MasterCard' => 'MasterCard', + 'Discover' => 'Discover card', + 'American Express' => 'American Express card', + 'Switch' => 'Switch', + 'Solo' => 'Solo', + }, + + }; + + } ## #customer-specific |