summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-09-29 21:43:23 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-10-05 18:45:54 -0500
commita18182ff59f7fb7f45c335ea466d8d52555fdb08 (patch)
tree38acefb1197cf9a699f25170a6c63b56bcf6046b /FS
parent529abbc641917dad55e3eca31408a40f1439f496 (diff)
RT#38048: not storing credit card #s [save-first fix for selfservice]
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm71
1 files changed, 35 insertions, 36 deletions
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) {