Transfer.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace Stripe;
  3. /**
  4. * Class Transfer
  5. *
  6. * @property string $id
  7. * @property string $object
  8. * @property int $amount
  9. * @property int $amount_reversed
  10. * @property string $balance_transaction
  11. * @property int $created
  12. * @property string $currency
  13. * @property string $description
  14. * @property string $destination
  15. * @property string $destination_payment
  16. * @property bool $livemode
  17. * @property StripeObject $metadata
  18. * @property Collection $reversals
  19. * @property bool $reversed
  20. * @property string $source_transaction
  21. * @property string $source_type
  22. * @property string $transfer_group
  23. *
  24. * @package Stripe
  25. */
  26. class Transfer extends ApiResource
  27. {
  28. const OBJECT_NAME = "transfer";
  29. use ApiOperations\All;
  30. use ApiOperations\Create;
  31. use ApiOperations\NestedResource;
  32. use ApiOperations\Retrieve;
  33. use ApiOperations\Update;
  34. const PATH_REVERSALS = '/reversals';
  35. /**
  36. * @return TransferReversal The created transfer reversal.
  37. */
  38. public function reverse($params = null, $opts = null)
  39. {
  40. $url = $this->instanceUrl() . '/reversals';
  41. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  42. $this->refreshFrom($response, $opts);
  43. return $this;
  44. }
  45. /**
  46. * @return Transfer The canceled transfer.
  47. */
  48. public function cancel()
  49. {
  50. $url = $this->instanceUrl() . '/cancel';
  51. list($response, $opts) = $this->_request('post', $url);
  52. $this->refreshFrom($response, $opts);
  53. return $this;
  54. }
  55. /**
  56. * @param array|null $id The ID of the transfer on which to create the reversal.
  57. * @param array|null $params
  58. * @param array|string|null $opts
  59. *
  60. * @return TransferReversal
  61. */
  62. public static function createReversal($id, $params = null, $opts = null)
  63. {
  64. return self::_createNestedResource($id, static::PATH_REVERSALS, $params, $opts);
  65. }
  66. /**
  67. * @param array|null $id The ID of the transfer to which the reversal belongs.
  68. * @param array|null $reversalId The ID of the reversal to retrieve.
  69. * @param array|null $params
  70. * @param array|string|null $opts
  71. *
  72. * @return TransferReversal
  73. */
  74. public static function retrieveReversal($id, $reversalId, $params = null, $opts = null)
  75. {
  76. return self::_retrieveNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
  77. }
  78. /**
  79. * @param array|null $id The ID of the transfer to which the reversal belongs.
  80. * @param array|null $reversalId The ID of the reversal to update.
  81. * @param array|null $params
  82. * @param array|string|null $opts
  83. *
  84. * @return TransferReversal
  85. */
  86. public static function updateReversal($id, $reversalId, $params = null, $opts = null)
  87. {
  88. return self::_updateNestedResource($id, static::PATH_REVERSALS, $reversalId, $params, $opts);
  89. }
  90. /**
  91. * @param array|null $id The ID of the transfer on which to retrieve the reversals.
  92. * @param array|null $params
  93. * @param array|string|null $opts
  94. *
  95. * @return TransferReversal
  96. */
  97. public static function allReversals($id, $params = null, $opts = null)
  98. {
  99. return self::_allNestedResources($id, static::PATH_REVERSALS, $params, $opts);
  100. }
  101. }