TokenService.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class TokenService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Creates a single-use token that represents a bank account’s details. You can use
  12. * this token with any API method in place of a bank account dictionary. You can
  13. * only use this token once. To do so, attach it to a <a href="#accounts">connected
  14. * account</a> where <a
  15. * href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a>
  16. * is <code>application</code>, which includes Custom accounts.
  17. *
  18. * @param null|array $params
  19. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  20. *
  21. * @throws \Stripe\Exception\ApiErrorException if the request fails
  22. *
  23. * @return \Stripe\Token
  24. */
  25. public function create($params = null, $opts = null)
  26. {
  27. return $this->request('post', '/v1/tokens', $params, $opts);
  28. }
  29. /**
  30. * Retrieves the token with the given ID.
  31. *
  32. * @param string $id
  33. * @param null|array $params
  34. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  35. *
  36. * @throws \Stripe\Exception\ApiErrorException if the request fails
  37. *
  38. * @return \Stripe\Token
  39. */
  40. public function retrieve($id, $params = null, $opts = null)
  41. {
  42. return $this->request('get', $this->buildPath('/v1/tokens/%s', $id), $params, $opts);
  43. }
  44. }