PaymentIntentService.php 7.3 KB

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