RT# 79902 - fixed so change payment information link will still work when upgraded...
[freeside.git] / fs_selfservice / FS-SelfService / cgi / selfservice.cgi
index 6cf264c..6986405 100755 (executable)
@@ -12,7 +12,7 @@ use Date::Format;
 use Date::Parse 'str2time';
 use Number::Format 1.50;
 use FS::SelfService qw(
-  access_info login_info login customer_info edit_info insert_payby update_payby 
+  access_info login_info login customer_info edit_info insert_payby update_payby
   invoice payment_info process_payment realtime_collect process_prepay
   list_pkgs order_pkg signup_info order_recharge
   part_svc_info provision_acct provision_external provision_phone provision_forward
@@ -284,7 +284,10 @@ sub change_bill {
   };
 }
 sub change_ship { change_bill(@_); }
-sub change_pay { change_bill(@_); }
+sub change_pay {
+  my @payby = ('CARD', 'CHEK', 'DCHK');
+  change_bill(@_);
+}
 
 sub change_creditcard_pay { change_bill('CARD'); }
 sub change_check_pay { change_bill('CHEK'); }
@@ -385,8 +388,9 @@ sub process_change_ship {
 sub process_change_pay {
         my $postal = $cgi->param( 'postal_invoicing' );
         my $payby  = $cgi->param( 'payby' );
+        $cgi->param('paydate', $cgi->param('year') . '-' . $cgi->param('month') . '-01');
         my @list =
-          qw( payby payinfo payinfo1 payinfo2 month year payname
+          qw( payby payinfo payinfo1 payinfo2 month year paydate payname custpaybynum
               address1 address2 city county state zip country auto paytype
               paystate ss stateid stateid_state invoicing_list
             );
@@ -404,7 +408,11 @@ sub process_change_pay {
           };
         }
 
-        _process_change_info( 'change_pay', @list );
+        if (FS::SelfService->can('update_payby')) {
+          if ($cgi->param( 'custpaybynum' )) { _process_change_payby( 'change_pay', @list ); }
+          else { _process_insert_payby( 'change_pay', @list ); }
+        }
+        else { _process_change_info( 'change_pay', @list ); }
 }
 
 sub process_change_creditcard_pay {
@@ -726,9 +734,9 @@ sub payment_results {
   $cgi->param('paycvv') =~ /^\s*(.{0,4})\s*$/ or die "illegal CVV2";
   my $paycvv = $1;
 
-  $cgi->param('month') =~ /^(\d{2})$/ or die "illegal month";
+  $cgi->param('month') =~ /^(\d{2})/ or die "illegal month";
   my $month = $1;
-  $cgi->param('year') =~ /^(\d{4})$/ or die "illegal year";
+  $cgi->param('year') =~ /^(\d{4})/ or die "illegal year";
   my $year = $1;
 
   $cgi->param('payname') =~ /^(.{0,80})$/ or die "illegal payname";
@@ -1325,5 +1333,3 @@ sub include {
                     );
 
 }
-
-