summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authormark <mark>2010-09-21 05:54:24 +0000
committermark <mark>2010-09-21 05:54:24 +0000
commitd522fe5d5d1898165af4a92151412b2fe943f9ea (patch)
tree2b5e86690d41dd6454c836a9ba5c5891c810b8e4 /FS
parentfef4b45b04c7c0ad5e32dc93a904983a4383fbb7 (diff)
store TxRefNum for Paymentech batch payments, RT#9962
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/pay_batch.pm2
-rw-r--r--FS/FS/pay_batch/paymentech.pm27
2 files changed, 28 insertions, 1 deletions
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index 2561d3dc4..afff261a0 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -373,7 +373,7 @@ sub import_results {
my $cust_pay = new FS::cust_pay ( {
'custnum' => $custnum,
'payby' => $payby,
- 'paybatch' => $self->batchnum,
+ 'paybatch' => $hash{'paybatch'} || $self->batchnum,
'payinfo' => ( $hash{'payinfo'} || $cust_pay_batch->payinfo ),
map { $_ => $hash{$_} } (qw( paid _date )),
} );
diff --git a/FS/FS/pay_batch/paymentech.pm b/FS/FS/pay_batch/paymentech.pm
index 89f0c7723..a5b6f276d 100644
--- a/FS/FS/pay_batch/paymentech.pm
+++ b/FS/FS/pay_batch/paymentech.pm
@@ -2,6 +2,7 @@ package FS::pay_batch::paymentech;
use strict;
use vars qw(@ISA %import_info %export_info $name);
+use FS::Record 'qsearchs';
use Time::Local;
use Date::Format 'time2str';
use Date::Parse 'str2time';
@@ -12,6 +13,8 @@ my $conf;
my ($bin, $merchantID, $terminalID, $username);
$name = 'paymentech';
+my $gateway;
+
%import_info = (
filetype => 'XML',
xmlrow => [ qw(transResponse newOrderResp) ],
@@ -19,18 +22,42 @@ $name = 'paymentech';
'paybatchnum',
'_date',
'approvalStatus',
+ 'order_number',
+ 'authorization',
],
xmlkeys => [
'orderID',
'respDateTime',
'approvalStatus',
+ 'txRefNum',
+ 'authorizationCode',
],
'hook' => sub {
+ if ( !$gateway ) {
+ # find a gateway configuration that has the same merchantID
+ # as the batch config, if there is one. If not, leave
+ # gateway out entirely.
+ my $merchant = (FS::Conf->new->config('batchconfig-paymentech'))[2];
+ my $g = qsearchs({
+ 'table' => 'payment_gateway',
+ 'addl_from' => ' JOIN payment_gateway_option USING (gatewaynum) ',
+ 'hashref' => { disabled => '',
+ optionname => 'merchant_id',
+ optionvalue => $merchant,
+ },
+ });
+ $gateway = ($g ? $g->gatewaynum . '-' : '') . 'PaymenTech';
+ }
my ($hash, $oldhash) = @_;
my ($mon, $day, $year, $hour, $min, $sec) =
$hash->{'_date'} =~ /^(..)(..)(....)(..)(..)(..)$/;
$hash->{'_date'} = timelocal($sec, $min, $hour, $day, $mon-1, $year);
$hash->{'paid'} = $oldhash->{'amount'};
+ $hash->{'paybatch'} = join(':',
+ $gateway,
+ $hash->{'authorization'},
+ $hash->{'order_number'},
+ );
},
'approved' => sub { my $hash = shift;
$hash->{'approvalStatus'}