summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-10-03 11:15:51 -0400
committerChristopher Burger <burgerc@freeside.biz>2017-10-06 10:16:23 -0400
commitddc96f96d3e8cf5239bbedad2c2067e80eaa02f2 (patch)
tree71fc32b2548519049beb9219c8698035bdeb8a8b
parent576f6400095474dc9d2ba5fb4c01f90af16cd037 (diff)
RT# 77193 - updated selfservice change payment accounts to work with version 4
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm1
-rw-r--r--fs_selfservice/FS-SelfService/cgi/myaccount_menu.html7
-rwxr-xr-xfs_selfservice/FS-SelfService/cgi/selfservice.cgi87
3 files changed, 80 insertions, 15 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index a10a452..30ab96b 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -882,6 +882,7 @@ sub payment_info {
if ($cust_payby) {
$return{payname} = $cust_payby->payname
|| ( $cust_main->first. ' '. $cust_main->get('last') );
+ $return{custpaybynum} = $cust_payby->custpaybynum;
if ( $cust_payby->payby =~ /^(CARD|DCRD)$/ ) {
$return{card_type} = cardtype($cust_payby->payinfo);
diff --git a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
index 6af5e5e..1bc35e3 100644
--- a/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
+++ b/fs_selfservice/FS-SelfService/cgi/myaccount_menu.html
@@ -93,9 +93,10 @@ push @menu,
unless ( $access_pkgnum ) {
push @menu,
- { title=>'Change billing address', url=>'change_bill', indent=>2 },
- { title=>'Change service address', url=>'change_ship', indent=>2 },
- { title=>'Change payment information', url=>'change_pay', indent=>2 },
+ { title=>'Change billing address', url=>'change_bill', indent=>2 },
+ { title=>'Change service address', url=>'change_ship', indent=>2 },
+ { title=>'Change credit card information', url=>'change_creditcard_pay', indent=>2 },
+ { title=>'Change check information', url=>'change_check_pay', indent=>2 },
;
}
diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
index cd9e32c..f194746 100755
--- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
+++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi
@@ -12,8 +12,8 @@ use Date::Format;
use Date::Parse 'str2time';
use Number::Format 1.50;
use FS::SelfService qw(
- access_info login_info login customer_info edit_info invoice
- payment_info process_payment realtime_collect process_prepay
+ access_info login_info login customer_info edit_info insert_payby update_payby
+ invoice payment_info process_payment realtime_collect process_prepay
list_pkgs order_pkg signup_info order_recharge
part_svc_info provision_acct provision_external provision_phone provision_forward
unprovision_svc change_pkg suspend_pkg domainselector
@@ -59,6 +59,10 @@ my @actions = ( qw(
change_bill
change_ship
change_pay
+ change_creditcard_pay
+ change_check_pay
+ process_change_creditcard_pay
+ process_change_check_pay
process_change_bill
process_change_ship
process_change_pay
@@ -261,19 +265,30 @@ sub myaccount {
customer_info( 'session_id' => $session_id );
}
-sub change_bill { my $payment_info =
- payment_info( 'session_id' => $session_id );
- return $payment_info if ( $payment_info->{'error'} );
- my $customer_info =
- customer_info( 'session_id' => $session_id );
- return {
- %$payment_info,
- %$customer_info,
- };
- }
+sub change_bill {
+ my $payby = shift;
+ my $payment_info;
+ if ($payby) {
+ $payment_info = payment_info( 'session_id' => $session_id, 'payment_payby' => $payby, );
+ }
+ else {
+ $payment_info = payment_info( 'session_id' => $session_id, );
+ }
+
+ return $payment_info if ( $payment_info->{'error'} );
+ my $customer_info =
+ customer_info( 'session_id' => $session_id );
+ return {
+ %$payment_info,
+ %$customer_info,
+ };
+}
sub change_ship { change_bill(@_); }
sub change_pay { change_bill(@_); }
+sub change_creditcard_pay { change_bill('CARD'); }
+sub change_check_pay { change_bill('CHEK'); }
+
sub _process_change_info {
my ($erroraction, @fields) = @_;
@@ -298,6 +313,30 @@ sub _process_change_info {
}
}
+sub _process_change_payby {
+ my ($erroraction, @fields) = @_;
+
+ my $results = '';
+
+ $results ||= update_payby (
+ 'session_id' => $session_id,
+ map { ($_ => $cgi->param($_)) } grep { defined($cgi->param($_)) } @fields,
+ );
+
+
+ if ( $results->{'error'} ) {
+ no strict 'refs';
+ $action = $erroraction;
+ return {
+ $cgi->Vars,
+ %{&$action()},
+ 'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+ };
+ } else {
+ return $results;
+ }
+}
+
sub process_change_bill {
_process_change_info( 'change_bill',
qw( first last company address1 address2 city state
@@ -342,6 +381,30 @@ sub process_change_pay {
_process_change_info( 'change_pay', @list );
}
+sub process_change_creditcard_pay {
+ my $payby = $cgi->param( 'payby' );
+ $cgi->param('paydate', $cgi->param('year') . '-' . $cgi->param('month') . '-01');
+ my @list =
+ qw( payby payinfo payinfo1 payinfo2 paydate payname custpaybynum
+ address1 address2 city county state zip country auto paytype
+ paystate ss stateid stateid_state invoicing_list
+ );
+
+ _process_change_payby( 'change_creditcard_pay', @list );
+}
+
+sub process_change_check_pay {
+ my $payby = $cgi->param( 'payby' );
+ $cgi->param('paydate', $cgi->param('year') . '-' . $cgi->param('month') . '-01');
+ my @list =
+ qw( payby payinfo payinfo1 payinfo2 paydate payname custpaybynum
+ address1 address2 city county state zip country auto paytype
+ paystate ss stateid stateid_state invoicing_list
+ );
+
+ _process_change_payby( 'change_check_pay', @list );
+}
+
sub view_invoice {
$cgi->param('invnum') =~ /^(\d+)$/ or die "illegal invnum";