BillingPlan.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* Copyright 2015-2016 PayPal, Inc. */
  2. "use strict";
  3. var generate = require('../generate');
  4. var api = require('../api');
  5. /**
  6. * Create planned sets of future recurring payments at periodic intervals (sometimes known as “subscriptions”).
  7. * @return {Object} billing plan functions
  8. */
  9. function billingPlan() {
  10. var baseURL = '/v1/payments/billing-plans/';
  11. var operations = ['create', 'get', 'list', 'update'];
  12. var ret = {
  13. baseURL: baseURL,
  14. /**
  15. * Activate a billing plan so that it can be used to form
  16. * billing agreements with users
  17. * @param {String} id Billing plan identifier
  18. * @param {Object|Function} config Configuration parameters e.g. client_id, client_secret override or callback
  19. * @param {Function} cb
  20. * @return {} Returns the HTTP status of 200 if the call is successful
  21. */
  22. activate: function activate(id, config, cb) {
  23. var activate_attributes = [
  24. {
  25. "op": "replace",
  26. "path": "/",
  27. "value": {
  28. "state": "ACTIVE"
  29. }
  30. }
  31. ];
  32. api.executeHttp('PATCH', this.baseURL + id, activate_attributes, config, cb);
  33. }
  34. };
  35. ret = generate.mixin(ret, operations);
  36. return ret;
  37. }
  38. module.exports = billingPlan;