summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-10-19 12:51:06 -0700
committerMark Wells <mark@freeside.biz>2012-10-19 12:51:06 -0700
commit744b17e5c9a5de68ad8a24b7a35449b535f02731 (patch)
tree341a92bd2b7b20aaaa4328391c8ea8bda78beff8 /FS
parenta056cbfc08fa8491aa3c995d7053ed4574b18c50 (diff)
recurring indicator for Paymentech batches, #19571
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm2
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm11
-rw-r--r--FS/FS/pay_batch/paymentech.pm12
-rw-r--r--FS/FS/payinfo_Mixin.pm25
4 files changed, 38 insertions, 12 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 5c43b3a..d8fd545 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3601,7 +3601,7 @@ and customer address. Include units.',
{
'key' => 'batchconfig-paymentech',
'section' => 'billing',
- 'description' => 'Configuration for Chase Paymentech batching, five lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username, 5. Password (for batch uploads)',
+ 'description' => 'Configuration for Chase Paymentech batching, six lines: 1. BIN, 2. Terminal ID, 3. Merchant ID, 4. Username, 5. Password (for batch uploads), 6. Flag to send recurring indicator.',
'type' => 'textarea',
},
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index f9f90a7..c2f2ac5 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -170,15 +170,8 @@ sub _bop_recurring_billing {
} else {
- my %hash = ( 'custnum' => $self->custnum,
- 'payby' => 'CARD',
- );
-
- return 1
- if qsearch('cust_pay', { %hash, 'payinfo' => $opt{'payinfo'} } )
- || qsearch('cust_pay', { %hash, 'paymask' => $self->mask_payinfo('CARD',
- $opt{'payinfo'} )
- } );
+ # return 1 if the payinfo has been used for another payment
+ return $self->payinfo_used($opt{'payinfo'}); # in payinfo_Mixin
}
diff --git a/FS/FS/pay_batch/paymentech.pm b/FS/FS/pay_batch/paymentech.pm
index 2ac5a66..133f8f1 100644
--- a/FS/FS/pay_batch/paymentech.pm
+++ b/FS/FS/pay_batch/paymentech.pm
@@ -10,7 +10,7 @@ use Tie::IxHash;
use FS::Conf;
my $conf;
-my ($bin, $merchantID, $terminalID, $username);
+my ($bin, $merchantID, $terminalID, $username, $password, $with_recurringInd);
$name = 'paymentech';
my $gateway;
@@ -80,7 +80,7 @@ my %paytype = (
eval "use XML::Writer";
die $@ if $@;
my $conf = shift;
- ($bin, $terminalID, $merchantID, $username) =
+ ($bin, $terminalID, $merchantID, $username, $password, $with_recurringInd) =
$conf->config('batchconfig-paymentech');
},
# Here we do all the work in the header function.
@@ -99,6 +99,7 @@ my %paytype = (
foreach (@cust_pay_batch) {
$xml->startTag('newOrder', BatchRequestNo => $count++);
+ my $status = $_->cust_main->status;
tie my %order, 'Tie::IxHash', (
industryType => 'EC',
transType => 'AC',
@@ -124,6 +125,13 @@ my %paytype = (
orderID => $_->paybatchnum,
amount => $_->amount * 100,
);
+ # only do this if recurringInd is enabled in config,
+ # and the customer has at least one non-canceled recurring package
+ if ( $with_recurringInd and $status =~ /^active|suspended|ordered$/ ) {
+ # then send RF if this is the first payment on this payinfo,
+ # RS otherwise.
+ $order{'recurringInd'} = $_->payinfo_used ? 'RS' : 'RF';
+ }
foreach my $key (keys %order) {
$xml->dataElement($key, $order{$key})
}
diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm
index d03391f..7b713ef 100644
--- a/FS/FS/payinfo_Mixin.pm
+++ b/FS/FS/payinfo_Mixin.pm
@@ -3,6 +3,7 @@ package FS::payinfo_Mixin;
use strict;
use Business::CreditCard;
use FS::payby;
+use FS::Record qw(qsearch);
=head1 NAME
@@ -267,6 +268,30 @@ sub payby_payinfo_pretty {
}
}
+=item payinfo_used [ PAYINFO ]
+
+Returns 1 if there's an existing payment using this payinfo. This can be
+used to set the 'recurring payment' flag required by some processors.
+
+=cut
+
+sub payinfo_used {
+ my $self = shift;
+ my $payinfo = shift || $self->payinfo;
+ my %hash = (
+ 'custnum' => $self->custnum,
+ 'payby' => 'CARD',
+ );
+
+ return 1
+ if qsearch('cust_pay', { %hash, 'payinfo' => $payinfo } )
+ || qsearch('cust_pay',
+ { %hash, 'paymask' => $self->mask_payinfo('CARD', $payinfo) } )
+ ;
+
+ return 0;
+}
+
=back
=head1 BUGS