SetupIntentService.php 4.4 KB

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