X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FSignup.pm;h=488692f9f0bc1c9457bfcbc286df3e85ce83e788;hp=1bce9654f0dd7b9d6acb976d4cfd06ab29779cba;hb=90393980e5f2859ee1e186fa461f48f5129e803e;hpb=314565233e336063494acdcbf22077043ce54d88 diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 1bce9654f..488692f9f 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -321,23 +321,34 @@ sub signup_info { warn "$me has agent $agent\n" if $DEBUG > 1; if ( $agent ) { #else complain loudly? $signup_info->{'hide_payment_fields'} = []; - foreach my $payby (@{$signup_info->{payby}}) { - warn "$me checking $payby payment fields\n" if $DEBUG > 1; - my $hide = 0; - if ( FS::payby->realtime($payby) ) { - my $payment_gateway = - $agent->payment_gateway( 'method' => FS::payby->payby2bop($payby), - 'nofatal' => 1, - ); - if ( $payment_gateway - && $payment_gateway->gateway_namespace - eq 'Business::OnlineThirdPartyPayment' - ) { - warn "$me hiding $payby payment fields\n" if $DEBUG > 1; - $hide = 1; + my $gatewaynum = $conf->config('selfservice-payment_gateway'); + if ( $gatewaynum ) { + my $pg = qsearchs('payment_gateway', { gatewaynum => $gatewaynum }); + die "configured gatewaynum $gatewaynum not found!" if !$pg; + my $hide = $pg->gateway_namespace eq 'Business::OnlineThirdPartyPayment'; + $signup_info->{'hide_payment_fields'} = [ + map { $hide } @{$signup_info->{'payby'}} + ]; + } + else { + foreach my $payby (@{$signup_info->{payby}}) { + warn "$me checking $payby payment fields\n" if $DEBUG > 1; + my $hide = 0; + if ( FS::payby->realtime($payby) ) { + my $payment_gateway = + $agent->payment_gateway( 'method' => FS::payby->payby2bop($payby), + 'nofatal' => 1, + ); + if ( $payment_gateway + && $payment_gateway->gateway_namespace + eq 'Business::OnlineThirdPartyPayment' + ) { + warn "$me hiding $payby payment fields\n" if $DEBUG > 1; + $hide = 1; + } } - } - push @{$signup_info->{'hide_payment_fields'}}, $hide; + push @{$signup_info->{'hide_payment_fields'}}, $hide; + } # foreach $payby } } warn "$me done setting agent-specific payment flag\n" if $DEBUG > 1; @@ -545,9 +556,17 @@ sub new_customer { return { 'error' => "Unknown reseller" } unless $agent; - my $gw = $agent->payment_gateway( 'method' => FS::payby->payby2bop($payby), - 'nofatal' => 1, + my $gw; + my $gatewaynum = $conf->config('selfservice-payment_gateway'); + if ( $gatewaynum ) { + $gw = qsearchs('payment_gateway', { gatewaynum => $gatewaynum }); + die "configured gatewaynum $gatewaynum not found!" if !$gw; + } + else { + $gw = $agent->payment_gateway( 'method' => FS::payby->payby2bop($payby), + 'nofatal' => 1, ); + } $cust_main->payby('BILL') # MCRD better? if $gw && $gw->gateway_namespace eq 'Business::OnlineThirdPartyPayment'; @@ -609,7 +628,7 @@ sub new_customer { push @acct_snarf, $acct_snarf; } $svc->child_objects( \@acct_snarf ); - + push @svc, $svc; } elsif ( $svc_x eq 'svc_phone' ) { @@ -698,6 +717,7 @@ sub new_customer { $bill_error = $cust_main->realtime_collect( method => FS::payby->payby2bop( $packet->{payby} ), depend_jobnum => $placeholder->jobnum, + selfservice => 1, ); #warn "$me error collecting from new customer: $bill_error" # if $bill_error; @@ -787,29 +807,36 @@ sub capture_payment { my $conf = new FS::Conf; - my $url = $packet->{url}; - my $payment_gateway = - qsearchs('payment_gateway', { 'gateway_callback_url' => popurl(0, $url) } ); - - unless ($payment_gateway) { - - my ( $processor, $login, $password, $action, @bop_options ) = - $conf->config('business-onlinepayment'); - $action ||= 'normal authorization'; - pop @bop_options if scalar(@bop_options) % 2 && $bop_options[-1] =~ /^\s*$/; - die "No real-time processor is enabled - ". - "did you set the business-onlinepayment configuration value?\n" - unless $processor; - - $payment_gateway = new FS::payment_gateway( { - gateway_namespace => $conf->config('business-onlinepayment-namespace'), - gateway_module => $processor, - gateway_username => $login, - gateway_password => $password, - gateway_action => $action, - options => [ ( @bop_options ) ], - }); - + my $payment_gateway; + if ( my $gwnum = $conf->config('selfservice-payment_gateway') ) { + $payment_gateway = qsearchs('payment_gateway', { 'gatewaynum' => $gwnum }) + or die "configured gatewaynum $gwnum not found!"; + } + else { + my $url = $packet->{url}; + + $payment_gateway = qsearchs('payment_gateway', + { 'gateway_callback_url' => popurl(0, $url) } + ); + if (!$payment_gateway) { + + my ( $processor, $login, $password, $action, @bop_options ) = + $conf->config('business-onlinepayment'); + $action ||= 'normal authorization'; + pop @bop_options if scalar(@bop_options) % 2 && $bop_options[-1] =~ /^\s*$/; + die "No real-time processor is enabled - ". + "did you set the business-onlinepayment configuration value?\n" + unless $processor; + + $payment_gateway = new FS::payment_gateway( { + gateway_namespace => $conf->config('business-onlinepayment-namespace'), + gateway_module => $processor, + gateway_username => $login, + gateway_password => $password, + gateway_action => $action, + options => [ ( @bop_options ) ], + }); + } } die "No real-time third party processor is enabled - ". @@ -847,7 +874,10 @@ sub capture_payment { my $cust_main = $cust_pay_pending->cust_main; my $bill_error = - $cust_main->realtime_botpp_capture( $cust_pay_pending, %{$packet->{data}} ); + $cust_main->realtime_botpp_capture( $cust_pay_pending, + %{$packet->{data}}, + apply => 1, + ); return { 'error' => ( $bill_error->{bill_error} ? '_decline' : '' ), %$bill_error,