PlanService.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class PlanService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of your plans.
  8. *
  9. * @param null|array $params
  10. * @param null|array|\Stripe\Util\RequestOptions $opts
  11. *
  12. * @throws \Stripe\Exception\ApiErrorException if the request fails
  13. *
  14. * @return \Stripe\Collection
  15. */
  16. public function all($params = null, $opts = null)
  17. {
  18. return $this->requestCollection('get', '/v1/plans', $params, $opts);
  19. }
  20. /**
  21. * You can now model subscriptions more flexibly using the <a href="#prices">Prices
  22. * API</a>. It replaces the Plans API and is backwards compatible to simplify your
  23. * migration.
  24. *
  25. * @param null|array $params
  26. * @param null|array|\Stripe\Util\RequestOptions $opts
  27. *
  28. * @throws \Stripe\Exception\ApiErrorException if the request fails
  29. *
  30. * @return \Stripe\Plan
  31. */
  32. public function create($params = null, $opts = null)
  33. {
  34. return $this->request('post', '/v1/plans', $params, $opts);
  35. }
  36. /**
  37. * Deleting plans means new subscribers can’t be added. Existing subscribers aren’t
  38. * affected.
  39. *
  40. * @param string $id
  41. * @param null|array $params
  42. * @param null|array|\Stripe\Util\RequestOptions $opts
  43. *
  44. * @throws \Stripe\Exception\ApiErrorException if the request fails
  45. *
  46. * @return \Stripe\Plan
  47. */
  48. public function delete($id, $params = null, $opts = null)
  49. {
  50. return $this->request('delete', $this->buildPath('/v1/plans/%s', $id), $params, $opts);
  51. }
  52. /**
  53. * Retrieves the plan with the given ID.
  54. *
  55. * @param string $id
  56. * @param null|array $params
  57. * @param null|array|\Stripe\Util\RequestOptions $opts
  58. *
  59. * @throws \Stripe\Exception\ApiErrorException if the request fails
  60. *
  61. * @return \Stripe\Plan
  62. */
  63. public function retrieve($id, $params = null, $opts = null)
  64. {
  65. return $this->request('get', $this->buildPath('/v1/plans/%s', $id), $params, $opts);
  66. }
  67. /**
  68. * Updates the specified plan by setting the values of the parameters passed. Any
  69. * parameters not provided are left unchanged. By design, you cannot change a
  70. * plan’s ID, amount, currency, or billing cycle.
  71. *
  72. * @param string $id
  73. * @param null|array $params
  74. * @param null|array|\Stripe\Util\RequestOptions $opts
  75. *
  76. * @throws \Stripe\Exception\ApiErrorException if the request fails
  77. *
  78. * @return \Stripe\Plan
  79. */
  80. public function update($id, $params = null, $opts = null)
  81. {
  82. return $this->request('post', $this->buildPath('/v1/plans/%s', $id), $params, $opts);
  83. }
  84. }