ConnectionToken.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Terminal;
  4. /**
  5. * A Connection Token is used by the Stripe Terminal SDK to connect to a reader.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/terminal/fleet/locations">Fleet management</a>
  8. *
  9. * @property string $object String representing the object's type. Objects of the same type share the same value.
  10. * @property null|string $location The id of the location that this connection token is scoped to. Note that location scoping only applies to internet-connected readers. For more details, see <a href="https://docs.stripe.com/terminal/fleet/locations-and-zones?dashboard-or-api=api#connection-tokens">the docs on scoping connection tokens</a>.
  11. * @property string $secret Your application should pass this token to the Stripe Terminal SDK.
  12. */
  13. class ConnectionToken extends \Stripe\ApiResource
  14. {
  15. const OBJECT_NAME = 'terminal.connection_token';
  16. /**
  17. * To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived
  18. * connection token from Stripe, proxied through your server. On your backend, add
  19. * an endpoint that creates and returns a connection token.
  20. *
  21. * @param null|array $params
  22. * @param null|array|string $options
  23. *
  24. * @throws \Stripe\Exception\ApiErrorException if the request fails
  25. *
  26. * @return \Stripe\Terminal\ConnectionToken the created resource
  27. */
  28. public static function create($params = null, $options = null)
  29. {
  30. self::_validateParams($params);
  31. $url = static::classUrl();
  32. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  33. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  34. $obj->setLastResponse($response);
  35. return $obj;
  36. }
  37. }