PlanService.php 2.9 KB

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