From: Christopher Burger Date: Mon, 9 Oct 2017 18:36:07 +0000 (-0400) Subject: RT# 77193 - fixed error when inserting new ach payby thru selfservice on V4. Now... X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=ee27cd8eea7b135db2ba8a6b1a6ac8933171d9d0 RT# 77193 - fixed error when inserting new ach payby thru selfservice on V4. Now works --- diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 30ab96b49..e28aa1870 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -1675,14 +1675,15 @@ sub insert_payby { #XXX payinfo1 + payinfo2 for CHEK? #or take the opportunity to use separate, more well- named fields? - # my $payinfo; - # $p->{'payinfo1'} =~ /^([\dx]+)$/ - # or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; - # my $payinfo1 = $1; - # $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? - # or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; - # my $payinfo2 = $1; - # $payinfo = $payinfo1. '@'. $payinfo2; + if ($p->{'payby'} eq 'CHEK') { + $p->{'payinfo1'} =~ /^([\dx]+)$/ + or return { 'error' => "illegal account number ". $p->{'payinfo1'} }; + my $payinfo1 = $1; + $p->{'payinfo2'} =~ /^([\dx\.]+)$/ # . turned on by echeck-country CA ? + or return { 'error' => "illegal ABA/routing number ". $p->{'payinfo2'} }; + my $payinfo2 = $1; + $p->{'payinfo'} = $payinfo1. '@'. $payinfo2; + } my $cust_payby = new FS::cust_payby { 'custnum' => $custnum, diff --git a/FS/FS/cust_payby.pm b/FS/FS/cust_payby.pm index fd90597bf..704741f3d 100644 --- a/FS/FS/cust_payby.pm +++ b/FS/FS/cust_payby.pm @@ -159,8 +159,9 @@ sub insert { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - my $error = $self->check_payinfo_cardtype - || $self->SUPER::insert; + my $error = $self->check_payinfo_cardtype if $self->payby =~/^(CARD|DCRD)$/; + $self->SUPER::insert unless $error; + if ( $error ) { $dbh->rollback if $oldAutoCommit; return $error; diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index f194746c5..6cf264c08 100755 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -337,6 +337,32 @@ sub _process_change_payby { } } +sub _process_insert_payby { + my ($erroraction, @fields) = @_; + + my $results = ''; + + $results ||= insert_payby ( + 'session_id' => $session_id, + map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields, + ); + + ## check error + + + if ( $results->{'error'} ) { + no strict 'refs'; + $action = $erroraction; + return { + $cgi->Vars, + %{&$action()}, + 'error' => ''. $results->{'error'}. '', + }; + } else { + return $results; + } +} + sub process_change_bill { _process_change_info( 'change_bill', qw( first last company address1 address2 city state @@ -389,20 +415,20 @@ sub process_change_creditcard_pay { address1 address2 city county state zip country auto paytype paystate ss stateid stateid_state invoicing_list ); - - _process_change_payby( 'change_creditcard_pay', @list ); + if ($cgi->param( 'custpaybynum' )) { _process_change_payby( 'change_creditcard_pay', @list ); } + else { _process_insert_payby( 'change_creditcard_pay', @list ); } } sub process_change_check_pay { my $payby = $cgi->param( 'payby' ); - $cgi->param('paydate', $cgi->param('year') . '-' . $cgi->param('month') . '-01'); + #$cgi->param('paydate', '2039-12-01'); my @list = qw( payby payinfo payinfo1 payinfo2 paydate payname custpaybynum address1 address2 city county state zip country auto paytype paystate ss stateid stateid_state invoicing_list ); - - _process_change_payby( 'change_check_pay', @list ); + if ($cgi->param( 'custpaybynum' )) { _process_change_payby( 'change_check_pay', @list ); } + else { _process_insert_payby( 'change_check_pay', @list ); } } sub view_invoice {