SessionService.php 2.9 KB

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