summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-10-25 23:30:00 +0000
committerivan <ivan>2009-10-25 23:30:00 +0000
commit534d783cfda72bbea29a78954bafa1d25f443782 (patch)
treee5b0cce276d2250428e33739ac95653b184b4a89
parentb0ca0f4c6dc42596f1b1d838f897042589af8252 (diff)
add apply option to realtime_collect, RT#5071
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm2
-rw-r--r--FS/FS/cust_main.pm41
2 files changed, 37 insertions, 6 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 1e029ed25..21dab46f4 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -680,7 +680,6 @@ sub process_payment {
}
sub realtime_collect {
-
my $p = shift;
my $session = _cache->get($p->{'session_id'})
@@ -695,6 +694,7 @@ sub realtime_collect {
'method' => $p->{'method'},
'pkgnum' => $session->{'pkgnum'},
'session_id' => $p->{'session_id'},
+ 'apply' => 1,
);
return { 'error' => $error } unless ref( $error );
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 506f10b89..ffc9f0fce 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3854,7 +3854,9 @@ I<description> is a free-text field passed to the gateway. It defaults to
If an I<invnum> is specified, this payment (if successful) is applied to the
specified invoice. If you don't specify an I<invnum> you might want to
-call the B<apply_payments> method.
+call the B<apply_payments> method or set the I<apply> option.
+
+I<apply> can be set to true to apply a resulting payment.
I<quiet> can be set true to surpress email decline notices.
@@ -3873,7 +3875,16 @@ sub realtime_bop {
return $self->_new_realtime_bop(@_)
if $self->_new_bop_required();
- my( $method, $amount, %options ) = @_;
+ my($method, $amount);
+ my %options = ();
+ if (ref($_[0]) eq 'HASH') {
+ %options = %{$_[0]};
+ $method = $options{method};
+ $amount = $options{amount};
+ } else {
+ ( $method, $amount ) = ( shift, shift );
+ %options = @_;
+ }
if ( $DEBUG ) {
warn "$me realtime_bop: $method $amount\n";
warn " $_ => $options{$_}\n" foreach keys %options;
@@ -4347,6 +4358,16 @@ sub realtime_bop {
} else {
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ if ( $options{'apply'} ) {
+ my $apply_error = $self->apply_payments_and_credits;
+ if ( $apply_error ) {
+ warn "WARNING: error applying payment: $apply_error\n";
+ #but we still should return no error cause the payment otherwise went
+ #through...
+ }
+ }
+
return ''; #no error
}
@@ -4802,7 +4823,6 @@ sub _new_bop_required {
'';
}
-
=item realtime_collect [ OPTION => VALUE ... ]
Runs a realtime credit card, ACH (electronic check) or phone bill transaction
@@ -4830,7 +4850,9 @@ I<description> is a free-text field passed to the gateway. It defaults to
If an I<invnum> is specified, this payment (if successful) is applied to the
specified invoice. If you don't specify an I<invnum> you might want to
-call the B<apply_payments> method.
+call the B<apply_payments> method or set the I<apply> option.
+
+I<apply> can be set to true to apply a resulting payment.
I<quiet> can be set true to surpress email decline notices.
@@ -5513,6 +5535,16 @@ sub _realtime_bop_result {
} else {
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ if ( $options{'apply'} ) {
+ my $apply_error = $self->apply_payments_and_credits;
+ if ( $apply_error ) {
+ warn "WARNING: error applying payment: $apply_error\n";
+ #but we still should return no error cause the payment otherwise went
+ #through...
+ }
+ }
+
return ''; #no error
}
@@ -6374,7 +6406,6 @@ A hash of optional arguments may be passed. Currently "manual" is supported.
If true, a payment receipt is sent instead of a statement when
'payment_receipt_email' configuration option is set.
-
Dies if there is an error.
=cut