SetupIntentService.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 SetupIntentService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of SetupIntents.
  12. *
  13. * @param null|array $params
  14. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  15. *
  16. * @throws \Stripe\Exception\ApiErrorException if the request fails
  17. *
  18. * @return \Stripe\Collection<\Stripe\SetupIntent>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/setup_intents', $params, $opts);
  23. }
  24. /**
  25. * You can cancel a SetupIntent object when it’s in one of these statuses:
  26. * <code>requires_payment_method</code>, <code>requires_confirmation</code>, or
  27. * <code>requires_action</code>.
  28. *
  29. * After you cancel it, setup is abandoned and any operations on the SetupIntent
  30. * fail with an error. You can’t cancel the SetupIntent for a Checkout Session. <a
  31. * href="/docs/api/checkout/sessions/expire">Expire the Checkout Session</a>
  32. * instead.
  33. *
  34. * @param string $id
  35. * @param null|array $params
  36. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  37. *
  38. * @throws \Stripe\Exception\ApiErrorException if the request fails
  39. *
  40. * @return \Stripe\SetupIntent
  41. */
  42. public function cancel($id, $params = null, $opts = null)
  43. {
  44. return $this->request('post', $this->buildPath('/v1/setup_intents/%s/cancel', $id), $params, $opts);
  45. }
  46. /**
  47. * Confirm that your customer intends to set up the current or provided payment
  48. * method. For example, you would confirm a SetupIntent when a customer hits the
  49. * “Save” button on a payment method management page on your website.
  50. *
  51. * If the selected payment method does not require any additional steps from the
  52. * customer, the SetupIntent will transition to the <code>succeeded</code> status.
  53. *
  54. * Otherwise, it will transition to the <code>requires_action</code> status and
  55. * suggest additional actions via <code>next_action</code>. If setup fails, the
  56. * SetupIntent will transition to the <code>requires_payment_method</code> status
  57. * or the <code>canceled</code> status if the confirmation limit is reached.
  58. *
  59. * @param string $id
  60. * @param null|array $params
  61. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  62. *
  63. * @throws \Stripe\Exception\ApiErrorException if the request fails
  64. *
  65. * @return \Stripe\SetupIntent
  66. */
  67. public function confirm($id, $params = null, $opts = null)
  68. {
  69. return $this->request('post', $this->buildPath('/v1/setup_intents/%s/confirm', $id), $params, $opts);
  70. }
  71. /**
  72. * Creates a SetupIntent object.
  73. *
  74. * After you create the SetupIntent, attach a payment method and <a
  75. * href="/docs/api/setup_intents/confirm">confirm</a> it to collect any required
  76. * permissions to charge the payment method later.
  77. *
  78. * @param null|array $params
  79. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  80. *
  81. * @throws \Stripe\Exception\ApiErrorException if the request fails
  82. *
  83. * @return \Stripe\SetupIntent
  84. */
  85. public function create($params = null, $opts = null)
  86. {
  87. return $this->request('post', '/v1/setup_intents', $params, $opts);
  88. }
  89. /**
  90. * Retrieves the details of a SetupIntent that has previously been created.
  91. *
  92. * Client-side retrieval using a publishable key is allowed when the
  93. * <code>client_secret</code> is provided in the query string.
  94. *
  95. * When retrieved with a publishable key, only a subset of properties will be
  96. * returned. Please refer to the <a href="#setup_intent_object">SetupIntent</a>
  97. * object reference for more details.
  98. *
  99. * @param string $id
  100. * @param null|array $params
  101. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  102. *
  103. * @throws \Stripe\Exception\ApiErrorException if the request fails
  104. *
  105. * @return \Stripe\SetupIntent
  106. */
  107. public function retrieve($id, $params = null, $opts = null)
  108. {
  109. return $this->request('get', $this->buildPath('/v1/setup_intents/%s', $id), $params, $opts);
  110. }
  111. /**
  112. * Updates a SetupIntent object.
  113. *
  114. * @param string $id
  115. * @param null|array $params
  116. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  117. *
  118. * @throws \Stripe\Exception\ApiErrorException if the request fails
  119. *
  120. * @return \Stripe\SetupIntent
  121. */
  122. public function update($id, $params = null, $opts = null)
  123. {
  124. return $this->request('post', $this->buildPath('/v1/setup_intents/%s', $id), $params, $opts);
  125. }
  126. /**
  127. * Verifies microdeposits on a SetupIntent object.
  128. *
  129. * @param string $id
  130. * @param null|array $params
  131. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  132. *
  133. * @throws \Stripe\Exception\ApiErrorException if the request fails
  134. *
  135. * @return \Stripe\SetupIntent
  136. */
  137. public function verifyMicrodeposits($id, $params = null, $opts = null)
  138. {
  139. return $this->request('post', $this->buildPath('/v1/setup_intents/%s/verify_microdeposits', $id), $params, $opts);
  140. }
  141. }