Review.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * Reviews can be used to supplement automated fraud detection with human expertise.
  6. *
  7. * Learn more about <a href="/radar">Radar</a> and reviewing payments
  8. * <a href="https://stripe.com/docs/radar/reviews">here</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 null|string $billing_zip The ZIP or postal code of the card used, if applicable.
  13. * @property null|string|\Stripe\Charge $charge The charge associated with this review.
  14. * @property null|string $closed_reason The reason the review was closed, or null if it has not yet been closed. One of <code>approved</code>, <code>refunded</code>, <code>refunded_as_fraud</code>, <code>disputed</code>, or <code>redacted</code>.
  15. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  16. * @property null|string $ip_address The IP address where the payment originated.
  17. * @property null|\Stripe\StripeObject $ip_address_location Information related to the location of the payment. Note that this information is an approximation and attempts to locate the nearest population center - it should not be used to determine a specific address.
  18. * @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.
  19. * @property bool $open If <code>true</code>, the review needs action.
  20. * @property string $opened_reason The reason the review was opened. One of <code>rule</code> or <code>manual</code>.
  21. * @property null|string|\Stripe\PaymentIntent $payment_intent The PaymentIntent ID associated with this review, if one exists.
  22. * @property string $reason The reason the review is currently open or closed. One of <code>rule</code>, <code>manual</code>, <code>approved</code>, <code>refunded</code>, <code>refunded_as_fraud</code>, <code>disputed</code>, or <code>redacted</code>.
  23. * @property null|\Stripe\StripeObject $session Information related to the browsing session of the user who initiated the payment.
  24. */
  25. class Review extends ApiResource
  26. {
  27. const OBJECT_NAME = 'review';
  28. const CLOSED_REASON_APPROVED = 'approved';
  29. const CLOSED_REASON_DISPUTED = 'disputed';
  30. const CLOSED_REASON_REDACTED = 'redacted';
  31. const CLOSED_REASON_REFUNDED = 'refunded';
  32. const CLOSED_REASON_REFUNDED_AS_FRAUD = 'refunded_as_fraud';
  33. const OPENED_REASON_MANUAL = 'manual';
  34. const OPENED_REASON_RULE = 'rule';
  35. /**
  36. * Returns a list of <code>Review</code> objects that have <code>open</code> set to
  37. * <code>true</code>. The objects are sorted in descending order by creation date,
  38. * with the most recently created object appearing first.
  39. *
  40. * @param null|array $params
  41. * @param null|array|string $opts
  42. *
  43. * @throws \Stripe\Exception\ApiErrorException if the request fails
  44. *
  45. * @return \Stripe\Collection<\Stripe\Review> of ApiResources
  46. */
  47. public static function all($params = null, $opts = null)
  48. {
  49. $url = static::classUrl();
  50. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  51. }
  52. /**
  53. * Retrieves a <code>Review</code> object.
  54. *
  55. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  56. * @param null|array|string $opts
  57. *
  58. * @throws \Stripe\Exception\ApiErrorException if the request fails
  59. *
  60. * @return \Stripe\Review
  61. */
  62. public static function retrieve($id, $opts = null)
  63. {
  64. $opts = \Stripe\Util\RequestOptions::parse($opts);
  65. $instance = new static($id, $opts);
  66. $instance->refresh();
  67. return $instance;
  68. }
  69. /**
  70. * Possible string representations of the current, the opening or the closure reason of the review.
  71. * Not all of these enumeration apply to all of the ´reason´ fields. Please consult the Review object to
  72. * determine where these are apply.
  73. *
  74. * @see https://stripe.com/docs/api/radar/reviews/object
  75. */
  76. const REASON_APPROVED = 'approved';
  77. const REASON_DISPUTED = 'disputed';
  78. const REASON_MANUAL = 'manual';
  79. const REASON_REFUNDED = 'refunded';
  80. const REASON_REFUNDED_AS_FRAUD = 'refunded_as_fraud';
  81. const REASON_RULE = 'rule';
  82. /**
  83. * @param null|array $params
  84. * @param null|array|string $opts
  85. *
  86. * @throws \Stripe\Exception\ApiErrorException if the request fails
  87. *
  88. * @return \Stripe\Review the approved review
  89. */
  90. public function approve($params = null, $opts = null)
  91. {
  92. $url = $this->instanceUrl() . '/approve';
  93. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  94. $this->refreshFrom($response, $opts);
  95. return $this;
  96. }
  97. }