[freeside-commits] branch FREESIDE_4_BRANCH updated. 536604504ef9e5ff239e2a96cf747977dd441ae3

Ivan ivan at 420.am
Wed Apr 26 13:15:11 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  536604504ef9e5ff239e2a96cf747977dd441ae3 (commit)
      from  50dc555d2f00db4da8e6878f0bde5117ed05a179 (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 536604504ef9e5ff239e2a96cf747977dd441ae3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Apr 26 13:15:10 2017 -0700

    add list_payments and payment_receipt self-service API calls, RT#75517

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.
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index 8f8871a..00f83bb 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -49,6 +49,8 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   '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',
@@ -600,6 +602,73 @@ Invoice date, in UNIX epoch time
 
 =back
 
+=item list_payments HASHREF
+
+Returns a list of all customer payments.  Takes a hash reference with a single
+key, session_id.
+
+Returns a hash reference with the following keys:
+
+=over 4
+
+=item error
+
+Empty on success, or an error message on errors
+
+=item payments
+
+Reference to array of hash references with the following keys:
+
+=over 4
+
+=item paynum
+
+Payment #
+
+=item _date
+
+Payument date, in UNIX epoch time
+
+=item date
+
+Payment date, in a human-readable format
+
+=item date_short
+
+Payment date, in a shorter human-readable format
+
+=item paid
+
+Amount paid
+
+=item payby
+
+Payment method: CARD, CHEK (electronic check), or BILL (physical check).
+
+=item paycardtype
+
+Payment card type
+
+=item paymask
+
+Payment card mask
+
+=item processor
+
+Processor for cards and electronic checks
+
+=item auth
+
+Authorization number
+
+=item order_number
+
+Order number
+
+=back
+
+=back
+
 =item list_payby HASHREF
 
 Returns a list of all stored customer payment information (credit cards and

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                 |   36 ++++++++++++++
 FS/FS/ClientAPI_XMLRPC.pm                    |    2 +
 FS/FS/cust_pay.pm                            |   24 +++++++++
 fs_selfservice/FS-SelfService/SelfService.pm |   69 ++++++++++++++++++++++++++
 4 files changed, 131 insertions(+)




More information about the freeside-commits mailing list