api/payments.js
function getAccountPayments(account, source_account, destination_account,
    direction, options, callback) {
  var self = this;

  function getTransactions(_callback) {
    var args = {
      account: account,
      source_account: source_account,
      destination_account: destination_account,
      direction: direction,
      min: options.results_per_page,
      max: options.results_per_page,
      offset: (options.results_per_page || DEFAULT_RESULTS_PER_PAGE)
              * ((options.page || 1) - 1),
      types: ['payment'],
      earliestFirst: options.earliest_first
    };

    transactions.getAccountTransactions(self,
      _.merge(options, args), _callback);
  }

  function formatTransactions(_transactions) {
    return _transactions.map(_.partial(formatPaymentHelper, account));
  }

  function attachResourceId(_transactions, _callback) {
    async.map(_transactions, function(paymentResult, async_map_callback) {
      var hash = paymentResult.hash;

      self.db.getTransaction({hash: hash}, function(error, db_entry) {
        if (error) {
          return async_map_callback(error);
        }
        var client_resource_id = '';
        if (db_entry && db_entry.client_resource_id) {
          client_resource_id = db_entry.client_resource_id;
        }

        paymentResult.client_resource_id = client_resource_id;

        async_map_callback(null, paymentResult);
      });
    }, _callback);
  }

  function formatResponse(_transactions) {
    return {payments: _transactions};
  }

  var steps = [
    getTransactions,
    _.partial(utils.attachDate, self),
    asyncify(formatTransactions),
    attachResourceId,
    asyncify(formatResponse)
  ];

  async.waterfall(steps, callback);
}
function getAccountPayments(account, source_account, destination_account,
    direction, options, callback) {
  var self = this;

  function getTransactions(_callback) {
    var args = {
      account: account,
      source_account: source_account,
      destination_account: destination_account,
      direction: direction,
      min: options.results_per_page,
      max: options.results_per_page,
      offset: (options.results_per_page || DEFAULT_RESULTS_PER_PAGE)
              * ((options.page || 1) - 1),
      types: ['payment'],
      earliestFirst: options.earliest_first
    };

    transactions.getAccountTransactions(self,
      _.merge(options, args), _callback);
  }

  function formatTransactions(_transactions) {
    return _transactions.map(_.partial(formatPaymentHelper, account));
  }

  function attachResourceId(_transactions, _callback) {
    async.map(_transactions, function(paymentResult, async_map_callback) {
      var hash = paymentResult.hash;

      self.db.getTransaction({hash: hash}, function(error, db_entry) {
        if (error) {
          return async_map_callback(error);
        }
        var client_resource_id = '';
        if (db_entry && db_entry.client_resource_id) {
          client_resource_id = db_entry.client_resource_id;
        }

        paymentResult.client_resource_id = client_resource_id;

        async_map_callback(null, paymentResult);
      });
    }, _callback);
  }

  function formatResponse(_transactions) {
    return {payments: _transactions};
  }

  var steps = [
    getTransactions,
    _.partial(utils.attachDate, self),
    asyncify(formatTransactions),
    attachResourceId,
    asyncify(formatResponse)
  ];

  async.waterfall(steps, callback);
}
function getAccountPayments ( account , source_account , destination_account , direction , options , callback ) { var self = this ; function getTransactions ( _callback ) { var args = { account : account , source_account : source_account , destination_account : destination_account , direction : direction , min : options . results_per_page , max : options . results_per_page , offset : ( options . results_per_page || DEFAULT_RESULTS_PER_PAGE ) * ( ( options . page || 1 ) - 1 ) , types : [ 'payment' ] , earliestFirst : options . earliest_first } ; transactions . getAccountTransactions ( self , _ . merge ( options , args ) , _callback ) ; } function formatTransactions ( _transactions ) { return _transactions . map ( _ . partial ( formatPaymentHelper , account ) ) ; } function attachResourceId ( _transactions , _callback ) { async . map ( _transactions , function ( paymentResult , async_map_callback ) { var hash = paymentResult . hash ; self . db . getTransaction ( { hash : hash } , function ( error , db_entry ) { if ( error ) { return async_map_callback ( error ) ; } var client_resource_id = '' ; if ( db_entry && db_entry . client_resource_id ) { client_resource_id = db_entry . client_resource_id ; } paymentResult . client_resource_id = client_resource_id ; async_map_callback ( null , paymentResult ) ; } ) ; } , _callback ) ; } function formatResponse ( _transactions ) { return { payments : _transactions } ; } var steps = [ getTransactions , _ . partial ( utils . attachDate , self ) , asyncify ( formatTransactions ) , attachResourceId , asyncify ( formatResponse ) ] ; async . waterfall ( steps , callback ) ; }
Retrieve the details of multiple payments from the Remote
and the local database.

This function calls transactions.getAccountTransactions
recursively to retrieve results_per_page number of transactions
and filters the results by type "payment", along with the other
client-specified parameters.

@param {Remote} remote
@param {/lib/db-interface} dbinterface
@param {RippleAddress} req.params.account
@param {RippleAddress} req.query.source_account
@param {RippleAddress} req.query.destination_account
@param {String "incoming"|"outgoing"} req.query.direction
@param {Number} [-1] req.query.start_ledger
@param {Number} [-1] req.query.end_ledger
@param {Boolean} [false] req.query.earliest_first
@param {Boolean} [false] req.query.exclude_failed
@param {Number} [20] req.query.results_per_page
@param {Number} [1] req.query.page
Retrieve the details of multiple payments from the Remote and the local database .