SubscriptionScheduleService.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 SubscriptionScheduleService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Retrieves the list of your subscription schedules.
  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\SubscriptionSchedule>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/subscription_schedules', $params, $opts);
  23. }
  24. /**
  25. * Cancels a subscription schedule and its associated subscription immediately (if
  26. * the subscription schedule has an active subscription). A subscription schedule
  27. * can only be canceled if its status is <code>not_started</code> or
  28. * <code>active</code>.
  29. *
  30. * @param string $id
  31. * @param null|array $params
  32. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  33. *
  34. * @throws \Stripe\Exception\ApiErrorException if the request fails
  35. *
  36. * @return \Stripe\SubscriptionSchedule
  37. */
  38. public function cancel($id, $params = null, $opts = null)
  39. {
  40. return $this->request('post', $this->buildPath('/v1/subscription_schedules/%s/cancel', $id), $params, $opts);
  41. }
  42. /**
  43. * Creates a new subscription schedule object. Each customer can have up to 500
  44. * active or scheduled subscriptions.
  45. *
  46. * @param null|array $params
  47. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  48. *
  49. * @throws \Stripe\Exception\ApiErrorException if the request fails
  50. *
  51. * @return \Stripe\SubscriptionSchedule
  52. */
  53. public function create($params = null, $opts = null)
  54. {
  55. return $this->request('post', '/v1/subscription_schedules', $params, $opts);
  56. }
  57. /**
  58. * Releases the subscription schedule immediately, which will stop scheduling of
  59. * its phases, but leave any existing subscription in place. A schedule can only be
  60. * released if its status is <code>not_started</code> or <code>active</code>. If
  61. * the subscription schedule is currently associated with a subscription, releasing
  62. * it will remove its <code>subscription</code> property and set the subscription’s
  63. * ID to the <code>released_subscription</code> property.
  64. *
  65. * @param string $id
  66. * @param null|array $params
  67. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  68. *
  69. * @throws \Stripe\Exception\ApiErrorException if the request fails
  70. *
  71. * @return \Stripe\SubscriptionSchedule
  72. */
  73. public function release($id, $params = null, $opts = null)
  74. {
  75. return $this->request('post', $this->buildPath('/v1/subscription_schedules/%s/release', $id), $params, $opts);
  76. }
  77. /**
  78. * Retrieves the details of an existing subscription schedule. You only need to
  79. * supply the unique subscription schedule identifier that was returned upon
  80. * subscription schedule creation.
  81. *
  82. * @param string $id
  83. * @param null|array $params
  84. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  85. *
  86. * @throws \Stripe\Exception\ApiErrorException if the request fails
  87. *
  88. * @return \Stripe\SubscriptionSchedule
  89. */
  90. public function retrieve($id, $params = null, $opts = null)
  91. {
  92. return $this->request('get', $this->buildPath('/v1/subscription_schedules/%s', $id), $params, $opts);
  93. }
  94. /**
  95. * Updates an existing subscription schedule.
  96. *
  97. * @param string $id
  98. * @param null|array $params
  99. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  100. *
  101. * @throws \Stripe\Exception\ApiErrorException if the request fails
  102. *
  103. * @return \Stripe\SubscriptionSchedule
  104. */
  105. public function update($id, $params = null, $opts = null)
  106. {
  107. return $this->request('post', $this->buildPath('/v1/subscription_schedules/%s', $id), $params, $opts);
  108. }
  109. }