PriceService.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 PriceService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of your active prices, excluding <a
  12. * href="/docs/products-prices/pricing-models#inline-pricing">inline prices</a>.
  13. * For the list of inactive prices, set <code>active</code> to false.
  14. *
  15. * @param null|array $params
  16. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  17. *
  18. * @throws \Stripe\Exception\ApiErrorException if the request fails
  19. *
  20. * @return \Stripe\Collection<\Stripe\Price>
  21. */
  22. public function all($params = null, $opts = null)
  23. {
  24. return $this->requestCollection('get', '/v1/prices', $params, $opts);
  25. }
  26. /**
  27. * Creates a new price for an existing product. The price can be recurring or
  28. * one-time.
  29. *
  30. * @param null|array $params
  31. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  32. *
  33. * @throws \Stripe\Exception\ApiErrorException if the request fails
  34. *
  35. * @return \Stripe\Price
  36. */
  37. public function create($params = null, $opts = null)
  38. {
  39. return $this->request('post', '/v1/prices', $params, $opts);
  40. }
  41. /**
  42. * Retrieves the price with the given ID.
  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\Price
  51. */
  52. public function retrieve($id, $params = null, $opts = null)
  53. {
  54. return $this->request('get', $this->buildPath('/v1/prices/%s', $id), $params, $opts);
  55. }
  56. /**
  57. * Search for prices you’ve previously created using Stripe’s <a
  58. * href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
  59. * search in read-after-write flows where strict consistency is necessary. Under
  60. * normal operating conditions, data is searchable in less than a minute.
  61. * Occasionally, propagation of new or updated data can be up to an hour behind
  62. * during outages. Search functionality is not available to merchants in India.
  63. *
  64. * @param null|array $params
  65. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  66. *
  67. * @throws \Stripe\Exception\ApiErrorException if the request fails
  68. *
  69. * @return \Stripe\SearchResult<\Stripe\Price>
  70. */
  71. public function search($params = null, $opts = null)
  72. {
  73. return $this->requestSearchResult('get', '/v1/prices/search', $params, $opts);
  74. }
  75. /**
  76. * Updates the specified price by setting the values of the parameters passed. Any
  77. * parameters not provided are left unchanged.
  78. *
  79. * @param string $id
  80. * @param null|array $params
  81. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  82. *
  83. * @throws \Stripe\Exception\ApiErrorException if the request fails
  84. *
  85. * @return \Stripe\Price
  86. */
  87. public function update($id, $params = null, $opts = null)
  88. {
  89. return $this->request('post', $this->buildPath('/v1/prices/%s', $id), $params, $opts);
  90. }
  91. }