ApplicationFee.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * @property string $id Unique identifier for the object.
  6. * @property string $object String representing the object's type. Objects of the same type share the same value.
  7. * @property string|\Stripe\Account $account ID of the Stripe account this fee was taken from.
  8. * @property int $amount Amount earned, in cents (or local equivalent).
  9. * @property int $amount_refunded Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued)
  10. * @property string|\Stripe\Application $application ID of the Connect application that earned the fee.
  11. * @property null|string|\Stripe\BalanceTransaction $balance_transaction Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
  12. * @property string|\Stripe\Charge $charge ID of the charge that the application fee was taken from.
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @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>.
  15. * @property null|\Stripe\StripeObject $fee_source Polymorphic source of the application fee. Includes the ID of the object the application fee was created from.
  16. * @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.
  17. * @property null|string|\Stripe\Charge $originating_transaction ID of the corresponding charge on the platform account, if this fee was the result of a charge using the <code>destination</code> parameter.
  18. * @property bool $refunded Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
  19. * @property \Stripe\Collection<\Stripe\ApplicationFeeRefund> $refunds A list of refunds that have been applied to the fee.
  20. */
  21. class ApplicationFee extends ApiResource
  22. {
  23. const OBJECT_NAME = 'application_fee';
  24. use ApiOperations\NestedResource;
  25. /**
  26. * Returns a list of application fees you’ve previously collected. The application
  27. * fees are returned in sorted order, with the most recent fees appearing first.
  28. *
  29. * @param null|array $params
  30. * @param null|array|string $opts
  31. *
  32. * @throws \Stripe\Exception\ApiErrorException if the request fails
  33. *
  34. * @return \Stripe\Collection<\Stripe\ApplicationFee> of ApiResources
  35. */
  36. public static function all($params = null, $opts = null)
  37. {
  38. $url = static::classUrl();
  39. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  40. }
  41. /**
  42. * Retrieves the details of an application fee that your account has collected. The
  43. * same information is returned when refunding the application fee.
  44. *
  45. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  46. * @param null|array|string $opts
  47. *
  48. * @throws \Stripe\Exception\ApiErrorException if the request fails
  49. *
  50. * @return \Stripe\ApplicationFee
  51. */
  52. public static function retrieve($id, $opts = null)
  53. {
  54. $opts = \Stripe\Util\RequestOptions::parse($opts);
  55. $instance = new static($id, $opts);
  56. $instance->refresh();
  57. return $instance;
  58. }
  59. const PATH_REFUNDS = '/refunds';
  60. /**
  61. * @param string $id the ID of the application fee on which to retrieve the application fee refunds
  62. * @param null|array $params
  63. * @param null|array|string $opts
  64. *
  65. * @throws \Stripe\Exception\ApiErrorException if the request fails
  66. *
  67. * @return \Stripe\Collection<\Stripe\ApplicationFeeRefund> the list of application fee refunds
  68. */
  69. public static function allRefunds($id, $params = null, $opts = null)
  70. {
  71. return self::_allNestedResources($id, static::PATH_REFUNDS, $params, $opts);
  72. }
  73. /**
  74. * @param string $id the ID of the application fee on which to create the application fee refund
  75. * @param null|array $params
  76. * @param null|array|string $opts
  77. *
  78. * @throws \Stripe\Exception\ApiErrorException if the request fails
  79. *
  80. * @return \Stripe\ApplicationFeeRefund
  81. */
  82. public static function createRefund($id, $params = null, $opts = null)
  83. {
  84. return self::_createNestedResource($id, static::PATH_REFUNDS, $params, $opts);
  85. }
  86. /**
  87. * @param string $id the ID of the application fee to which the application fee refund belongs
  88. * @param string $refundId the ID of the application fee refund to retrieve
  89. * @param null|array $params
  90. * @param null|array|string $opts
  91. *
  92. * @throws \Stripe\Exception\ApiErrorException if the request fails
  93. *
  94. * @return \Stripe\ApplicationFeeRefund
  95. */
  96. public static function retrieveRefund($id, $refundId, $params = null, $opts = null)
  97. {
  98. return self::_retrieveNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
  99. }
  100. /**
  101. * @param string $id the ID of the application fee to which the application fee refund belongs
  102. * @param string $refundId the ID of the application fee refund to update
  103. * @param null|array $params
  104. * @param null|array|string $opts
  105. *
  106. * @throws \Stripe\Exception\ApiErrorException if the request fails
  107. *
  108. * @return \Stripe\ApplicationFeeRefund
  109. */
  110. public static function updateRefund($id, $refundId, $params = null, $opts = null)
  111. {
  112. return self::_updateNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
  113. }
  114. }