[freeside-commits] branch FREESIDE_4_BRANCH updated. 23b0d9bf0da485662c257fda156cad40b99d9612

Jonathan Prykop jonathan at 420.am
Mon Oct 5 16:49:47 PDT 2015


The branch, FREESIDE_4_BRANCH has been updated
       via  23b0d9bf0da485662c257fda156cad40b99d9612 (commit)
       via  a18182ff59f7fb7f45c335ea466d8d52555fdb08 (commit)
       via  529abbc641917dad55e3eca31408a40f1439f496 (commit)
      from  ac092350a606dac185f249da7d9ad59a81a6bad9 (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 23b0d9bf0da485662c257fda156cad40b99d9612
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Sep 30 20:32:20 2015 -0500

    RT#38048: not storing credit card #s [no longer setting cust_main->card_token]

diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index fda3ae0..e08bdae 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -766,8 +766,6 @@ sub realtime_bop {
 
   if ( $transaction->can('card_token') && $transaction->card_token ) {
 
-    $self->card_token($transaction->card_token);
-
     if ( $options{'payinfo'} eq $self->payinfo ) {
       $self->payinfo($transaction->card_token);
       my $error = $self->replace;

commit a18182ff59f7fb7f45c335ea466d8d52555fdb08
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Sep 29 21:43:23 2015 -0500

    RT#38048: not storing credit card #s [save-first fix for selfservice]

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index b25064f..35cc829 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1141,37 +1141,6 @@ sub do_process_payment {
 
   my $payby = delete $validate->{'payby'};
 
-  my $error = $cust_main->realtime_bop( $FS::payby::payby2bop{$payby}, $amount,
-    'quiet'       => 1,
-    'manual'      => 1,
-    'selfservice' => 1,
-    'paynum_ref'  => \$paynum,
-    %$validate,
-  );
-  return { 'error' => $error } if $error;
-
-  #no error, so order the fee package if applicable...
-  my $conf = new FS::Conf;
-  my $fee_pkgpart = $conf->config('selfservice_process-pkgpart', $cust_main->agentnum);
-  my $fee_skip_first = $conf->exists('selfservice_process-skip_first');
-  
-  if ( $fee_pkgpart and ! $fee_skip_first || scalar($cust_main->cust_pay) ) {
-
-    my $cust_pkg = new FS::cust_pkg { 'pkgpart' => $fee_pkgpart };
-
-    $error = $cust_main->order_pkg( 'cust_pkg' => $cust_pkg );
-    return { 'error' => "payment processed successfully, but error ordering fee: $error" }
-      if $error;
-
-    #and generate an invoice for it now too
-    $error = $cust_main->bill( 'pkg_list' => [ $cust_pkg ] );
-    return { 'error' => "payment processed and fee ordered sucessfully, but error billing fee: $error" }
-      if $error;
-
-  }
-
-  $cust_main->apply_payments;
-
   if ( $validate->{'save'} ) {
     my $new = new FS::cust_main { $cust_main->hash };
     if ($payby eq 'CARD' || $payby eq 'DCRD') {
@@ -1192,7 +1161,7 @@ sub do_process_payment {
                     stateid stateid_state );
       $new->set( 'payby' => $validate->{'auto'} ? 'CHEK' : 'DCHK' );
     }
-    $new->set( 'payinfo' => $cust_main->card_token || $validate->{'payinfo'} );
+    $new->payinfo( $validate->{'payinfo'} ); #to properly set paymask
     $new->set( 'paydate' => $validate->{'paydate'} );
     my $error = $new->replace($cust_main);
     if ( $error ) {
@@ -1200,18 +1169,48 @@ sub do_process_payment {
       #return { 'error' => $error };
       #XXX just warn verosely for now so i can figure out how these happen in
       # the first place, eventually should redirect them to the "change
-      #address" page but indicate the payment did process??
+      #address" page but indicate if the payment processed?
       delete($validate->{'payinfo'}); #don't want to log this!
       warn "WARNING: error changing customer info when processing payment (not returning to customer as a processing error): $error\n".
            "NEW: ". Dumper($new)."\n".
            "OLD: ". Dumper($cust_main)."\n".
            "PACKET: ". Dumper($validate)."\n";
-    #} else {
-      #not needed...
-      #$cust_main = $new;
+    } else {
+      $cust_main = $new;
     }
   }
 
+  my $error = $cust_main->realtime_bop( $FS::payby::payby2bop{$payby}, $amount,
+    'quiet'       => 1,
+    'manual'      => 1,
+    'selfservice' => 1,
+    'paynum_ref'  => \$paynum,
+    %$validate,
+  );
+  return { 'error' => $error } if $error;
+
+  #no error, so order the fee package if applicable...
+  my $conf = new FS::Conf;
+  my $fee_pkgpart = $conf->config('selfservice_process-pkgpart', $cust_main->agentnum);
+  my $fee_skip_first = $conf->exists('selfservice_process-skip_first');
+  
+  if ( $fee_pkgpart and ! $fee_skip_first || scalar($cust_main->cust_pay) ) {
+
+    my $cust_pkg = new FS::cust_pkg { 'pkgpart' => $fee_pkgpart };
+
+    $error = $cust_main->order_pkg( 'cust_pkg' => $cust_pkg );
+    return { 'error' => "payment processed successfully, but error ordering fee: $error" }
+      if $error;
+
+    #and generate an invoice for it now too
+    $error = $cust_main->bill( 'pkg_list' => [ $cust_pkg ] );
+    return { 'error' => "payment processed and fee ordered sucessfully, but error billing fee: $error" }
+      if $error;
+
+  }
+
+  $cust_main->apply_payments;
+
   my $cust_pay = '';
   my $receipt_html = '';
   if ($paynum) {

commit 529abbc641917dad55e3eca31408a40f1439f496
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Sep 29 00:00:42 2015 -0500

    RT#38048 not storing credit card #s

diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi
index 27b8186..d9299e5 100644
--- a/httemplate/misc/process/payment.cgi
+++ b/httemplate/misc/process/payment.cgi
@@ -135,6 +135,45 @@ $cgi->param('discount_term') =~ /^(\d*)$/
   or errorpage("illegal discount_term");
 my $discount_term = $1;
 
+# save first, for proper tokenization later
+if ( $cgi->param('save') ) {
+  my $new = new FS::cust_main { $cust_main->hash };
+  if ( $payby eq 'CARD' ) { 
+    $new->set( 'payby' => ( $cgi->param('auto') ? 'CARD' : 'DCRD' ) );
+  } elsif ( $payby eq 'CHEK' ) {
+    $new->set( 'payby' => ( $cgi->param('auto') ? 'CHEK' : 'DCHK' ) );
+  } else {
+    die "unknown payby $payby";
+  }
+  $new->payinfo($payinfo); #to properly set paymask
+  $new->set( 'paydate' => "$year-$month-01" );
+  $new->set( 'payname' => $payname );
+
+  #false laziness w/FS:;cust_main::realtime_bop - check both to make sure
+  # working correctly
+  if ( $payby eq 'CARD' &&
+       grep { $_ eq cardtype($payinfo) } $conf->config('cvv-save') ) {
+    $new->set( 'paycvv' => $paycvv );
+  } else {
+    $new->set( 'paycvv' => '');
+  }
+
+  if ( $payby eq 'CARD' ) {
+    my $bill_location = FS::cust_location->new;
+    $bill_location->set( $_ => $cgi->param($_) )
+      foreach @{$payby2fields{$payby}};
+    $new->set('bill_location' => $bill_location);
+    # will do nothing if the fields are all unchanged
+  } else {
+    $new->set( $_ => $cgi->param($_) ) foreach @{$payby2fields{$payby}};
+  }
+
+  my $error = $new->replace($cust_main);
+  errorpage("error saving info, payment not processed: $error")
+    if $error;
+  $cust_main = $new;
+}
+
 my $error = '';
 my $paynum = '';
 if ( $cgi->param('batch') ) {
@@ -190,44 +229,6 @@ if ( $cgi->param('batch') ) {
 
 }
 
-if ( $cgi->param('save') ) {
-  my $new = new FS::cust_main { $cust_main->hash };
-  if ( $payby eq 'CARD' ) { 
-    $new->set( 'payby' => ( $cgi->param('auto') ? 'CARD' : 'DCRD' ) );
-  } elsif ( $payby eq 'CHEK' ) {
-    $new->set( 'payby' => ( $cgi->param('auto') ? 'CHEK' : 'DCHK' ) );
-  } else {
-    die "unknown payby $payby";
-  }
-  $new->set( 'payinfo' => $cust_main->card_token || $payinfo );
-  $new->set( 'paydate' => "$year-$month-01" );
-  $new->set( 'payname' => $payname );
-
-  #false laziness w/FS:;cust_main::realtime_bop - check both to make sure
-  # working correctly
-  if ( $payby eq 'CARD' &&
-       grep { $_ eq cardtype($payinfo) } $conf->config('cvv-save') ) {
-    $new->set( 'paycvv' => $paycvv );
-  } else {
-    $new->set( 'paycvv' => '');
-  }
-
-  if ( $payby eq 'CARD' ) {
-    my $bill_location = FS::cust_location->new;
-    $bill_location->set( $_ => $cgi->param($_) )
-      foreach @{$payby2fields{$payby}};
-    $new->set('bill_location' => $bill_location);
-    # will do nothing if the fields are all unchanged
-  } else {
-    $new->set( $_ => $cgi->param($_) ) foreach @{$payby2fields{$payby}};
-  }
-
-  my $error = $new->replace($cust_main);
-  errorpage("payment processed successfully, but error saving info: $error")
-    if $error;
-  $cust_main = $new;
-}
-
 #success!
 
 </%init>

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm        |   71 ++++++++++++++++----------------
 FS/FS/cust_main/Billing_Realtime.pm |    2 -
 httemplate/misc/process/payment.cgi |   77 ++++++++++++++++++-----------------
 3 files changed, 74 insertions(+), 76 deletions(-)




More information about the freeside-commits mailing list