InvoiceItemService.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class InvoiceItemService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of your invoice items. Invoice items are returned sorted by
  8. * creation date, with the most recently created invoice items 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/invoiceitems', $params, $opts);
  20. }
  21. /**
  22. * Creates an item to be added to a draft invoice (up to 250 items per invoice). If
  23. * no invoice is specified, the item will be on the next invoice created for the
  24. * customer specified.
  25. *
  26. * @param null|array $params
  27. * @param null|array|\Stripe\Util\RequestOptions $opts
  28. *
  29. * @throws \Stripe\Exception\ApiErrorException if the request fails
  30. *
  31. * @return \Stripe\InvoiceItem
  32. */
  33. public function create($params = null, $opts = null)
  34. {
  35. return $this->request('post', '/v1/invoiceitems', $params, $opts);
  36. }
  37. /**
  38. * Deletes an invoice item, removing it from an invoice. Deleting invoice items is
  39. * only possible when they’re not attached to invoices, or if it’s attached to a
  40. * draft invoice.
  41. *
  42. * @param string $id
  43. * @param null|array $params
  44. * @param null|array|\Stripe\Util\RequestOptions $opts
  45. *
  46. * @throws \Stripe\Exception\ApiErrorException if the request fails
  47. *
  48. * @return \Stripe\InvoiceItem
  49. */
  50. public function delete($id, $params = null, $opts = null)
  51. {
  52. return $this->request('delete', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  53. }
  54. /**
  55. * Retrieves the invoice item with the given ID.
  56. *
  57. * @param string $id
  58. * @param null|array $params
  59. * @param null|array|\Stripe\Util\RequestOptions $opts
  60. *
  61. * @throws \Stripe\Exception\ApiErrorException if the request fails
  62. *
  63. * @return \Stripe\InvoiceItem
  64. */
  65. public function retrieve($id, $params = null, $opts = null)
  66. {
  67. return $this->request('get', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  68. }
  69. /**
  70. * Updates the amount or description of an invoice item on an upcoming invoice.
  71. * Updating an invoice item is only possible before the invoice it’s attached to is
  72. * closed.
  73. *
  74. * @param string $id
  75. * @param null|array $params
  76. * @param null|array|\Stripe\Util\RequestOptions $opts
  77. *
  78. * @throws \Stripe\Exception\ApiErrorException if the request fails
  79. *
  80. * @return \Stripe\InvoiceItem
  81. */
  82. public function update($id, $params = null, $opts = null)
  83. {
  84. return $this->request('post', $this->buildPath('/v1/invoiceitems/%s', $id), $params, $opts);
  85. }
  86. }