package FS::cust_pay_void;
use strict;
-use base qw( FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_Mixin
+use base qw( FS::otaker_Mixin FS::payinfo_transaction_Mixin FS::cust_main_Mixin
FS::Record );
use vars qw( @encrypted_fields $otaker_upgrade_kludge );
use Business::CreditCard;
use FS::cust_pkg;
@encrypted_fields = ('payinfo');
+sub nohistory_fields { ('payinfo'); }
+
$otaker_upgrade_kludge = 0;
=head1 NAME
=item payby
-`CARD' (credit cards), `CHEK' (electronic check/ACH),
-`LECB' (phone bill billing), `BILL' (billing), `CASH' (cash),
-`WEST' (Western Union), `MCRD' (Manual credit card), or `COMP' (free)
+Payment Type (See L<FS::payinfo_Mixin> for valid values)
=item payinfo
card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
+=item cardtype
+
+Credit card type, if appropriate.
+
=item paybatch
text field for tracking card processing
map { $_ => $self->get($_) } fields('cust_pay')
} );
my $error = $cust_pay->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return $error;
+
+ my $cust_pay_pending =
+ qsearchs('cust_pay_pending', { void_paynum => $self->paynum });
+ if ( $cust_pay_pending ) {
+ $cust_pay_pending->set('paynum', $cust_pay->paynum);
+ $cust_pay_pending->set('void_paynum', '');
+ $error ||= $cust_pay_pending->replace;
}
- $error = $self->delete;
+ $error ||= $self->delete;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
|| $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
|| $self->ut_numbern('void_date')
|| $self->ut_textn('reason')
+ # || $self->payinfo_check #we'd rather void what we have than fail on this
;
return $error if $error;
$self->void_date(time) unless $self->void_date;
- $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP|PREP|CASH|WEST|MCRD)$/
- or return "Illegal payby";
- $self->payby($1);
-
- #false laziness with cust_refund::check
- if ( $self->payby eq 'CARD' ) {
- my $payinfo = $self->payinfo;
- $payinfo =~ s/\D//g;
- $self->payinfo($payinfo);
- if ( $self->payinfo ) {
- $self->payinfo =~ /^(\d{13,16}|\d{8,9})$/
- or return "Illegal (mistyped?) credit card number (payinfo)";
- $self->payinfo($1);
- validate($self->payinfo) or return "Illegal credit card number";
- return "Unknown card type" if $self->payinfo !~ /^99\d{14}$/ #token
- && cardtype($self->payinfo) eq "Unknown";
- } else {
- $self->payinfo('N/A');
- }
-
- } else {
- $error = $self->ut_textn('payinfo');
- return $error if $error;
- }
-
$self->void_usernum($FS::CurrentUser::CurrentUser->usernum)
unless $self->void_usernum;