[freeside-commits] branch master updated. 23c80f76dae49785318a5dac440558977a05c17c
Christopher Burger
burgerc at 420.am
Mon Aug 28 06:30:33 PDT 2017
The branch, master has been updated
via 23c80f76dae49785318a5dac440558977a05c17c (commit)
from 3a63e53c109a26f27a098028cf65882318d44099 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 23c80f76dae49785318a5dac440558977a05c17c
Author: Christopher Burger <burgerc at freeside.biz>
Date: Mon Aug 28 09:29:08 2017 -0400
RT# 76952 - fixed error that would save a duplicate ACH or credit card account
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 5c86b78..a10a452 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -980,6 +980,7 @@ sub validate_payment {
#false laziness w/process/payment.cgi
my $payinfo;
my $paycvv = '';
+ my $replace_cust_payby;
if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) {
$p->{'payinfo1'} =~ /^([\dx]+)$/
@@ -994,6 +995,7 @@ sub validate_payment {
foreach my $cust_payby ($cust_main->cust_payby('CHEK','DCHK')) {
if ( $cust_payby->paymask eq $payinfo ) {
$payinfo = $cust_payby->payinfo;
+ $replace_cust_payby = $cust_payby;
$achonfile = 1;
last;
}
@@ -1014,6 +1016,7 @@ sub validate_payment {
foreach my $cust_payby ($cust_main->cust_payby('CARD','DCRD')) {
if ( $cust_payby->paymask eq $payinfo ) {
$payinfo = $cust_payby->payinfo;
+ $replace_cust_payby = $cust_payby;
$onfile = 1;
last;
}
@@ -1055,6 +1058,8 @@ sub validate_payment {
'CHEK' => [ qw( ss paytype paystate stateid stateid_state payip ) ],
);
+ my %replace = ( 'replace' => $replace_cust_payby, );
+
my $card_type = '';
$card_type = cardtype($payinfo) if $payby eq 'CARD';
@@ -1063,7 +1068,7 @@ sub validate_payment {
'amount' => sprintf('%.2f', $amount),
'payby' => $payby,
'payinfo' => $payinfo,
- 'paymask' => $cust_main->mask_payinfo( $payby, $payinfo ),
+ 'paymask' => FS::payinfo_Mixin->mask_payinfo( $payby, $payinfo ),
'card_type' => $card_type,
'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01',
'paydate_pretty' => $p->{'month'}. ' / '. $p->{'year'},
@@ -1076,6 +1081,7 @@ sub validate_payment {
'payname' => $payname,
'discount_term' => $discount_term,
'pkgnum' => $session->{'pkgnum'},
+ %replace,
map { $_ => $p->{$_} } ( @{ $payby2fields{$payby} },
qw( save auto ),
)
@@ -1158,6 +1164,7 @@ sub do_process_payment {
my $error = $cust_main->save_cust_payby(
'payment_payby' => $payby,
+ 'replace' => $validate->{'replace'}, # cust_payby object to replace
%saveopt
);
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index f8157c4..925eb4e 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4617,6 +4617,8 @@ PAYBYLOOP:
next if grep(/^$field$/, qw( custpaybynum payby weight ) );
next if grep(/^$field$/, @preserve );
next PAYBYLOOP unless $new->get($field) eq $cust_payby->get($field);
+ # check if paymask exists, if so stop and don't save, no need for a duplicate.
+ return '' if $new->get('paymask') eq $cust_payby->get('paymask');
}
# now check fields that can replace if one value is blank
my $replace = 0;
diff --git a/ng_selfservice/payment_cc.php b/ng_selfservice/payment_cc.php
index 5c49dab..37f57c0 100644
--- a/ng_selfservice/payment_cc.php
+++ b/ng_selfservice/payment_cc.php
@@ -88,8 +88,8 @@ if ( $receipt_html ) { ?>
<TD COLSPAN=7>
<SELECT NAME="card_type"><OPTION></OPTION>
<? foreach ( $card_types AS $ct ) { ?>
- <OPTION <? if ( $card_type == $card_types[$ct] ) { echo 'SELECTED'; } ?>
- VALUE="<? echo $card_types[$ct]; ?>"><? echo $ct; ?>
+ <OPTION <? if ( $card_type == $ct ) { echo 'SELECTED'; } ?>
+ VALUE="<? echo $ct; ?>"><? echo $ct; ?>
<? } ?>
</SELECT>
</TD>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/ClientAPI/MyAccount.pm | 9 ++++++++-
FS/FS/cust_main.pm | 2 ++
ng_selfservice/payment_cc.php | 4 ++--
3 files changed, 12 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list