From: ivan Date: Sun, 25 Oct 2009 22:59:27 +0000 (+0000) Subject: backport realtime_collect to 1.7 for SG to use instead of calling collect, RT#5071 X-Git-Tag: freeside_1_7_4~30 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=1b2a96a59001c6f1935c92de52352c887924a622;hp=42591d3035d7b3fbcced05dac6a684903b64053a;p=freeside.git backport realtime_collect to 1.7 for SG to use instead of calling collect, RT#5071 --- diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index d386bcc07..0a2b0fd22 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -472,6 +472,28 @@ sub process_payment { } +sub realtime_collect { + my $p = shift; + + my $session = _cache->get($p->{'session_id'}) + or return { 'error' => "Can't resume session" }; #better error message + + my $custnum = $session->{'custnum'}; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + my $error = $cust_main->realtime_collect( + 'method' => $p->{'method'}, + 'session_id' => $p->{'session_id'}, + ); + return { 'error' => $error } unless ref( $error ); + + my $amount = $cust_main->balance; + + return { 'error' => '', amount => $amount, %$error }; +} + sub process_payment_order_pkg { my $p = shift; diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index c74cb45ac..cbbfc4858 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -3612,6 +3612,59 @@ sub realtime_refund_bop { } +=item realtime_collect [ OPTION => VALUE ... ] + +Runs a realtime credit card, ACH (electronic check) or phone bill transaction +via a Business::OnlinePayment realtime gateway. See +L for supported gateways. + +If there is an error, returns the error, otherwise returns false. + +Available options are: I, I, I, I, I, I, I + +I is one of: I, I and I. If none is specified +then it is deduced from the customer record. + +If no I is specified, then the customer balance is used. + +The additional options I, I, I, I, I, +I, I and I are also available. Any of these options, +if set, will override the value from the customer record. + +I is a free-text field passed to the gateway. It defaults to +"Internet services". + +If an I is specified, this payment (if successful) is applied to the +specified invoice. If you don't specify an I you might want to +call the B method. + +I can be set true to surpress email decline notices. + +I can be set to a scalar reference. It will be filled in with the +resulting paynum, if any. + +I is a unique identifier for this payment. + +I allows payment capture to unlock export jobs + +=cut + +sub realtime_collect { + my( $self, %options ) = @_; + + if ( $DEBUG ) { + warn "$me realtime_collect:\n"; + warn " $_ => $options{$_}\n" foreach keys %options; + } + + $options{amount} = $self->balance unless exists( $options{amount} ); + $options{method} = FS::payby->payby2bop($self->payby) + unless exists( $options{method} ); + + return $self->realtime_bop({%options}); + +} + =item batch_card OPTION => VALUE... Adds a payment for this invoice to the pending credit card batch (see diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index 36928d02c..578ae52a9 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -39,6 +39,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'process_payment_change_pkg' => 'MyAccount/process_payment_change_pkg', 'process_payment_order_renew' => 'MyAccount/process_payment_order_renew', 'process_prepay' => 'MyAccount/process_prepay', + 'realtime_collect' => 'MyAccount/realtime_collect', 'list_pkgs' => 'MyAccount/list_pkgs', #add to ss (added?) 'list_svcs' => 'MyAccount/list_svcs', #add to ss (added?) 'list_svc_usage' => 'MyAccount/list_svc_usage',