ChargeService.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class ChargeService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of charges you’ve previously created. The charges are returned in
  8. * sorted order, with the most recent charges appearing first.
  9. *
  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\Collection<\Stripe\Charge>
  16. */
  17. public function all($params = null, $opts = null)
  18. {
  19. return $this->requestCollection('get', '/v1/charges', $params, $opts);
  20. }
  21. /**
  22. * Capture the payment of an existing, uncaptured, charge. This is the second half
  23. * of the two-step payment flow, where first you <a href="#create_charge">created a
  24. * charge</a> with the capture option set to false.
  25. *
  26. * Uncaptured payments expire a set number of days after they are created (<a
  27. * href="/docs/charges/placing-a-hold">7 by default</a>). If they are not captured
  28. * by that point in time, they will be marked as refunded and will no longer be
  29. * capturable.
  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\Charge
  38. */
  39. public function capture($id, $params = null, $opts = null)
  40. {
  41. return $this->request('post', $this->buildPath('/v1/charges/%s/capture', $id), $params, $opts);
  42. }
  43. /**
  44. * To charge a credit card or other payment source, you create a
  45. * <code>Charge</code> object. If your API key is in test mode, the supplied
  46. * payment source (e.g., card) won’t actually be charged, although everything else
  47. * will occur as if in live mode. (Stripe assumes that the charge would have
  48. * completed successfully).
  49. *
  50. * @param null|array $params
  51. * @param null|array|\Stripe\Util\RequestOptions $opts
  52. *
  53. * @throws \Stripe\Exception\ApiErrorException if the request fails
  54. *
  55. * @return \Stripe\Charge
  56. */
  57. public function create($params = null, $opts = null)
  58. {
  59. return $this->request('post', '/v1/charges', $params, $opts);
  60. }
  61. /**
  62. * Retrieves the details of a charge that has previously been created. Supply the
  63. * unique charge ID that was returned from your previous request, and Stripe will
  64. * return the corresponding charge information. The same information is returned
  65. * when creating or refunding the charge.
  66. *
  67. * @param string $id
  68. * @param null|array $params
  69. * @param null|array|\Stripe\Util\RequestOptions $opts
  70. *
  71. * @throws \Stripe\Exception\ApiErrorException if the request fails
  72. *
  73. * @return \Stripe\Charge
  74. */
  75. public function retrieve($id, $params = null, $opts = null)
  76. {
  77. return $this->request('get', $this->buildPath('/v1/charges/%s', $id), $params, $opts);
  78. }
  79. /**
  80. * Updates the specified charge by setting the values of the parameters passed. Any
  81. * parameters not provided will be left unchanged.
  82. *
  83. * @param string $id
  84. * @param null|array $params
  85. * @param null|array|\Stripe\Util\RequestOptions $opts
  86. *
  87. * @throws \Stripe\Exception\ApiErrorException if the request fails
  88. *
  89. * @return \Stripe\Charge
  90. */
  91. public function update($id, $params = null, $opts = null)
  92. {
  93. return $this->request('post', $this->buildPath('/v1/charges/%s', $id), $params, $opts);
  94. }
  95. }