diff options
author | Ivan Kohler <ivan@freeside.biz> | 2017-04-26 13:15:10 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2017-04-26 13:15:10 -0700 |
commit | 536604504ef9e5ff239e2a96cf747977dd441ae3 (patch) | |
tree | bed67b163dada87a65fcfa0b3cc11b2469518aaf /FS/FS | |
parent | 50dc555d2f00db4da8e6878f0bde5117ed05a179 (diff) |
add list_payments and payment_receipt self-service API calls, RT#75517
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/ClientAPI/MyAccount.pm | 36 | ||||
-rw-r--r-- | FS/FS/ClientAPI_XMLRPC.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 24 |
3 files changed, 62 insertions, 0 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 8072006..7df481e 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -1589,6 +1589,42 @@ sub list_invoices { }; } +sub list_payments { + 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" }; + + return { 'error' => '', + 'balance' => $cust_main->balance, + 'money_char' => FS::Conf->new->config("money_char") || '$', + 'payments' => [ map $_->SSAPI_getinfo, $cust_main->cust_pay ], + }; +} + +sub payment_receipt { + 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_pay = qsearchs('cust_pay', { 'custnum' => $custnum, + 'paynum' => $p->{'paynum'}, + } + ) + or return { 'error' => "unknown payment ". $p->{'paynum'} }; + + return { + 'error' => '', + %{ $cust_pay->SSAPI_getinfo }, + }; +} + sub list_payby { my $p = shift; diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm index e69a06e..2d8856a 100644 --- a/FS/FS/ClientAPI_XMLRPC.pm +++ b/FS/FS/ClientAPI_XMLRPC.pm @@ -128,6 +128,8 @@ sub ss2clientapi { 'legacy_invoice_pdf' => 'MyAccount/legacy_invoice_pdf', 'invoice_logo' => 'MyAccount/invoice_logo', 'list_invoices' => 'MyAccount/list_invoices', #? + 'list_payments' => 'MyAccount/list_payments', + 'payment_receipt' => 'MyAccount/payment_receipt', 'list_payby' => 'MyAccount/list_payby', 'insert_payby' => 'MyAccount/insert_payby', 'update_payby' => 'MyAccount/update_payby', diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 64ce7ec..8b5e06d 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -1071,6 +1071,30 @@ sub API_getinfo { }; } +=item SSAPI_getinfo + +=cut + +sub SSAPI_getinfo { + #my( $self, %opt ) = @_; + my $self = shift; + + +{ 'paynum' => $self->paynum, + '_date' => $self->_date, + 'date' => time2str("%b %o, %Y", $self->_date), + 'date_short' => time2str("%m-%d-%Y", $self->_date), + 'paid' => sprintf('%.2f', $self->paid), + 'payby' => $self->payby, + 'paycardtype' => $self->paycardtype, + 'paymask' => $self->paymask, + 'processor' => $self->processor, + 'auth' => $self->auth, + 'order_number' => $self->order_number, + }; + +} + + # _upgrade_data # # Used by FS::Upgrade to migrate to a new database. |