use Carp;
use Data::Dumper;
use Business::CreditCard 0.35;
+use Business::OnlinePayment;
use FS::UID qw( dbh myconnect );
use FS::Record qw( qsearch qsearchs );
use FS::payby;
$options{amount} = $self->balance unless exists( $options{amount} );
return '' unless $options{amount} > 0;
+ #huh, in v4, realtime_bop no longer will just process a card without passing
+ # payinfo or cust_payby...
+ if ( ! $options{'payinfo'} && ! $options{'cust_payby'} && $self->has_cust_payby_auto ) {
+ my @cust_payby = $self->cust_payby;
+ $options{'cust_payby'} = $cust_payby[0];
+ }
+
return $self->realtime_bop({%options});
}
and any other tokenizable records will still be committed.
If the I<daily> flag is also set, detection of existing untokenized records will
-record a critical error in the system log (because they should have never appeared
+record an info message in the system log (because they should have never appeared
in the first place.) Tokenization will still be attempted.
If any configured gateways do NOT have the ability to tokenize, or if a
#acts on all customers
my %opt = @_;
my $debug = !$opt{'quiet'} || $DEBUG;
+ my $hascritical = 0;
warn "token_check called with opts\n".Dumper(\%opt) if $debug;
}
my $error = "No gateway found for custnum ".$cust_main->custnum;
if ($opt{'queue'}) {
+ $hascritical = 1;
$log->critical($error);
$dbh->commit or die $dbh->errstr; # commit error message
next; # not next CUSTLOOP, want to record error for every cust_payby
if ($error) {
$error = "Error tokenizing cust_payby ".$cust_payby->custpaybynum.": ".$error;
if ($opt{'queue'}) {
+ $hascritical = 1;
$log->critical($error);
$dbh->commit or die $dbh->errstr; # commit log message, release mutex
next; # not next CUSTLOOP, want to record error for every cust_payby
while (my $recnum = _token_check_next_recnum($dbh,$table,$step,\$offset,\@recnums)) {
my $record = $tclass->by_key($recnum);
+ unless ($record->payby eq 'CARD') {
+ warn "Skipping non-card record for $table ".$record->get($record->primary_key) if $debug;
+ next;
+ }
if (FS::cust_main::Billing_Realtime->tokenized($record->payinfo)) {
warn "Skipping tokenized record for $table ".$record->get($record->primary_key) if $debug;
next;
} else {
my $error = "Could not load cust_main for $table ".$record->get($record->primary_key);
if ($opt{'queue'}) {
+ $hascritical = 1;
$log->critical($error);
$dbh->commit or die $dbh->errstr; # commit log message
next;
if ($error) {
$error = "Error tokenizing $table ".$record->get($record->primary_key).": ".$error;
if ($opt{'queue'}) {
+ $hascritical = 1;
$log->critical($error);
$dbh->commit or die $dbh->errstr; # commit log message, release mutex
next;
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return '';
+ return $hascritical ? 'Critical errors occurred on some records, see system log' : '';
}
# not a method!
my $sth = $dbh->prepare(
'SELECT '.$tclass->primary_key.
' FROM '.$table.
- " WHERE payby IN ( 'CARD', 'DCRD' ) ".
- " AND ( length(payinfo) > 80 OR payinfo NOT LIKE '99%' )".
+ " WHERE ( is_tokenized IS NULL OR is_tokenized = '' ) ".
' ORDER BY '.$tclass->primary_key.
' LIMIT '.$step.
' OFFSET '.$$offset