[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 80c01e2aff2fe380ab74ca04606e42e3a360b634

Mark Wells mark at 420.am
Fri Oct 19 12:52:02 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  80c01e2aff2fe380ab74ca04606e42e3a360b634 (commit)
       via  c4ecb739ba059ce14ec7c3c8889e0fbbe31334bb (commit)
      from  c84159b64f322a6c32a9ec77e7e63beb4a5f6c19 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 80c01e2aff2fe380ab74ca04606e42e3a360b634
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Oct 19 12:49:14 2012 -0700

    recurring indicator for Paymentech batches, #19571

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 58afe7a..7a3a10b 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -3480,7 +3480,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 364d4a7..d2c0975 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -167,15 +167,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 f22a80f..9c1f5d2 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

commit c4ecb739ba059ce14ec7c3c8889e0fbbe31334bb
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Oct 19 12:04:31 2012 -0700

    fix typo

diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index c1728c0..a4947ae 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -1128,7 +1128,7 @@ sub paid_sql {
   my $paid = "( SELECT COALESCE(SUM(cust_bill_pay_pkg.amount),0)
      FROM cust_bill_pay_pkg JOIN cust_bill_pay USING (billpaynum)
      WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum
-           $s $e$setuprecur )";
+           $s $e $setuprecur )";
 
   if ( $opt{no_usage} ) {
     # cap the amount paid at the sum of non-usage charges, 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                       |    2 +-
 FS/FS/cust_bill_pkg.pm              |    2 +-
 FS/FS/cust_main/Billing_Realtime.pm |   11 ++---------
 FS/FS/pay_batch/paymentech.pm       |   12 ++++++++++--
 FS/FS/payinfo_Mixin.pm              |   25 +++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 13 deletions(-)




More information about the freeside-commits mailing list