summaryrefslogtreecommitdiff
path: root/FS/FS/cust_pay_batch.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-01-29 16:28:26 -0800
committerMark Wells <mark@freeside.biz>2013-01-30 12:09:29 -0800
commit61097b876e692dbf5571a17b9aa415949607085f (patch)
treeaead5bab2124ce0aaca391a15de3deeaa383f867 /FS/FS/cust_pay_batch.pm
parent6bd91fa5feb41ea3294bdaee5fe1c1134f19c330 (diff)
record and show batch payment status info, #21117
Diffstat (limited to 'FS/FS/cust_pay_batch.pm')
-rw-r--r--FS/FS/cust_pay_batch.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm
index 9f2e9dd..4138436 100644
--- a/FS/FS/cust_pay_batch.pm
+++ b/FS/FS/cust_pay_batch.pm
@@ -9,7 +9,7 @@ use FS::payinfo_Mixin;
use FS::cust_main;
use FS::cust_bill;
-@ISA = qw( FS::payinfo_Mixin FS::Record );
+@ISA = qw( FS::payinfo_Mixin FS::cust_main_Mixin FS::Record );
# 1 is mostly method/subroutine entry and options
# 2 traces progress of some operations
@@ -80,7 +80,9 @@ following fields are currently supported:
=item country
-=item status
+=item status - 'Approved' or 'Declined'
+
+=item error_message - the error returned by the gateway if any
=back
@@ -289,19 +291,21 @@ sub retriable {
'';
}
-=item approve PAYBATCH
+=item approve OPTIONS
Approve this payment. This will replace the existing record with the
same paybatchnum, set its status to 'Approved', and generate a payment
record (L<FS::cust_pay>). This should only be called from the batch
import process.
+OPTIONS may contain "gatewaynum", "processor", "auth", and "order_number".
+
=cut
sub approve {
# to break up the Big Wall of Code that is import_results
my $new = shift;
- my $paybatch = shift;
+ my %opt = @_;
my $paybatchnum = $new->paybatchnum;
my $old = qsearchs('cust_pay_batch', { paybatchnum => $paybatchnum })
or return "paybatchnum $paybatchnum not found";
@@ -317,13 +321,17 @@ sub approve {
my $cust_pay = new FS::cust_pay ( {
'custnum' => $new->custnum,
'payby' => $new->payby,
- 'paybatch' => $paybatch,
'payinfo' => $new->payinfo || $old->payinfo,
'paid' => $new->paid,
'_date' => $new->_date,
'usernum' => $new->usernum,
'batchnum' => $new->batchnum,
+ 'gatewaynum' => $opt{'gatewaynum'},
+ 'processor' => $opt{'processor'},
+ 'auth' => $opt{'auth'},
+ 'order_number' => $opt{'order_number'}
} );
+
$error = $cust_pay->insert;
if ( $error ) {
return "error inserting payment for paybatchnum $paybatchnum: $error\n";
@@ -375,6 +383,7 @@ sub decline {
}
} # !$old->status
$new->status('Declined');
+ $new->error_message($reason);
my $error = $new->replace($old);
if ( $error ) {
return "error updating status of paybatchnum $paybatchnum: $error\n";