InvoiceItemService.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 InvoiceItemService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of your invoice items. Invoice items are returned sorted by
  12. * creation date, with the most recently created invoice items appearing first.
  13. *
  14. * @param null|array $params
  15. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  16. *
  17. * @throws \Stripe\Exception\ApiErrorException if the request fails
  18. *
  19. * @return \Stripe\Collection<\Stripe\InvoiceItem>
  20. */
  21. public function all($params = null, $opts = null)
  22. {
  23. return $this->requestCollection('get', '/v1/invoiceitems', $params, $opts);
  24. }
  25. /**
  26. * Creates an item to be added to a draft invoice (up to 250 items per invoice). If
  27. * no invoice is specified, the item will be on the next invoice created for the
  28. * customer specified.
  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\InvoiceItem
  36. */
  37. public function create($params = null, $opts = null)
  38. {
  39. return $this->request('post', '/v1/invoiceitems', $params, $opts);
  40. }
  41. /**
  42. * Deletes an invoice item, removing it from an invoice. Deleting invoice items is
  43. * only possible when they’re not attached to invoices, or if it’s attached to a
  44. * draft invoice.
  45. *
  46. * @param string $id
  47. * @param null|array $params
  48. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  49. *
  50. * @throws \Stripe\Exception\ApiErrorException if the request fails
  51. *
  52. * @return \Stripe\InvoiceItem
  53. */
  54. public function delete($id, $params = null, $opts = null)
  55. {
  56. return $this->request('delete', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  57. }
  58. /**
  59. * Retrieves the invoice item with the given ID.
  60. *
  61. * @param string $id
  62. * @param null|array $params
  63. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  64. *
  65. * @throws \Stripe\Exception\ApiErrorException if the request fails
  66. *
  67. * @return \Stripe\InvoiceItem
  68. */
  69. public function retrieve($id, $params = null, $opts = null)
  70. {
  71. return $this->request('get', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  72. }
  73. /**
  74. * Updates the amount or description of an invoice item on an upcoming invoice.
  75. * Updating an invoice item is only possible before the invoice it’s attached to is
  76. * closed.
  77. *
  78. * @param string $id
  79. * @param null|array $params
  80. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  81. *
  82. * @throws \Stripe\Exception\ApiErrorException if the request fails
  83. *
  84. * @return \Stripe\InvoiceItem
  85. */
  86. public function update($id, $params = null, $opts = null)
  87. {
  88. return $this->request('post', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  89. }
  90. }