Payout.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* Copyright 2015-2016 PayPal, Inc. */
  2. "use strict";
  3. var generate = require('../generate');
  4. var api = require('../api');
  5. /**
  6. * Make payouts to multiple PayPal accounts, or multiple payments to same PayPal account
  7. * @return {Object} payout functions
  8. */
  9. function payout() {
  10. var baseURL = '/v1/payments/payouts/';
  11. var operations = ['get'];
  12. var ret = {
  13. baseURL: baseURL,
  14. /**
  15. * Create a batch(asynchronous) or single(synchronous) payout
  16. * @param {Object} data payout details
  17. * @param {String} sync_mode true for synchronous payouts, false by default
  18. * @param {Object|Function} config Configuration parameters e.g. client_id, client_secret override or callback
  19. * @param {Function} cb
  20. * @return {Object} Payout object
  21. */
  22. create: function create(data, sync_mode, config, cb) {
  23. cb = (typeof sync_mode === 'function') ? sync_mode : cb;
  24. sync_mode = (typeof sync_mode === 'string' && sync_mode === 'true') ? 'true' : 'false';
  25. api.executeHttp('POST', this.baseURL + "?" + "sync_mode=" + sync_mode, data, config, cb);
  26. }
  27. };
  28. ret = generate.mixin(ret, operations);
  29. return ret;
  30. }
  31. module.exports = payout;