[freeside-commits] branch FREESIDE_3_BRANCH updated. 27ad9a232bbd0ac64091f3d0796fb836928bdb92

Jonathan Prykop jonathan at 420.am
Mon Oct 5 17:05:05 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  27ad9a232bbd0ac64091f3d0796fb836928bdb92 (commit)
       via  8db72ccbae1214657269f0eb8aceefe6e349b52c (commit)
       via  56a6c2354d5b02b89f48af3d5ddf78dd053ed01a (commit)
      from  a2dbfca9b10917eba6e8ec2231eb2cc764b886b2 (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 27ad9a232bbd0ac64091f3d0796fb836928bdb92
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 790135c..af29156 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -735,8 +735,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 8db72ccbae1214657269f0eb8aceefe6e349b52c
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 087f176..88b9ed6 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1107,37 +1107,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') {
@@ -1158,7 +1127,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 ) {
@@ -1166,18 +1135,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 56a6c2354d5b02b89f48af3d5ddf78dd053ed01a
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