TransferService.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 TransferService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of existing transfers sent to connected accounts. The transfers
  12. * are returned in sorted order, with the most recently created transfers appearing
  13. * first.
  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\Transfer>
  21. */
  22. public function all($params = null, $opts = null)
  23. {
  24. return $this->requestCollection('get', '/v1/transfers', $params, $opts);
  25. }
  26. /**
  27. * You can see a list of the reversals belonging to a specific transfer. Note that
  28. * the 10 most recent reversals are always available by default on the transfer
  29. * object. If you need more than those 10, you can use this API method and the
  30. * <code>limit</code> and <code>starting_after</code> parameters to page through
  31. * additional reversals.
  32. *
  33. * @param string $parentId
  34. * @param null|array $params
  35. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  36. *
  37. * @throws \Stripe\Exception\ApiErrorException if the request fails
  38. *
  39. * @return \Stripe\Collection<\Stripe\TransferReversal>
  40. */
  41. public function allReversals($parentId, $params = null, $opts = null)
  42. {
  43. return $this->requestCollection('get', $this->buildPath('/v1/transfers/%s/reversals', $parentId), $params, $opts);
  44. }
  45. /**
  46. * To send funds from your Stripe account to a connected account, you create a new
  47. * transfer object. Your <a href="#balance">Stripe balance</a> must be able to
  48. * cover the transfer amount, or you’ll receive an “Insufficient Funds” error.
  49. *
  50. * @param null|array $params
  51. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  52. *
  53. * @throws \Stripe\Exception\ApiErrorException if the request fails
  54. *
  55. * @return \Stripe\Transfer
  56. */
  57. public function create($params = null, $opts = null)
  58. {
  59. return $this->request('post', '/v1/transfers', $params, $opts);
  60. }
  61. /**
  62. * When you create a new reversal, you must specify a transfer to create it on.
  63. *
  64. * When reversing transfers, you can optionally reverse part of the transfer. You
  65. * can do so as many times as you wish until the entire transfer has been reversed.
  66. *
  67. * Once entirely reversed, a transfer can’t be reversed again. This method will
  68. * return an error when called on an already-reversed transfer, or when trying to
  69. * reverse more money than is left on a transfer.
  70. *
  71. * @param string $parentId
  72. * @param null|array $params
  73. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  74. *
  75. * @throws \Stripe\Exception\ApiErrorException if the request fails
  76. *
  77. * @return \Stripe\TransferReversal
  78. */
  79. public function createReversal($parentId, $params = null, $opts = null)
  80. {
  81. return $this->request('post', $this->buildPath('/v1/transfers/%s/reversals', $parentId), $params, $opts);
  82. }
  83. /**
  84. * Retrieves the details of an existing transfer. Supply the unique transfer ID
  85. * from either a transfer creation request or the transfer list, and Stripe will
  86. * return the corresponding transfer information.
  87. *
  88. * @param string $id
  89. * @param null|array $params
  90. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  91. *
  92. * @throws \Stripe\Exception\ApiErrorException if the request fails
  93. *
  94. * @return \Stripe\Transfer
  95. */
  96. public function retrieve($id, $params = null, $opts = null)
  97. {
  98. return $this->request('get', $this->buildPath('/v1/transfers/%s', $id), $params, $opts);
  99. }
  100. /**
  101. * By default, you can see the 10 most recent reversals stored directly on the
  102. * transfer object, but you can also retrieve details about a specific reversal
  103. * stored on the transfer.
  104. *
  105. * @param string $parentId
  106. * @param string $id
  107. * @param null|array $params
  108. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  109. *
  110. * @throws \Stripe\Exception\ApiErrorException if the request fails
  111. *
  112. * @return \Stripe\TransferReversal
  113. */
  114. public function retrieveReversal($parentId, $id, $params = null, $opts = null)
  115. {
  116. return $this->request('get', $this->buildPath('/v1/transfers/%s/reversals/%s', $parentId, $id), $params, $opts);
  117. }
  118. /**
  119. * Updates the specified transfer by setting the values of the parameters passed.
  120. * Any parameters not provided will be left unchanged.
  121. *
  122. * This request accepts only metadata as an argument.
  123. *
  124. * @param string $id
  125. * @param null|array $params
  126. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  127. *
  128. * @throws \Stripe\Exception\ApiErrorException if the request fails
  129. *
  130. * @return \Stripe\Transfer
  131. */
  132. public function update($id, $params = null, $opts = null)
  133. {
  134. return $this->request('post', $this->buildPath('/v1/transfers/%s', $id), $params, $opts);
  135. }
  136. /**
  137. * Updates the specified reversal by setting the values of the parameters passed.
  138. * Any parameters not provided will be left unchanged.
  139. *
  140. * This request only accepts metadata and description as arguments.
  141. *
  142. * @param string $parentId
  143. * @param string $id
  144. * @param null|array $params
  145. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  146. *
  147. * @throws \Stripe\Exception\ApiErrorException if the request fails
  148. *
  149. * @return \Stripe\TransferReversal
  150. */
  151. public function updateReversal($parentId, $id, $params = null, $opts = null)
  152. {
  153. return $this->request('post', $this->buildPath('/v1/transfers/%s/reversals/%s', $parentId, $id), $params, $opts);
  154. }
  155. }