From 5b2b242ad80a2efac3fb3f4d919142307084bd73 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 2 May 2016 21:44:40 -0500 Subject: [PATCH] RT#37632: Credit card validation [v3 fixes] --- FS/FS/cust_main.pm | 24 ++++++++++++++++++++++++ FS/FS/cust_main/Billing_Realtime.pm | 2 ++ 2 files changed, 26 insertions(+) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 6e666466d..22b7a1648 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -542,6 +542,16 @@ sub insert { } + # validate card (needs custnum already set) + if ( $self->payby =~ /^(CARD|DCRD)$/ + && $conf->exists('business-onlinepayment-verification') ) { + $error = $self->realtime_verify_bop({ 'method'=>'CC' }); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + warn " setting contacts\n" if $DEBUG > 1; @@ -1540,6 +1550,20 @@ sub replace { return $error if $error; if ( $conf->exists('business-onlinepayment-verification') ) { + #need to standardize paydate for this, false laziness with check + my( $m, $y ); + if ( $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) { + ( $m, $y ) = ( $1, length($2) == 4 ? $2 : "20$2" ); + } elsif ( $self->paydate =~ /^19(\d{2})[\/\-](\d{1,2})[\/\-]\d+$/ ) { + ( $m, $y ) = ( $2, "19$1" ); + } elsif ( $self->paydate =~ /^(20)?(\d{2})[\/\-](\d{1,2})[\/\-]\d+$/ ) { + ( $m, $y ) = ( $3, "20$2" ); + } else { + return "Illegal expiration date: ". $self->paydate; + } + $m = sprintf('%02d',$m); + $self->paydate("$y-$m-01"); + $error = $self->realtime_verify_bop({ 'method'=>'CC' }); return $error if $error; } diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 90fda5eb2..4c28d0e0e 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -1938,8 +1938,10 @@ sub realtime_verify_bop { ); $reverse->content( 'action' => 'Reverse Authorization', + $self->_bop_auth(\%options), # B:OP + 'amount' => '1.00', 'authorization' => $transaction->authorization, 'order_number' => $ordernum, -- 2.11.0