PaymentIntentService.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class PaymentIntentService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of PaymentIntents.
  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<\Stripe\PaymentIntent>
  15. */
  16. public function all($params = null, $opts = null)
  17. {
  18. return $this->requestCollection('get', '/v1/payment_intents', $params, $opts);
  19. }
  20. /**
  21. * A PaymentIntent object can be canceled when it is in one of these statuses:
  22. * <code>requires_payment_method</code>, <code>requires_capture</code>,
  23. * <code>requires_confirmation</code>, <code>requires_action</code>, or
  24. * <code>processing</code>.
  25. *
  26. * Once canceled, no additional charges will be made by the PaymentIntent and any
  27. * operations on the PaymentIntent will fail with an error. For PaymentIntents with
  28. * <code>status=’requires_capture’</code>, the remaining
  29. * <code>amount_capturable</code> will automatically be refunded.
  30. *
  31. * @param string $id
  32. * @param null|array $params
  33. * @param null|array|\Stripe\Util\RequestOptions $opts
  34. *
  35. * @throws \Stripe\Exception\ApiErrorException if the request fails
  36. *
  37. * @return \Stripe\PaymentIntent
  38. */
  39. public function cancel($id, $params = null, $opts = null)
  40. {
  41. return $this->request('post', $this->buildPath('/v1/payment_intents/%s/cancel', $id), $params, $opts);
  42. }
  43. /**
  44. * Capture the funds of an existing uncaptured PaymentIntent when its status is
  45. * <code>requires_capture</code>.
  46. *
  47. * Uncaptured PaymentIntents will be canceled a set number of days after they are
  48. * created (7 by default).
  49. *
  50. * Learn more about <a href="/docs/payments/capture-later">separate authorization
  51. * and capture</a>.
  52. *
  53. * @param string $id
  54. * @param null|array $params
  55. * @param null|array|\Stripe\Util\RequestOptions $opts
  56. *
  57. * @throws \Stripe\Exception\ApiErrorException if the request fails
  58. *
  59. * @return \Stripe\PaymentIntent
  60. */
  61. public function capture($id, $params = null, $opts = null)
  62. {
  63. return $this->request('post', $this->buildPath('/v1/payment_intents/%s/capture', $id), $params, $opts);
  64. }
  65. /**
  66. * Confirm that your customer intends to pay with current or provided payment
  67. * method. Upon confirmation, the PaymentIntent will attempt to initiate a payment.
  68. *
  69. * If the selected payment method requires additional authentication steps, the
  70. * PaymentIntent will transition to the <code>requires_action</code> status and
  71. * suggest additional actions via <code>next_action</code>. If payment fails, the
  72. * PaymentIntent will transition to the <code>requires_payment_method</code>
  73. * status. If payment succeeds, the PaymentIntent will transition to the
  74. * <code>succeeded</code> status (or <code>requires_capture</code>, if
  75. * <code>capture_method</code> is set to <code>manual</code>).
  76. *
  77. * If the <code>confirmation_method</code> is <code>automatic</code>, payment may
  78. * be attempted using our <a
  79. * href="/docs/stripe-js/reference#stripe-handle-card-payment">client SDKs</a> and
  80. * the PaymentIntent’s <a
  81. * href="#payment_intent_object-client_secret">client_secret</a>. After
  82. * <code>next_action</code>s are handled by the client, no additional confirmation
  83. * is required to complete the payment.
  84. *
  85. * If the <code>confirmation_method</code> is <code>manual</code>, all payment
  86. * attempts must be initiated using a secret key. If any actions are required for
  87. * the payment, the PaymentIntent will return to the
  88. * <code>requires_confirmation</code> state after those actions are completed. Your
  89. * server needs to then explicitly re-confirm the PaymentIntent to initiate the
  90. * next payment attempt. Read the <a
  91. * href="/docs/payments/payment-intents/web-manual">expanded documentation</a> to
  92. * learn more about manual confirmation.
  93. *
  94. * @param string $id
  95. * @param null|array $params
  96. * @param null|array|\Stripe\Util\RequestOptions $opts
  97. *
  98. * @throws \Stripe\Exception\ApiErrorException if the request fails
  99. *
  100. * @return \Stripe\PaymentIntent
  101. */
  102. public function confirm($id, $params = null, $opts = null)
  103. {
  104. return $this->request('post', $this->buildPath('/v1/payment_intents/%s/confirm', $id), $params, $opts);
  105. }
  106. /**
  107. * Creates a PaymentIntent object.
  108. *
  109. * After the PaymentIntent is created, attach a payment method and <a
  110. * href="/docs/api/payment_intents/confirm">confirm</a> to continue the payment.
  111. * You can read more about the different payment flows available via the Payment
  112. * Intents API <a href="/docs/payments/payment-intents">here</a>.
  113. *
  114. * When <code>confirm=true</code> is used during creation, it is equivalent to
  115. * creating and confirming the PaymentIntent in the same call. You may use any
  116. * parameters available in the <a href="/docs/api/payment_intents/confirm">confirm
  117. * API</a> when <code>confirm=true</code> is supplied.
  118. *
  119. * @param null|array $params
  120. * @param null|array|\Stripe\Util\RequestOptions $opts
  121. *
  122. * @throws \Stripe\Exception\ApiErrorException if the request fails
  123. *
  124. * @return \Stripe\PaymentIntent
  125. */
  126. public function create($params = null, $opts = null)
  127. {
  128. return $this->request('post', '/v1/payment_intents', $params, $opts);
  129. }
  130. /**
  131. * Retrieves the details of a PaymentIntent that has previously been created.
  132. *
  133. * Client-side retrieval using a publishable key is allowed when the
  134. * <code>client_secret</code> is provided in the query string.
  135. *
  136. * When retrieved with a publishable key, only a subset of properties will be
  137. * returned. Please refer to the <a href="#payment_intent_object">payment
  138. * intent</a> object reference for more details.
  139. *
  140. * @param string $id
  141. * @param null|array $params
  142. * @param null|array|\Stripe\Util\RequestOptions $opts
  143. *
  144. * @throws \Stripe\Exception\ApiErrorException if the request fails
  145. *
  146. * @return \Stripe\PaymentIntent
  147. */
  148. public function retrieve($id, $params = null, $opts = null)
  149. {
  150. return $this->request('get', $this->buildPath('/v1/payment_intents/%s', $id), $params, $opts);
  151. }
  152. /**
  153. * Updates properties on a PaymentIntent object without confirming.
  154. *
  155. * Depending on which properties you update, you may need to confirm the
  156. * PaymentIntent again. For example, updating the <code>payment_method</code> will
  157. * always require you to confirm the PaymentIntent again. If you prefer to update
  158. * and confirm at the same time, we recommend updating properties via the <a
  159. * href="/docs/api/payment_intents/confirm">confirm API</a> instead.
  160. *
  161. * @param string $id
  162. * @param null|array $params
  163. * @param null|array|\Stripe\Util\RequestOptions $opts
  164. *
  165. * @throws \Stripe\Exception\ApiErrorException if the request fails
  166. *
  167. * @return \Stripe\PaymentIntent
  168. */
  169. public function update($id, $params = null, $opts = null)
  170. {
  171. return $this->request('post', $this->buildPath('/v1/payment_intents/%s', $id), $params, $opts);
  172. }
  173. /**
  174. * Verifies microdeposits on a PaymentIntent object.
  175. *
  176. * @param string $id
  177. * @param null|array $params
  178. * @param null|array|\Stripe\Util\RequestOptions $opts
  179. *
  180. * @throws \Stripe\Exception\ApiErrorException if the request fails
  181. *
  182. * @return \Stripe\PaymentIntent
  183. */
  184. public function verifyMicrodeposits($id, $params = null, $opts = null)
  185. {
  186. return $this->request('post', $this->buildPath('/v1/payment_intents/%s/verify_microdeposits', $id), $params, $opts);
  187. }
  188. }