Transfer.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * A <code>Transfer</code> object is created when you move funds between Stripe
  6. * accounts as part of Connect.
  7. *
  8. * Before April 6, 2017, transfers also represented movement of funds from a Stripe
  9. * account to a card or bank account. This behavior has since been split out into a
  10. * <a href="https://stripe.com/docs/api#payout_object">Payout</a> object, with
  11. * corresponding payout endpoints. For more information, read about the <a
  12. * href="https://stripe.com/docs/transfer-payout-split">transfer/payout split</a>.
  13. *
  14. * Related guide: <a
  15. * href="https://stripe.com/docs/connect/charges-transfers">Creating Separate
  16. * Charges and Transfers</a>.
  17. *
  18. * @property string $id Unique identifier for the object.
  19. * @property string $object String representing the object's type. Objects of the same type share the same value.
  20. * @property int $amount Amount in %s to be transferred.
  21. * @property int $amount_reversed Amount in %s reversed (can be less than the amount attribute on the transfer if a partial reversal was issued).
  22. * @property null|string|\Stripe\BalanceTransaction $balance_transaction Balance transaction that describes the impact of this transfer on your account balance.
  23. * @property int $created Time that this record of the transfer was first created.
  24. * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
  25. * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
  26. * @property null|string|\Stripe\Account $destination ID of the Stripe account the transfer was sent to.
  27. * @property string|\Stripe\Charge $destination_payment If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.
  28. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  29. * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  30. * @property \Stripe\Collection $reversals A list of reversals that have been applied to the transfer.
  31. * @property bool $reversed Whether the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false.
  32. * @property null|string|\Stripe\Charge $source_transaction ID of the charge or payment that was used to fund the transfer. If null, the transfer was funded from the available balance.
  33. * @property null|string $source_type The source balance this transfer came from. One of <code>card</code>, <code>fpx</code>, or <code>bank_account</code>.
  34. * @property null|string $transfer_group A string that identifies this transaction as part of a group. See the <a href="https://stripe.com/docs/connect/charges-transfers#transfer-options">Connect documentation</a> for details.
  35. */
  36. class Transfer extends ApiResource
  37. {
  38. const OBJECT_NAME = 'transfer';
  39. use ApiOperations\All;
  40. use ApiOperations\Create;
  41. use ApiOperations\NestedResource;
  42. use ApiOperations\Retrieve;
  43. use ApiOperations\Update;
  44. const SOURCE_TYPE_ALIPAY_ACCOUNT = 'alipay_account';
  45. const SOURCE_TYPE_BANK_ACCOUNT = 'bank_account';
  46. const SOURCE_TYPE_CARD = 'card';
  47. const SOURCE_TYPE_FINANCING = 'financing';
  48. /**
  49. * @param null|array $params
  50. * @param null|array|string $opts
  51. *
  52. * @throws \Stripe\Exception\ApiErrorException if the request fails
  53. *
  54. * @return Transfer the canceled transfer
  55. */
  56. public function cancel($params = null, $opts = null)
  57. {
  58. $url = $this->instanceUrl() . '/cancel';
  59. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  60. $this->refreshFrom($response, $opts);
  61. return $this;
  62. }
  63. const PATH_REVERSALS = '/reversals';
  64. /**
  65. * @param string $id the ID of the transfer on which to retrieve the transfer reversals
  66. * @param null|array $params
  67. * @param null|array|string $opts
  68. *
  69. * @throws \Stripe\Exception\ApiErrorException if the request fails
  70. *
  71. * @return \Stripe\Collection the list of transfer reversals
  72. */
  73. public static function allReversals($id, $params = null, $opts = null)
  74. {
  75. return self::_allNestedResources($id, static::PATH_REVERSALS, $params, $opts);
  76. }
  77. /**
  78. * @param string $id the ID of the transfer on which to create the transfer reversal
  79. * @param null|array $params
  80. * @param null|array|string $opts
  81. *
  82. * @throws \Stripe\Exception\ApiErrorException if the request fails
  83. *
  84. * @return \Stripe\TransferReversal
  85. */
  86. public static function createReversal($id, $params = null, $opts = null)
  87. {
  88. return self::_createNestedResource($id, static::PATH_REVERSALS, $params, $opts);
  89. }
  90. /**
  91. * @param string $id the ID of the transfer to which the transfer reversal belongs
  92. * @param string $reversalId the ID of the transfer reversal to retrieve
  93. * @param null|array $params
  94. * @param null|array|string $opts
  95. *
  96. * @throws \Stripe\Exception\ApiErrorException if the request fails
  97. *
  98. * @return \Stripe\TransferReversal
  99. */
  100. public static function retrieveReversal($id, $reversalId, $params = null, $opts = null)
  101. {
  102. return self::_retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
  103. }
  104. /**
  105. * @param string $id the ID of the transfer to which the transfer reversal belongs
  106. * @param string $reversalId the ID of the transfer reversal to update
  107. * @param null|array $params
  108. * @param null|array|string $opts
  109. *
  110. * @throws \Stripe\Exception\ApiErrorException if the request fails
  111. *
  112. * @return \Stripe\TransferReversal
  113. */
  114. public static function updateReversal($id, $reversalId, $params = null, $opts = null)
  115. {
  116. return self::_updateNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
  117. }
  118. }