CreditNoteService.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class CreditNoteService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of credit notes.
  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
  15. */
  16. public function all($params = null, $opts = null)
  17. {
  18. return $this->requestCollection('get', '/v1/credit_notes', $params, $opts);
  19. }
  20. /**
  21. * When retrieving a credit note, you’ll get a <strong>lines</strong> property
  22. * containing the the first handful of those items. There is also a URL where you
  23. * can retrieve the full (paginated) list of line items.
  24. *
  25. * @param string $parentId
  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\Collection
  32. */
  33. public function allLines($parentId, $params = null, $opts = null)
  34. {
  35. return $this->requestCollection('get', $this->buildPath('/v1/credit_notes/%s/lines', $parentId), $params, $opts);
  36. }
  37. /**
  38. * Issue a credit note to adjust the amount of a finalized invoice. For a
  39. * <code>status=open</code> invoice, a credit note reduces its
  40. * <code>amount_due</code>. For a <code>status=paid</code> invoice, a credit note
  41. * does not affect its <code>amount_due</code>. Instead, it can result in any
  42. * combination of the following:.
  43. *
  44. * <ul> <li>Refund: create a new refund (using <code>refund_amount</code>) or link
  45. * an existing refund (using <code>refund</code>).</li> <li>Customer balance
  46. * credit: credit the customer’s balance (using <code>credit_amount</code>) which
  47. * will be automatically applied to their next invoice when it’s finalized.</li>
  48. * <li>Outside of Stripe credit: record the amount that is or will be credited
  49. * outside of Stripe (using <code>out_of_band_amount</code>).</li> </ul>
  50. *
  51. * For post-payment credit notes the sum of the refund, credit and outside of
  52. * Stripe amounts must equal the credit note total.
  53. *
  54. * You may issue multiple credit notes for an invoice. Each credit note will
  55. * increment the invoice’s <code>pre_payment_credit_notes_amount</code> or
  56. * <code>post_payment_credit_notes_amount</code> depending on its
  57. * <code>status</code> at the time of credit note creation.
  58. *
  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\CreditNote
  65. */
  66. public function create($params = null, $opts = null)
  67. {
  68. return $this->request('post', '/v1/credit_notes', $params, $opts);
  69. }
  70. /**
  71. * Get a preview of a credit note without creating it.
  72. *
  73. * @param null|array $params
  74. * @param null|array|\Stripe\Util\RequestOptions $opts
  75. *
  76. * @throws \Stripe\Exception\ApiErrorException if the request fails
  77. *
  78. * @return \Stripe\CreditNote
  79. */
  80. public function preview($params = null, $opts = null)
  81. {
  82. return $this->request('get', '/v1/credit_notes/preview', $params, $opts);
  83. }
  84. /**
  85. * When retrieving a credit note preview, you’ll get a <strong>lines</strong>
  86. * property containing the first handful of those items. This URL you can retrieve
  87. * the full (paginated) list of line items.
  88. *
  89. * @param null|array $params
  90. * @param null|array|\Stripe\Util\RequestOptions $opts
  91. *
  92. * @throws \Stripe\Exception\ApiErrorException if the request fails
  93. *
  94. * @return \Stripe\CreditNote
  95. */
  96. public function previewLines($params = null, $opts = null)
  97. {
  98. return $this->request('get', '/v1/credit_notes/preview/lines', $params, $opts);
  99. }
  100. /**
  101. * Retrieves the credit note object with the given identifier.
  102. *
  103. * @param string $id
  104. * @param null|array $params
  105. * @param null|array|\Stripe\Util\RequestOptions $opts
  106. *
  107. * @throws \Stripe\Exception\ApiErrorException if the request fails
  108. *
  109. * @return \Stripe\CreditNote
  110. */
  111. public function retrieve($id, $params = null, $opts = null)
  112. {
  113. return $this->request('get', $this->buildPath('/v1/credit_notes/%s', $id), $params, $opts);
  114. }
  115. /**
  116. * Updates an existing credit note.
  117. *
  118. * @param string $id
  119. * @param null|array $params
  120. * @param null|array|\Stripe\Util\RequestOptions $opts
  121. *
  122. * @throws \Stripe\Exception\ApiErrorException if the request fails
  123. *
  124. * @return \Stripe\CreditNote
  125. */
  126. public function update($id, $params = null, $opts = null)
  127. {
  128. return $this->request('post', $this->buildPath('/v1/credit_notes/%s', $id), $params, $opts);
  129. }
  130. /**
  131. * Marks a credit note as void. Learn more about <a
  132. * href="/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
  133. *
  134. * @param string $id
  135. * @param null|array $params
  136. * @param null|array|\Stripe\Util\RequestOptions $opts
  137. *
  138. * @throws \Stripe\Exception\ApiErrorException if the request fails
  139. *
  140. * @return \Stripe\CreditNote
  141. */
  142. public function voidCreditNote($id, $params = null, $opts = null)
  143. {
  144. return $this->request('post', $this->buildPath('/v1/credit_notes/%s/void', $id), $params, $opts);
  145. }
  146. }