BalanceTransaction.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * Balance transactions represent funds moving through your Stripe account.
  6. * Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
  7. *
  8. * Related guide: <a href="https://stripe.com/docs/reports/balance-transaction-types">Balance transaction types</a>
  9. *
  10. * @property string $id Unique identifier for the object.
  11. * @property string $object String representing the object's type. Objects of the same type share the same value.
  12. * @property int $amount Gross amount of this transaction (in cents (or local equivalent)). A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
  13. * @property int $available_on The date that the transaction's net funds become available in the Stripe balance.
  14. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  15. * @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>.
  16. * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
  17. * @property null|float $exchange_rate If applicable, this transaction uses an exchange rate. If money converts from currency A to currency B, then the <code>amount</code> in currency A, multipled by the <code>exchange_rate</code>, equals the <code>amount</code> in currency B. For example, if you charge a customer 10.00 EUR, the PaymentIntent's <code>amount</code> is <code>1000</code> and <code>currency</code> is <code>eur</code>. If this converts to 12.34 USD in your Stripe account, the BalanceTransaction's <code>amount</code> is <code>1234</code>, its <code>currency</code> is <code>usd</code>, and the <code>exchange_rate</code> is <code>1.234</code>.
  18. * @property int $fee Fees (in cents (or local equivalent)) paid for this transaction. Represented as a positive integer when assessed.
  19. * @property \Stripe\StripeObject[] $fee_details Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
  20. * @property int $net Net impact to a Stripe balance (in cents (or local equivalent)). A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by <code>amount</code> - <code>fee</code>
  21. * @property string $reporting_category Learn more about how <a href="https://stripe.com/docs/reports/reporting-categories">reporting categories</a> can help you understand balance transactions from an accounting perspective.
  22. * @property null|string|\Stripe\ApplicationFee|\Stripe\ApplicationFeeRefund|\Stripe\Charge|\Stripe\ConnectCollectionTransfer|\Stripe\CustomerCashBalanceTransaction|\Stripe\Dispute|\Stripe\Issuing\Authorization|\Stripe\Issuing\Dispute|\Stripe\Issuing\Transaction|\Stripe\Payout|\Stripe\Refund|\Stripe\ReserveTransaction|\Stripe\TaxDeductedAtSource|\Stripe\Topup|\Stripe\Transfer|\Stripe\TransferReversal $source This transaction relates to the Stripe object.
  23. * @property string $status The transaction's net funds status in the Stripe balance, which are either <code>available</code> or <code>pending</code>.
  24. * @property string $type Transaction type: <code>adjustment</code>, <code>advance</code>, <code>advance_funding</code>, <code>anticipation_repayment</code>, <code>application_fee</code>, <code>application_fee_refund</code>, <code>charge</code>, <code>climate_order_purchase</code>, <code>climate_order_refund</code>, <code>connect_collection_transfer</code>, <code>contribution</code>, <code>issuing_authorization_hold</code>, <code>issuing_authorization_release</code>, <code>issuing_dispute</code>, <code>issuing_transaction</code>, <code>obligation_outbound</code>, <code>obligation_reversal_inbound</code>, <code>payment</code>, <code>payment_failure_refund</code>, <code>payment_network_reserve_hold</code>, <code>payment_network_reserve_release</code>, <code>payment_refund</code>, <code>payment_reversal</code>, <code>payment_unreconciled</code>, <code>payout</code>, <code>payout_cancel</code>, <code>payout_failure</code>, <code>refund</code>, <code>refund_failure</code>, <code>reserve_transaction</code>, <code>reserved_funds</code>, <code>stripe_fee</code>, <code>stripe_fx_fee</code>, <code>tax_fee</code>, <code>topup</code>, <code>topup_reversal</code>, <code>transfer</code>, <code>transfer_cancel</code>, <code>transfer_failure</code>, or <code>transfer_refund</code>. Learn more about <a href="https://stripe.com/docs/reports/balance-transaction-types">balance transaction types and what they represent</a>. To classify transactions for accounting purposes, consider <code>reporting_category</code> instead.
  25. */
  26. class BalanceTransaction extends ApiResource
  27. {
  28. const OBJECT_NAME = 'balance_transaction';
  29. const TYPE_ADJUSTMENT = 'adjustment';
  30. const TYPE_ADVANCE = 'advance';
  31. const TYPE_ADVANCE_FUNDING = 'advance_funding';
  32. const TYPE_ANTICIPATION_REPAYMENT = 'anticipation_repayment';
  33. const TYPE_APPLICATION_FEE = 'application_fee';
  34. const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund';
  35. const TYPE_CHARGE = 'charge';
  36. const TYPE_CLIMATE_ORDER_PURCHASE = 'climate_order_purchase';
  37. const TYPE_CLIMATE_ORDER_REFUND = 'climate_order_refund';
  38. const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer';
  39. const TYPE_CONTRIBUTION = 'contribution';
  40. const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold';
  41. const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release';
  42. const TYPE_ISSUING_DISPUTE = 'issuing_dispute';
  43. const TYPE_ISSUING_TRANSACTION = 'issuing_transaction';
  44. const TYPE_OBLIGATION_OUTBOUND = 'obligation_outbound';
  45. const TYPE_OBLIGATION_REVERSAL_INBOUND = 'obligation_reversal_inbound';
  46. const TYPE_PAYMENT = 'payment';
  47. const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund';
  48. const TYPE_PAYMENT_NETWORK_RESERVE_HOLD = 'payment_network_reserve_hold';
  49. const TYPE_PAYMENT_NETWORK_RESERVE_RELEASE = 'payment_network_reserve_release';
  50. const TYPE_PAYMENT_REFUND = 'payment_refund';
  51. const TYPE_PAYMENT_REVERSAL = 'payment_reversal';
  52. const TYPE_PAYMENT_UNRECONCILED = 'payment_unreconciled';
  53. const TYPE_PAYOUT = 'payout';
  54. const TYPE_PAYOUT_CANCEL = 'payout_cancel';
  55. const TYPE_PAYOUT_FAILURE = 'payout_failure';
  56. const TYPE_REFUND = 'refund';
  57. const TYPE_REFUND_FAILURE = 'refund_failure';
  58. const TYPE_RESERVED_FUNDS = 'reserved_funds';
  59. const TYPE_RESERVE_TRANSACTION = 'reserve_transaction';
  60. const TYPE_STRIPE_FEE = 'stripe_fee';
  61. const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee';
  62. const TYPE_TAX_FEE = 'tax_fee';
  63. const TYPE_TOPUP = 'topup';
  64. const TYPE_TOPUP_REVERSAL = 'topup_reversal';
  65. const TYPE_TRANSFER = 'transfer';
  66. const TYPE_TRANSFER_CANCEL = 'transfer_cancel';
  67. const TYPE_TRANSFER_FAILURE = 'transfer_failure';
  68. const TYPE_TRANSFER_REFUND = 'transfer_refund';
  69. /**
  70. * Returns a list of transactions that have contributed to the Stripe account
  71. * balance (e.g., charges, transfers, and so forth). The transactions are returned
  72. * in sorted order, with the most recent transactions appearing first.
  73. *
  74. * Note that this endpoint was previously called “Balance history” and used the
  75. * path <code>/v1/balance/history</code>.
  76. *
  77. * @param null|array $params
  78. * @param null|array|string $opts
  79. *
  80. * @throws \Stripe\Exception\ApiErrorException if the request fails
  81. *
  82. * @return \Stripe\Collection<\Stripe\BalanceTransaction> of ApiResources
  83. */
  84. public static function all($params = null, $opts = null)
  85. {
  86. $url = static::classUrl();
  87. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  88. }
  89. /**
  90. * Retrieves the balance transaction with the given ID.
  91. *
  92. * Note that this endpoint previously used the path
  93. * <code>/v1/balance/history/:id</code>.
  94. *
  95. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  96. * @param null|array|string $opts
  97. *
  98. * @throws \Stripe\Exception\ApiErrorException if the request fails
  99. *
  100. * @return \Stripe\BalanceTransaction
  101. */
  102. public static function retrieve($id, $opts = null)
  103. {
  104. $opts = \Stripe\Util\RequestOptions::parse($opts);
  105. $instance = new static($id, $opts);
  106. $instance->refresh();
  107. return $instance;
  108. }
  109. }