EphemeralKeyService.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class EphemeralKeyService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Invalidates a short-lived API key for a given resource.
  8. *
  9. * @param string $id
  10. * @param null|array $params
  11. * @param null|array|\Stripe\Util\RequestOptions $opts
  12. *
  13. * @throws \Stripe\Exception\ApiErrorException if the request fails
  14. *
  15. * @return \Stripe\EphemeralKey
  16. */
  17. public function delete($id, $params = null, $opts = null)
  18. {
  19. return $this->request('delete', $this->buildPath('/v1/ephemeral_keys/%s', $id), $params, $opts);
  20. }
  21. /**
  22. * Creates a short-lived API key for a given resource.
  23. *
  24. * @param null|array $params
  25. * @param null|array|\Stripe\Util\RequestOptions $opts
  26. *
  27. * @throws \Stripe\Exception\ApiErrorException if the request fails
  28. *
  29. * @return \Stripe\EphemeralKey
  30. */
  31. public function create($params = null, $opts = null)
  32. {
  33. if (!$opts || !isset($opts['stripe_version'])) {
  34. throw new \Stripe\Exception\InvalidArgumentException('stripe_version must be specified to create an ephemeral key');
  35. }
  36. return $this->request('post', '/v1/ephemeral_keys', $params, $opts);
  37. }
  38. }