RT# 82010 Fix bug where selfservice payment form may not appear
[freeside.git] / fs_selfservice / FS-SelfService / cgi / change_pay.html
index f90f6d9..e4f412c 100644 (file)
@@ -39,8 +39,8 @@
                     );
 
   ## Don't show CHEK or DCHK option if ACH is read only
-  delete( $payby_index{'CHEK'} ) unless !$ach_read_only;
-  delete( $payby_index{'DCHK'} ) unless !$ach_read_only;
+  delete( $payby_index{'CHEK'} ) if ($ach_read_only && $payby ne "CHEK");
+  delete( $payby_index{'DCHK'} ) if ($ach_read_only && $payby ne "DCHK");
 
   tie my %options, 'Tie::IxHash', ();
   foreach my $payby_option ( grep { exists( $payby_index{$_} ) } @paybys ) {
@@ -60,8 +60,8 @@
   delete $options{'DCRD'} unless $payby eq 'DCRD' || ! exists $options{'CARD'};
   delete $options{'DCHK'} unless $payby eq 'DCHK' || ! exists $options{'CHEK'};
 
-  ## set default layer to first payby.
-  @p = keys %options; $payby = $p[0];
+  $payby = (keys %options)[0]
+    if !$payby && %options;
 
   HTML::Widgets::SelectLayers->new(
     options => \%options,