X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=23bcdd93af0226929e2e96a5bd28133c3da0a6dd;hb=fca1ac5d298b3896c1c42c4ffc7bdd3bab9b8516;hp=30333e0c4e27d593355c847374db0c5a78eb44da;hpb=10fdcf4c76e4dd14f7fb738665e3fb401af3c28a;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 30333e0c4..23bcdd93a 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -69,7 +69,9 @@ L and L for conversion functions. =item paymask - Masked payinfo (See L for how this works) -=item paybatch - text field for tracking card processing +=item paybatch - text field for tracking card processing or other batch grouping + +=item payunique - Optional unique identifer to prevent duplicate transactions. =item closed - books closed flag, empty or `Y' @@ -162,17 +164,6 @@ sub insert { } } - if ( $self->paybatch =~ /^webui-/ ) { - my @cust_pay = qsearch('cust_pay', { - 'custnum' => $self->custnum, - 'paybatch' => $self->paybatch, - } ); - if ( scalar(@cust_pay) > 1 ) { - $dbh->rollback if $oldAutoCommit; - return "a payment with webui token ". $self->paybatch. " already exists"; - } - } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; #false laziness w/ cust_credit::insert @@ -403,6 +394,7 @@ sub check { || $self->ut_money('paid') || $self->ut_numbern('_date') || $self->ut_textn('paybatch') + || $self->ut_textn('payunique') || $self->ut_enum('closed', [ '', 'Y' ]) || $self->payinfo_check() ; @@ -416,6 +408,16 @@ sub check { $self->_date(time) unless $self->_date; + # UNIQUE index should catch this too, without race conditions, but this + # should give a better error message the other 99.9% of the time... + if ( length($self->payunique) + && qsearchs('cust_pay', { 'payunique' => $self->payunique } ) ) { + #well, it *could* be a better error message + return "duplicate transaction". + " - a payment with unique identifer ". $self->payunique. + " already exists"; + } + $self->SUPER::check; }