From 22039cb3127c9683305bf999252474b01bcfca7f Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Tue, 30 Nov 2004 13:29:24 +0000 Subject: [PATCH] Adding some errorhandling to the commerce system. --- lib/WebGUI/Operation/Commerce.pm | 57 +++++++++++++++++++---------- lib/WebGUI/i18n/English/Commerce.pm | 10 +++++ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index 9b32e1720..a7cff3f89 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -224,7 +224,7 @@ sub www_confirmTransaction { #------------------------------------------------------------------- sub www_editCommerceSettings { - my (%tabs, $tabform, $jscript, $currentPlugin, $ac, $jscript, $i18n, $paymentPlugin); + my (%tabs, $tabform, $jscript, $currentPlugin, $ac, $jscript, $i18n, $paymentPlugin, @paymentPlugins, %paymentPlugins, @failedPaymentPlugins, $plugin); return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); $i18n = WebGUI::International->new('Commerce'); @@ -265,27 +265,46 @@ sub www_editCommerceSettings { -value => $session{setting}{commerceSendDailyReportTo} ); - # payment plugin - $tabform->getTab('payment')->raw(''); - $tabform->getTab("payment")->selectList( - -name => 'commercePaymentPlugin', - -options => {map {$_ => $_} @{$session{config}{paymentPlugins}}}, - -label => $i18n->get('payment form'), - -value => [$paymentPlugin], - -extras => 'onChange="activePayment=operateHidden(this.options[this.selectedIndex].value,activePayment)"' - ); - - $jscript = ''); + $tabform->getTab("payment")->selectList( + -name => 'commercePaymentPlugin', + -options => \%paymentPlugins, #{map {$_ => $_} @{$session{config}{paymentPlugins}}}, + -label => $i18n->get('payment form'), + -value => [$paymentPlugin], + -extras => 'onChange="activePayment=operateHidden(this.options[this.selectedIndex].value,activePayment)"' + ); + + $jscript = ''; + $tabform->getTab('payment')->raw($jscript); + } else { + $tabform->getTab('payment')->raw(''.$i18n->get('no payment plugins selected').''); + } + + if (@failedPaymentPlugins) { + $tabform->getTab('payment')->raw('
'.$i18n->get('failed payment plugins'). + '
'); } - $jscript .= ''; - $tabform->getTab('payment')->raw($jscript); $tabform->submit; WebGUI::Style::setScript($session{config}{extrasURL}.'/swapLayers.js',{language=>"Javascript"}); diff --git a/lib/WebGUI/i18n/English/Commerce.pm b/lib/WebGUI/i18n/English/Commerce.pm index 9f27aaca3..cf2fb321b 100755 --- a/lib/WebGUI/i18n/English/Commerce.pm +++ b/lib/WebGUI/i18n/English/Commerce.pm @@ -355,6 +355,16 @@ A template loop containing the items that were checked out. The following templa lastUpdated => 1101791348, context => q|The title of the help page of the checkout error template.| }, + 'no payment plugins selected' => { + message => q|There are no payment plugins to select. Please enable plugins in the config file.|, + lastUpdated => 0, + context => q|The message that's shown in the AdminConsole/Commerce menu when there are no payment plugins enabled.| + }, + 'failed payment plugins' => { + message => q|The following Payment Plugins failed to compile, please check your log for more information: |, + lastUpdated => 0, + context => q|The message that sais which payment plugins did not compile.| + }, }; 1;