summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2006-11-14 02:54:07 +0000
committerivan <ivan>2006-11-14 02:54:07 +0000
commit085d6dcbe3a137d8d8ad0b04b6d9c0af1516ee5e (patch)
treef353aa6c1c3e5e9e2a37d9dff370c20a44e945b5 /FS/FS
parent3758ad3cb13752bbbebb2c42fcc398bdb1ffdc6a (diff)
add card-types configuration value for self-service
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm73
-rw-r--r--FS/FS/Conf.pm36
2 files changed, 76 insertions, 33 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
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index edb1ca3..bf853bc 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1,6 +1,6 @@
package FS::Conf;
-use vars qw($default_dir @config_items $DEBUG );
+use vars qw($default_dir @config_items @card_types $DEBUG );
use IO::File;
use File::Basename;
use FS::ConfItem;
@@ -284,6 +284,20 @@ httemplate/docs/config.html
=cut
+#Business::CreditCard
+@card_types = (
+ "VISA card",
+ "MasterCard",
+ "Discover card",
+ "American Express card",
+ "Diner's Club/Carte Blanche",
+ "enRoute",
+ "JCB",
+ "BankCard",
+ "Switch",
+ "Solo",
+);
+
@config_items = map { new FS::ConfItem $_ } (
{
@@ -1476,15 +1490,7 @@ httemplate/docs/config.html
'section' => 'billing',
'description' => 'Save CVV2 information after the initial transaction for the selected credit card types. Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option for any credit card types.',
'type' => 'selectmultiple',
- 'select_enum' => [ "VISA card",
- "MasterCard",
- "Discover card",
- "American Express card",
- "Diner's Club/Carte Blanche",
- "enRoute",
- "JCB",
- "BankCard",
- ],
+ 'select_enum' => \@card_types,
},
{
@@ -1909,10 +1915,18 @@ httemplate/docs/config.html
{
'key' => 'support-key',
'section' => '',
- 'description' => 'A support key enables access to commercial services accessed over the network, such as access to the internal ticket system, priority support and optional backups.',
+ 'description' => 'A support key enables access to commercial services delivered over the network, such as the payroll module, access to the internal ticket system, priority support and optional backups.',
'type' => 'text',
},
+ {
+ 'key' => 'card-types',
+ 'section' => 'billing',
+ 'description' => 'Select one or more card types to enable only those card types. If no card types are selected, all card types are available.',
+ 'type' => 'selectmultiple',
+ 'select_enum' => \@card_types,
+ },
+
);
1;