[freeside-commits] branch FREESIDE_3_BRANCH_71513 updated. 2e28dbd1a28f60d714a272be5c29b56bc079142d

Jonathan Prykop jonathan at 420.am
Tue Jan 3 21:06:40 PST 2017


The branch, FREESIDE_3_BRANCH_71513 has been updated
       via  2e28dbd1a28f60d714a272be5c29b56bc079142d (commit)
       via  a1f5ae700fef217160ca7aca669ca37abb1f9b7f (commit)
       via  4d79aed4700a31d339bef938e4b2490ff8f2b9ec (commit)
      from  2a565ea54a0af5f32ac26804be62249effa958bf (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 2e28dbd1a28f60d714a272be5c29b56bc079142d
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jan 3 23:05:34 2017 -0600

    71513: Card tokenization [v3 test tweak]

diff --git a/FS/t/suite/13-tokenization.t b/FS/t/suite/13-tokenization.t
index 019b61c..a7226e6 100755
--- a/FS/t/suite/13-tokenization.t
+++ b/FS/t/suite/13-tokenization.t
@@ -30,10 +30,10 @@ ok( !$err, 'schema upgrade' ) or BAIL_OUT('Error string: '.$!);
 # some pre-upgrade cleanup, upgrade will fail if these are still configured
 foreach my $cust_main ( $fs->qsearch('cust_main') ) {
   my @count = $fs->qsearch('agent_payment_gateway', { agentnum => $cust_main->agentnum } );
-  if (@count > 1) {
+  if (@count > 0) {
     note("DELETING CARDTYPE GATEWAYS");
     foreach my $apg (@count) {
-      $err = $apg->delete if $apg->cardtype;
+      $err = $apg->delete;
       last if $err;
     }
     @count = $fs->qsearch('agent_payment_gateway', { agentnum => $cust_main->agentnum } );

commit a1f5ae700fef217160ca7aca669ca37abb1f9b7f
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jan 3 17:33:26 2017 -0600

    71513: Card tokenization [banned_pay tweaks, v3 merge]

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index a4622f5..3e7a5fb 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -364,7 +364,6 @@ sub realtime_bop {
     $options{amount} = $amount;
   }
 
-
   ### 
   # optional credit card surcharge
   ###
@@ -403,6 +402,13 @@ sub realtime_bop {
 
   $self->_bop_defaults(\%options);
 
+  # check for banned credit card/ACH
+  my $ban = FS::banned_pay->ban_search(
+    'payby'   => $bop_method2payby{$options{method}},
+    'payinfo' => $options{payinfo},
+  );
+  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
+
   # possibly run a separate transaction to tokenize card number,
   #   so that we never store tokenized card info in cust_pay_pending
   if (($options{method} eq 'CC') && !$self->tokenized($options{'payinfo'})) {
@@ -448,16 +454,6 @@ sub realtime_bop {
   die $@ if $@;
 
   ###
-  # check for banned credit card/ACH
-  ###
-
-  my $ban = FS::banned_pay->ban_search(
-    'payby'   => $bop_method2payby{$options{method}},
-    'payinfo' => $options{payinfo},
-  );
-  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
-
-  ###
   # check for term discount validity
   ###
 
@@ -1801,6 +1797,13 @@ sub realtime_verify_bop {
     warn "  $_ => $options{$_}\n" foreach keys %options;
   }
 
+  # check for banned credit card/ACH
+  my $ban = FS::banned_pay->ban_search(
+    'payby'   => $bop_method2payby{'CC'},
+    'payinfo' => $options{payinfo},
+  );
+  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
+
   # possibly run a separate transaction to tokenize card number,
   #   so that we never store tokenized card info in cust_pay_pending
   if (($options{method} eq 'CC') && !$self->tokenized($options{'payinfo'})) {
@@ -1821,16 +1824,6 @@ sub realtime_verify_bop {
   die $@ if $@;
 
   ###
-  # check for banned credit card/ACH
-  ###
-
-  my $ban = FS::banned_pay->ban_search(
-    'payby'   => $bop_method2payby{'CC'},
-    'payinfo' => $options{payinfo} || $self->payinfo,
-  );
-  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
-
-  ###
   # massage data
   ###
 
@@ -2257,6 +2250,13 @@ sub realtime_tokenize {
   return '' unless $options{method} eq 'CC';
   return '' if FS::payinfo_Mixin->tokenized($options{payinfo}); #already tokenized
 
+  # check for banned credit card/ACH
+  my $ban = FS::banned_pay->ban_search(
+    'payby'   => $bop_method2payby{'CC'},
+    'payinfo' => $options{payinfo},
+  );
+  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
+
   ###
   # select a gateway
   ###
@@ -2284,16 +2284,6 @@ sub realtime_tokenize {
   return '' unless $supported_actions{'CC'} and grep(/^Tokenize$/,@{$supported_actions{'CC'}});
 
   ###
-  # check for banned credit card/ACH
-  ###
-
-  my $ban = FS::banned_pay->ban_search(
-    'payby'   => $bop_method2payby{'CC'},
-    'payinfo' => $options{payinfo},
-  );
-  return "Banned credit card" if $ban && $ban->bantype ne 'warn';
-
-  ###
   # massage data
   ###
 

commit 4d79aed4700a31d339bef938e4b2490ff8f2b9ec
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Dec 28 13:56:31 2016 -0600

    71513: Card tokenization [undid refund always sending token, skip token_check if nothing is tokenizable]

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 453cd71..a4622f5 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -1598,12 +1598,6 @@ sub realtime_refund_bop {
         $content{'name'} = $self->get('first'). ' '. $self->get('last');
       }
     }
-    if ( $cust_pay->payby eq 'CARD'
-         && !$content{'card_number'}
-         && $cust_pay->tokenized
-    ) {
-      $content{'card_token'} = $cust_pay->payinfo;
-    }
     $void->content( 'action' => 'void', %content );
     $void->test_transaction(1)
       if $conf->exists('business-onlinepayment-test_transaction');
@@ -2423,8 +2417,9 @@ sub token_check {
 
   my $cache = {}; #cache for module info
 
-  # look for a gateway that can't tokenize
+  # look for a gateway that can and can't tokenize
   my $require_tokenized = 1;
+  my $someone_tokenizing = 0;
   foreach my $gateway (
     FS::payment_gateway->all_gateways(
       'method'  => 'CC',
@@ -2436,18 +2431,26 @@ sub token_check {
       # no default gateway, no promise to tokenize
       # can just load other gateways as-needeed below
       $require_tokenized = 0;
-      last;
+      last if $someone_tokenizing;
+      next;
     }
     my $info = _token_check_gateway_info($cache,$gateway);
     die $info unless ref($info); # means it's an error message
-    unless ($info->{'can_tokenize'}) {
+    if ($info->{'can_tokenize'}) {
+      $someone_tokenizing = 1;
+    } else {
       # a configured gateway can't tokenize, that's all we need to know right now
       # can just load other gateways as-needeed below
       $require_tokenized = 0;
-      last;
+      last if $someone_tokenizing;
     }
   }
 
+  unless ($someone_tokenizing) { #no need to check, if no one can tokenize
+    warn "no gateways tokenize\n" if $debug;
+    return;
+  }
+
   warn "REQUIRE TOKENIZED" if $require_tokenized && $debug;
 
   # upgrade does not call this with autocommit turned on,

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

Summary of changes:
 FS/FS/cust_main/Billing_Realtime.pm |   75 ++++++++++++++++-------------------
 FS/t/suite/13-tokenization.t        |    4 +-
 2 files changed, 36 insertions(+), 43 deletions(-)




More information about the freeside-commits mailing list