Skip to content

Commit

Permalink
RT# 77193 - fixed error when inserting new ach payby thru selfservice…
Browse files Browse the repository at this point in the history
… on V4. Now works
  • Loading branch information
Christopher Burger committed Oct 9, 2017
1 parent b9c2b7c commit ee27cd8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
17 changes: 9 additions & 8 deletions FS/FS/ClientAPI/MyAccount.pm
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions FS/FS/cust_payby.pm
Expand Up @@ -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;
Expand Down
36 changes: 31 additions & 5 deletions fs_selfservice/FS-SelfService/cgi/selfservice.cgi
Expand Up @@ -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' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
};
} else {
return $results;
}
}

sub process_change_bill {
_process_change_info( 'change_bill',
qw( first last company address1 address2 city state
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ee27cd8

Please sign in to comment.