SessionService.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service\Checkout;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class SessionService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of Checkout Sessions.
  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\Checkout\Session>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/checkout/sessions', $params, $opts);
  23. }
  24. /**
  25. * When retrieving a Checkout Session, there is an includable
  26. * <strong>line_items</strong> property containing the first handful of those
  27. * items. There is also a URL where you can retrieve the full (paginated) list of
  28. * line items.
  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\Collection<\Stripe\LineItem>
  37. */
  38. public function allLineItems($id, $params = null, $opts = null)
  39. {
  40. return $this->requestCollection('get', $this->buildPath('/v1/checkout/sessions/%s/line_items', $id), $params, $opts);
  41. }
  42. /**
  43. * Creates a Session object.
  44. *
  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\Checkout\Session
  51. */
  52. public function create($params = null, $opts = null)
  53. {
  54. return $this->request('post', '/v1/checkout/sessions', $params, $opts);
  55. }
  56. /**
  57. * A Session can be expired when it is in one of these statuses: <code>open</code>.
  58. *
  59. * After it expires, a customer can’t complete a Session and customers loading the
  60. * Session see a message saying the Session is expired.
  61. *
  62. * @param string $id
  63. * @param null|array $params
  64. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  65. *
  66. * @throws \Stripe\Exception\ApiErrorException if the request fails
  67. *
  68. * @return \Stripe\Checkout\Session
  69. */
  70. public function expire($id, $params = null, $opts = null)
  71. {
  72. return $this->request('post', $this->buildPath('/v1/checkout/sessions/%s/expire', $id), $params, $opts);
  73. }
  74. /**
  75. * Retrieves a Session object.
  76. *
  77. * @param string $id
  78. * @param null|array $params
  79. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  80. *
  81. * @throws \Stripe\Exception\ApiErrorException if the request fails
  82. *
  83. * @return \Stripe\Checkout\Session
  84. */
  85. public function retrieve($id, $params = null, $opts = null)
  86. {
  87. return $this->request('get', $this->buildPath('/v1/checkout/sessions/%s', $id), $params, $opts);
  88. }
  89. }