X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling_Realtime.pm;h=330a4547bd696e6870345046eadc6a9e3fca9232;hb=efdd51f41e878349a942b0cb97e97e9feda1b3f0;hp=6e89f71b8575a238024a5dff957fce8aa5ec798f;hpb=0972e744b4b542550013a470f8b08cb090094a0f;p=freeside.git diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 6e89f71b8..330a4547b 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -3,6 +3,7 @@ package FS::cust_main::Billing_Realtime; use strict; use vars qw( $conf $DEBUG $me ); use vars qw( $realtime_bop_decline_quiet ); #ugh +use Carp; use Data::Dumper; use Business::CreditCard 0.28; use FS::UID qw( dbh ); @@ -300,10 +301,6 @@ sub _bop_content { ? $options->{country} : $self->country; - #3.0 is a good a time as any to get rid of this... add a config to pass it - # if anyone still needs it - #$content{referer} = 'http://cleanwhisker.420.am/'; - $content{phone} = $self->daytime || $self->night; my $currency = $conf->exists('business-onlinepayment-currency') @@ -323,6 +320,10 @@ my %bop_method2payby = ( sub realtime_bop { my $self = shift; + confess "Can't call realtime_bop within another transaction ". + '($FS::UID::AutoCommit is false)' + unless $FS::UID::AutoCommit; + local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; my %options = (); @@ -364,6 +365,8 @@ sub realtime_bop { if ( $DEBUG ) { warn "$me realtime_bop (new): $options{method} $options{amount}\n"; warn " cc_surcharge = $cc_surcharge\n"; + } + if ( $DEBUG > 2 ) { warn " $_ => $options{$_}\n" foreach keys %options; } @@ -546,7 +549,9 @@ sub realtime_bop { ? $options{'balance'} : $self->balance; + warn "claiming mutex on customer ". $self->custnum. "\n" if $DEBUG > 1; $self->select_for_update; #mutex ... just until we get our pending record in + warn "obtained mutex on customer ". $self->custnum. "\n" if $DEBUG > 1; #the checks here are intended to catch concurrent payments #double-form-submission prevention is taken care of in cust_pay_pending::check @@ -597,9 +602,16 @@ sub realtime_bop { }; $cust_pay_pending->payunique( $options{payunique} ) if defined($options{payunique}) && length($options{payunique}); + + warn "inserting cust_pay_pending record for customer ". $self->custnum. "\n" + if $DEBUG > 1; my $cpp_new_err = $cust_pay_pending->insert; #mutex lost when this is inserted return $cpp_new_err if $cpp_new_err; + warn "inserted cust_pay_pending record for customer ". $self->custnum. "\n" + if $DEBUG > 1; + warn Dumper($cust_pay_pending) if $DEBUG > 2; + my( $action1, $action2 ) = split( /\s*\,\s*/, $payment_gateway->gateway_action ); @@ -1010,8 +1022,9 @@ sub _realtime_bop_result { } else { - my $perror = $payment_gateway->gateway_module. " error: ". - $transaction->error_message; + my $perror = $transaction->error_message; + #$payment_gateway->gateway_module. " error: ". + # removed for conciseness my $jobnum = $cust_pay_pending->jobnum; if ( $jobnum ) { @@ -1109,7 +1122,11 @@ sub _realtime_bop_result { } $cust_pay_pending->status('done'); - $cust_pay_pending->statustext("declined: $perror"); + $cust_pay_pending->statustext($perror); + #'declined:': no, that's failure_status + if ( $transaction->can('failure_status') ) { + $cust_pay_pending->failure_status( $transaction->failure_status ); + } my $cpp_done_err = $cust_pay_pending->replace; if ( $cpp_done_err ) { my $e = "WARNING: $options{method} declined but pending payment not ". @@ -1227,11 +1244,6 @@ sub realtime_botpp_capture { 'amount' => $cust_pay_pending->paid, #'invoice_number' => $options{'invnum'}, 'customer_id' => $self->custnum, - - #3.0 is a good a time as any to get rid of this... add a config to pass it - # if anyone still needs it - #'referer' => 'http://cleanwhisker.420.am/', - 'reference' => $cust_pay_pending->paypendingnum, 'email' => $email, 'phone' => $self->daytime || $self->night, @@ -1441,10 +1453,6 @@ sub realtime_refund_bop { 'password' => $password, 'order_number' => $order_number, 'amount' => $amount, - - #3.0 is a good a time as any to get rid of this... add a config to pass it - # if anyone still needs it - #'referer' => 'http://cleanwhisker.420.am/', ); $content{authorization} = $auth if length($auth); #echeck/ACH transactions have an order # but no auth