Reader.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Terminal;
  4. /**
  5. * A Reader represents a physical device for accepting payment details.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/terminal/payments/connect-reader">Connecting to a reader</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 null|\Stripe\StripeObject $action The most recent action performed by the reader.
  12. * @property null|string $device_sw_version The current software version of the reader.
  13. * @property string $device_type Type of reader, one of <code>bbpos_wisepad3</code>, <code>stripe_m2</code>, <code>bbpos_chipper2x</code>, <code>bbpos_wisepos_e</code>, <code>verifone_P400</code>, <code>simulated_wisepos_e</code>, or <code>mobile_phone_reader</code>.
  14. * @property null|string $ip_address The local IP address of the reader.
  15. * @property string $label Custom label given to the reader for easier identification.
  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\Terminal\Location $location The location identifier of the reader.
  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 $serial_number Serial number of the reader.
  20. * @property null|string $status The networking status of the reader.
  21. */
  22. class Reader extends \Stripe\ApiResource
  23. {
  24. const OBJECT_NAME = 'terminal.reader';
  25. use \Stripe\ApiOperations\Update;
  26. const DEVICE_TYPE_BBPOS_CHIPPER2X = 'bbpos_chipper2x';
  27. const DEVICE_TYPE_BBPOS_WISEPAD3 = 'bbpos_wisepad3';
  28. const DEVICE_TYPE_BBPOS_WISEPOS_E = 'bbpos_wisepos_e';
  29. const DEVICE_TYPE_MOBILE_PHONE_READER = 'mobile_phone_reader';
  30. const DEVICE_TYPE_SIMULATED_WISEPOS_E = 'simulated_wisepos_e';
  31. const DEVICE_TYPE_STRIPE_M2 = 'stripe_m2';
  32. const DEVICE_TYPE_VERIFONE_P400 = 'verifone_P400';
  33. const STATUS_OFFLINE = 'offline';
  34. const STATUS_ONLINE = 'online';
  35. /**
  36. * Creates a new <code>Reader</code> object.
  37. *
  38. * @param null|array $params
  39. * @param null|array|string $options
  40. *
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return \Stripe\Terminal\Reader the created resource
  44. */
  45. public static function create($params = null, $options = null)
  46. {
  47. self::_validateParams($params);
  48. $url = static::classUrl();
  49. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  50. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  51. $obj->setLastResponse($response);
  52. return $obj;
  53. }
  54. /**
  55. * Deletes a <code>Reader</code> object.
  56. *
  57. * @param null|array $params
  58. * @param null|array|string $opts
  59. *
  60. * @throws \Stripe\Exception\ApiErrorException if the request fails
  61. *
  62. * @return \Stripe\Terminal\Reader the deleted resource
  63. */
  64. public function delete($params = null, $opts = null)
  65. {
  66. self::_validateParams($params);
  67. $url = $this->instanceUrl();
  68. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  69. $this->refreshFrom($response, $opts);
  70. return $this;
  71. }
  72. /**
  73. * Returns a list of <code>Reader</code> objects.
  74. *
  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\Collection<\Stripe\Terminal\Reader> of ApiResources
  81. */
  82. public static function all($params = null, $opts = null)
  83. {
  84. $url = static::classUrl();
  85. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  86. }
  87. /**
  88. * Retrieves a <code>Reader</code> object.
  89. *
  90. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  91. * @param null|array|string $opts
  92. *
  93. * @throws \Stripe\Exception\ApiErrorException if the request fails
  94. *
  95. * @return \Stripe\Terminal\Reader
  96. */
  97. public static function retrieve($id, $opts = null)
  98. {
  99. $opts = \Stripe\Util\RequestOptions::parse($opts);
  100. $instance = new static($id, $opts);
  101. $instance->refresh();
  102. return $instance;
  103. }
  104. /**
  105. * Updates a <code>Reader</code> object by setting the values of the parameters
  106. * passed. Any parameters not provided will be left unchanged.
  107. *
  108. * @param string $id the ID of the resource to update
  109. * @param null|array $params
  110. * @param null|array|string $opts
  111. *
  112. * @throws \Stripe\Exception\ApiErrorException if the request fails
  113. *
  114. * @return \Stripe\Terminal\Reader the updated resource
  115. */
  116. public static function update($id, $params = null, $opts = null)
  117. {
  118. self::_validateParams($params);
  119. $url = static::resourceUrl($id);
  120. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  121. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  122. $obj->setLastResponse($response);
  123. return $obj;
  124. }
  125. /**
  126. * @param null|array $params
  127. * @param null|array|string $opts
  128. *
  129. * @throws \Stripe\Exception\ApiErrorException if the request fails
  130. *
  131. * @return \Stripe\Terminal\Reader the canceled reader
  132. */
  133. public function cancelAction($params = null, $opts = null)
  134. {
  135. $url = $this->instanceUrl() . '/cancel_action';
  136. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  137. $this->refreshFrom($response, $opts);
  138. return $this;
  139. }
  140. /**
  141. * @param null|array $params
  142. * @param null|array|string $opts
  143. *
  144. * @throws \Stripe\Exception\ApiErrorException if the request fails
  145. *
  146. * @return \Stripe\Terminal\Reader the processed reader
  147. */
  148. public function processPaymentIntent($params = null, $opts = null)
  149. {
  150. $url = $this->instanceUrl() . '/process_payment_intent';
  151. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  152. $this->refreshFrom($response, $opts);
  153. return $this;
  154. }
  155. /**
  156. * @param null|array $params
  157. * @param null|array|string $opts
  158. *
  159. * @throws \Stripe\Exception\ApiErrorException if the request fails
  160. *
  161. * @return \Stripe\Terminal\Reader the processed reader
  162. */
  163. public function processSetupIntent($params = null, $opts = null)
  164. {
  165. $url = $this->instanceUrl() . '/process_setup_intent';
  166. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  167. $this->refreshFrom($response, $opts);
  168. return $this;
  169. }
  170. /**
  171. * @param null|array $params
  172. * @param null|array|string $opts
  173. *
  174. * @throws \Stripe\Exception\ApiErrorException if the request fails
  175. *
  176. * @return \Stripe\Terminal\Reader the refunded reader
  177. */
  178. public function refundPayment($params = null, $opts = null)
  179. {
  180. $url = $this->instanceUrl() . '/refund_payment';
  181. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  182. $this->refreshFrom($response, $opts);
  183. return $this;
  184. }
  185. /**
  186. * @param null|array $params
  187. * @param null|array|string $opts
  188. *
  189. * @throws \Stripe\Exception\ApiErrorException if the request fails
  190. *
  191. * @return \Stripe\Terminal\Reader the seted reader
  192. */
  193. public function setReaderDisplay($params = null, $opts = null)
  194. {
  195. $url = $this->instanceUrl() . '/set_reader_display';
  196. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  197. $this->refreshFrom($response, $opts);
  198. return $this;
  199. }
  200. }