summaryrefslogtreecommitdiff
path: root/FS/FS/ClientAPI/MyAccount.pm
diff options
context:
space:
mode:
Diffstat (limited to 'FS/FS/ClientAPI/MyAccount.pm')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 674785524..9983b5d26 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -18,6 +18,7 @@ FS::ClientAPI->register_handlers(
'MyAccount/login' => \&login,
'MyAccount/customer_info' => \&customer_info,
'MyAccount/invoice' => \&invoice,
+ 'MyAccount/cancel' => \&cancel,
);
#store in db?
@@ -133,4 +134,23 @@ sub invoice {
}
+sub cancel {
+ my $p = shift;
+ my $session = $cache->get($p->{'session_id'})
+ or return { 'error' => "Can't resume session" }; #better error message
+
+ my $custnum = $session->{'custnum'};
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my @errors = $cust_main->cancel;
+
+ my $error = scalar(@errors) ? join(' / ', @errors) : '';
+
+ return { 'error' => $error };
+
+}
+
+1;