X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fprocess%2Fpayment.cgi;h=717d57c8588268e00aa1848abdb390621926df46;hp=852becb9d5e5ba4178c318bbbd413c4b95f21295;hb=55017a988ebdd9456d66b23f973b560733abfb55;hpb=fe58901b811f0ab26e8f93a9563fb93bc98e4c19 diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 852becb9d..717d57c85 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -72,7 +72,7 @@ $cgi->param('discount_term') =~ /^(\d*)$/ or errorpage("illegal discount_term"); my $discount_term = $1; -my( $payinfo, $paycvv, $month, $year, $payname ); +my( $cust_payby, $payinfo, $paycvv, $month, $year, $payname ); my $paymask = ''; if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { @@ -80,10 +80,11 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { # use stored cust_payby info ## - my $cust_payby = qsearchs('cust_payby', { custnum => $custnum, + $cust_payby = qsearchs('cust_payby', { custnum => $custnum, custpaybynum => $custpaybynum, } ) or die "unknown custpaybynum $custpaybynum"; + # not needed for realtime_bop, but still needed for batch_card $payinfo = $cust_payby->payinfo; $paymask = $cust_payby->paymask; $paycvv = $cust_payby->paycvv; # pass it if we got it, running a transaction will clear it @@ -128,13 +129,13 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { $payinfo = $cgi->param('payinfo'); $payinfo =~ s/\D//g; - $payinfo =~ /^(\d{13,16}|\d{8,9})$/ + $payinfo =~ /^(\d{13,19}|\d{8,9})$/ or errorpage(gettext('invalid_card')); $payinfo = $1; validate($payinfo) or errorpage(gettext('invalid_card')); - unless ( $payinfo =~ /^99\d{14}$/ ) { #token + unless ( $cust_main->tokenized($payinfo) ) { #token my $cardtype = cardtype($payinfo); @@ -164,7 +165,7 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { die "unknown payby $payby"; } - # save first, for proper tokenization later + # save first, for proper tokenization if ( $cgi->param('save') ) { my %saveopt; @@ -181,6 +182,7 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { } my $error = $cust_main->save_cust_payby( + 'saved_cust_payby' => \$cust_payby, 'payment_payby' => $payby, 'auto' => scalar($cgi->param('auto')), 'weight' => scalar($cgi->param('weight')), @@ -191,6 +193,11 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) { errorpage("error saving info, payment not processed: $error") if $error; + + } elsif ( $payby eq 'CARD' ) { # not saving + + $paymask = FS::payinfo_Mixin->mask_payinfo('CARD',$payinfo); # for untokenized but tokenizable payinfo + } } @@ -220,6 +227,7 @@ if ( $cgi->param('batch') ) { } else { $error = $cust_main->realtime_bop( $FS::payby::payby2bop{$payby}, $amount, + 'cust_payby' => $cust_payby, # if defined, will override passed payinfo, etc 'quiet' => 1, 'manual' => 1, 'balance' => $balance, @@ -248,7 +256,7 @@ if ( $cgi->param('batch') ) { #and generate an invoice for it now too $error = $cust_main->bill( 'pkg_list' => [ $cust_pkg ] ); - errorpage("payment processed and fee ordered sucessfully, but error billing fee: $error") + errorpage("payment processed and fee ordered successfully, but error billing fee: $error") if $error; }