RefundService.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 RefundService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of all refunds you created. We return the refunds in sorted
  12. * order, with the most recent refunds appearing first The 10 most recent refunds
  13. * are always available by default on the Charge object.
  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\Refund>
  21. */
  22. public function all($params = null, $opts = null)
  23. {
  24. return $this->requestCollection('get', '/v1/refunds', $params, $opts);
  25. }
  26. /**
  27. * Cancels a refund with a status of <code>requires_action</code>.
  28. *
  29. * You can’t cancel refunds in other states. Only refunds for payment methods that
  30. * require customer action can enter the <code>requires_action</code> state.
  31. *
  32. * @param string $id
  33. * @param null|array $params
  34. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  35. *
  36. * @throws \Stripe\Exception\ApiErrorException if the request fails
  37. *
  38. * @return \Stripe\Refund
  39. */
  40. public function cancel($id, $params = null, $opts = null)
  41. {
  42. return $this->request('post', $this->buildPath('/v1/refunds/%s/cancel', $id), $params, $opts);
  43. }
  44. /**
  45. * When you create a new refund, you must specify a Charge or a PaymentIntent
  46. * object on which to create it.
  47. *
  48. * Creating a new refund will refund a charge that has previously been created but
  49. * not yet refunded. Funds will be refunded to the credit or debit card that was
  50. * originally charged.
  51. *
  52. * You can optionally refund only part of a charge. You can do so multiple times,
  53. * until the entire charge has been refunded.
  54. *
  55. * Once entirely refunded, a charge can’t be refunded again. This method will raise
  56. * an error when called on an already-refunded charge, or when trying to refund
  57. * more money than is left on a charge.
  58. *
  59. * @param null|array $params
  60. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  61. *
  62. * @throws \Stripe\Exception\ApiErrorException if the request fails
  63. *
  64. * @return \Stripe\Refund
  65. */
  66. public function create($params = null, $opts = null)
  67. {
  68. return $this->request('post', '/v1/refunds', $params, $opts);
  69. }
  70. /**
  71. * Retrieves the details of an existing refund.
  72. *
  73. * @param string $id
  74. * @param null|array $params
  75. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  76. *
  77. * @throws \Stripe\Exception\ApiErrorException if the request fails
  78. *
  79. * @return \Stripe\Refund
  80. */
  81. public function retrieve($id, $params = null, $opts = null)
  82. {
  83. return $this->request('get', $this->buildPath('/v1/refunds/%s', $id), $params, $opts);
  84. }
  85. /**
  86. * Updates the refund that you specify by setting the values of the passed
  87. * parameters. Any parameters that you don’t provide remain unchanged.
  88. *
  89. * This request only accepts <code>metadata</code> as an argument.
  90. *
  91. * @param string $id
  92. * @param null|array $params
  93. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  94. *
  95. * @throws \Stripe\Exception\ApiErrorException if the request fails
  96. *
  97. * @return \Stripe\Refund
  98. */
  99. public function update($id, $params = null, $opts = null)
  100. {
  101. return $this->request('post', $this->buildPath('/v1/refunds/%s', $id), $params, $opts);
  102. }
  103. }