Dispute.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Issuing;
  4. /**
  5. * As a <a href="https://stripe.com/docs/issuing">card issuer</a>, you can dispute transactions that the cardholder does not recognize, suspects to be fraudulent, or has other issues with.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/issuing/purchases/disputes">Issuing disputes</a>
  8. *
  9. * @property string $id Unique identifier for the object.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property int $amount Disputed amount in the card's currency and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. Usually the amount of the <code>transaction</code>, but can differ (usually because of currency fluctuation).
  12. * @property null|\Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with the dispute.
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @property string $currency The currency the <code>transaction</code> was made in.
  15. * @property \Stripe\StripeObject $evidence
  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 $loss_reason The enum that describes the dispute loss outcome. If the dispute is not lost, this field will be absent. New enum values may be added in the future, so be sure to handle unknown values.
  18. * @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.
  19. * @property string $status Current status of the dispute.
  20. * @property string|\Stripe\Issuing\Transaction $transaction The transaction being disputed.
  21. * @property null|\Stripe\StripeObject $treasury <a href="https://stripe.com/docs/api/treasury">Treasury</a> details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts
  22. */
  23. class Dispute extends \Stripe\ApiResource
  24. {
  25. const OBJECT_NAME = 'issuing.dispute';
  26. use \Stripe\ApiOperations\Update;
  27. const LOSS_REASON_CARDHOLDER_AUTHENTICATION_ISSUER_LIABILITY = 'cardholder_authentication_issuer_liability';
  28. const LOSS_REASON_ECI5_TOKEN_TRANSACTION_WITH_TAVV = 'eci5_token_transaction_with_tavv';
  29. const LOSS_REASON_EXCESS_DISPUTES_IN_TIMEFRAME = 'excess_disputes_in_timeframe';
  30. const LOSS_REASON_HAS_NOT_MET_THE_MINIMUM_DISPUTE_AMOUNT_REQUIREMENTS = 'has_not_met_the_minimum_dispute_amount_requirements';
  31. const LOSS_REASON_INVALID_DUPLICATE_DISPUTE = 'invalid_duplicate_dispute';
  32. const LOSS_REASON_INVALID_INCORRECT_AMOUNT_DISPUTE = 'invalid_incorrect_amount_dispute';
  33. const LOSS_REASON_INVALID_NO_AUTHORIZATION = 'invalid_no_authorization';
  34. const LOSS_REASON_INVALID_USE_OF_DISPUTES = 'invalid_use_of_disputes';
  35. const LOSS_REASON_MERCHANDISE_DELIVERED_OR_SHIPPED = 'merchandise_delivered_or_shipped';
  36. const LOSS_REASON_MERCHANDISE_OR_SERVICE_AS_DESCRIBED = 'merchandise_or_service_as_described';
  37. const LOSS_REASON_NOT_CANCELLED = 'not_cancelled';
  38. const LOSS_REASON_OTHER = 'other';
  39. const LOSS_REASON_REFUND_ISSUED = 'refund_issued';
  40. const LOSS_REASON_SUBMITTED_BEYOND_ALLOWABLE_TIME_LIMIT = 'submitted_beyond_allowable_time_limit';
  41. const LOSS_REASON_TRANSACTION_3DS_REQUIRED = 'transaction_3ds_required';
  42. const LOSS_REASON_TRANSACTION_APPROVED_AFTER_PRIOR_FRAUD_DISPUTE = 'transaction_approved_after_prior_fraud_dispute';
  43. const LOSS_REASON_TRANSACTION_AUTHORIZED = 'transaction_authorized';
  44. const LOSS_REASON_TRANSACTION_ELECTRONICALLY_READ = 'transaction_electronically_read';
  45. const LOSS_REASON_TRANSACTION_QUALIFIES_FOR_VISA_EASY_PAYMENT_SERVICE = 'transaction_qualifies_for_visa_easy_payment_service';
  46. const LOSS_REASON_TRANSACTION_UNATTENDED = 'transaction_unattended';
  47. const STATUS_EXPIRED = 'expired';
  48. const STATUS_LOST = 'lost';
  49. const STATUS_SUBMITTED = 'submitted';
  50. const STATUS_UNSUBMITTED = 'unsubmitted';
  51. const STATUS_WON = 'won';
  52. /**
  53. * Creates an Issuing <code>Dispute</code> object. Individual pieces of evidence
  54. * within the <code>evidence</code> object are optional at this point. Stripe only
  55. * validates that required evidence is present during submission. Refer to <a
  56. * href="/docs/issuing/purchases/disputes#dispute-reasons-and-evidence">Dispute
  57. * reasons and evidence</a> for more details about evidence requirements.
  58. *
  59. * @param null|array $params
  60. * @param null|array|string $options
  61. *
  62. * @throws \Stripe\Exception\ApiErrorException if the request fails
  63. *
  64. * @return \Stripe\Issuing\Dispute the created resource
  65. */
  66. public static function create($params = null, $options = null)
  67. {
  68. self::_validateParams($params);
  69. $url = static::classUrl();
  70. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  71. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  72. $obj->setLastResponse($response);
  73. return $obj;
  74. }
  75. /**
  76. * Returns a list of Issuing <code>Dispute</code> objects. The objects are sorted
  77. * in descending order by creation date, with the most recently created object
  78. * appearing first.
  79. *
  80. * @param null|array $params
  81. * @param null|array|string $opts
  82. *
  83. * @throws \Stripe\Exception\ApiErrorException if the request fails
  84. *
  85. * @return \Stripe\Collection<\Stripe\Issuing\Dispute> of ApiResources
  86. */
  87. public static function all($params = null, $opts = null)
  88. {
  89. $url = static::classUrl();
  90. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  91. }
  92. /**
  93. * Retrieves an Issuing <code>Dispute</code> object.
  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\Issuing\Dispute
  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. /**
  110. * Updates the specified Issuing <code>Dispute</code> object by setting the values
  111. * of the parameters passed. Any parameters not provided will be left unchanged.
  112. * Properties on the <code>evidence</code> object can be unset by passing in an
  113. * empty string.
  114. *
  115. * @param string $id the ID of the resource to update
  116. * @param null|array $params
  117. * @param null|array|string $opts
  118. *
  119. * @throws \Stripe\Exception\ApiErrorException if the request fails
  120. *
  121. * @return \Stripe\Issuing\Dispute the updated resource
  122. */
  123. public static function update($id, $params = null, $opts = null)
  124. {
  125. self::_validateParams($params);
  126. $url = static::resourceUrl($id);
  127. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  128. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  129. $obj->setLastResponse($response);
  130. return $obj;
  131. }
  132. /**
  133. * @param null|array $params
  134. * @param null|array|string $opts
  135. *
  136. * @throws \Stripe\Exception\ApiErrorException if the request fails
  137. *
  138. * @return \Stripe\Issuing\Dispute the submited dispute
  139. */
  140. public function submit($params = null, $opts = null)
  141. {
  142. $url = $this->instanceUrl() . '/submit';
  143. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  144. $this->refreshFrom($response, $opts);
  145. return $this;
  146. }
  147. }