OrderService.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class OrderService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of your orders. The orders are returned sorted by creation date,
  8. * with the most recently created orders appearing first.
  9. *
  10. * @param null|array $params
  11. * @param null|array|\Stripe\Util\RequestOptions $opts
  12. *
  13. * @throws \Stripe\Exception\ApiErrorException if the request fails
  14. *
  15. * @return \Stripe\Collection
  16. */
  17. public function all($params = null, $opts = null)
  18. {
  19. return $this->requestCollection('get', '/v1/orders', $params, $opts);
  20. }
  21. /**
  22. * Creates a new order object.
  23. *
  24. * @param null|array $params
  25. * @param null|array|\Stripe\Util\RequestOptions $opts
  26. *
  27. * @throws \Stripe\Exception\ApiErrorException if the request fails
  28. *
  29. * @return \Stripe\Order
  30. */
  31. public function create($params = null, $opts = null)
  32. {
  33. return $this->request('post', '/v1/orders', $params, $opts);
  34. }
  35. /**
  36. * Pay an order by providing a <code>source</code> to create a payment.
  37. *
  38. * @param string $id
  39. * @param null|array $params
  40. * @param null|array|\Stripe\Util\RequestOptions $opts
  41. *
  42. * @throws \Stripe\Exception\ApiErrorException if the request fails
  43. *
  44. * @return \Stripe\Order
  45. */
  46. public function pay($id, $params = null, $opts = null)
  47. {
  48. return $this->request('post', $this->buildPath('/v1/orders/%s/pay', $id), $params, $opts);
  49. }
  50. /**
  51. * Retrieves the details of an existing order. Supply the unique order ID from
  52. * either an order creation request or the order list, and Stripe will return the
  53. * corresponding order information.
  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\Order
  62. */
  63. public function retrieve($id, $params = null, $opts = null)
  64. {
  65. return $this->request('get', $this->buildPath('/v1/orders/%s', $id), $params, $opts);
  66. }
  67. /**
  68. * Return all or part of an order. The order must have a status of
  69. * <code>paid</code> or <code>fulfilled</code> before it can be returned. Once all
  70. * items have been returned, the order will become <code>canceled</code> or
  71. * <code>returned</code> depending on which status the order started in.
  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\Order
  80. */
  81. public function returnOrder($id, $params = null, $opts = null)
  82. {
  83. return $this->request('post', $this->buildPath('/v1/orders/%s/returns', $id), $params, $opts);
  84. }
  85. /**
  86. * Updates the specific order by setting the values of the parameters passed. Any
  87. * parameters not provided will be left unchanged.
  88. *
  89. * @param string $id
  90. * @param null|array $params
  91. * @param null|array|\Stripe\Util\RequestOptions $opts
  92. *
  93. * @throws \Stripe\Exception\ApiErrorException if the request fails
  94. *
  95. * @return \Stripe\Order
  96. */
  97. public function update($id, $params = null, $opts = null)
  98. {
  99. return $this->request('post', $this->buildPath('/v1/orders/%s', $id), $params, $opts);
  100. }
  101. }