ChargeService.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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
  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 exactly seven days after they are created. If they
  27. * are not captured by that point in time, they will be marked as refunded and will
  28. * no longer be capturable.
  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\Charge
  37. */
  38. public function capture($id, $params = null, $opts = null)
  39. {
  40. return $this->request('post', $this->buildPath('/v1/charges/%s/capture', $id), $params, $opts);
  41. }
  42. /**
  43. * To charge a credit card or other payment source, you create a
  44. * <code>Charge</code> object. If your API key is in test mode, the supplied
  45. * payment source (e.g., card) won’t actually be charged, although everything else
  46. * will occur as if in live mode. (Stripe assumes that the charge would have
  47. * completed successfully).
  48. *
  49. * @param null|array $params
  50. * @param null|array|\Stripe\Util\RequestOptions $opts
  51. *
  52. * @throws \Stripe\Exception\ApiErrorException if the request fails
  53. *
  54. * @return \Stripe\Charge
  55. */
  56. public function create($params = null, $opts = null)
  57. {
  58. return $this->request('post', '/v1/charges', $params, $opts);
  59. }
  60. /**
  61. * Retrieves the details of a charge that has previously been created. Supply the
  62. * unique charge ID that was returned from your previous request, and Stripe will
  63. * return the corresponding charge information. The same information is returned
  64. * when creating or refunding the charge.
  65. *
  66. * @param string $id
  67. * @param null|array $params
  68. * @param null|array|\Stripe\Util\RequestOptions $opts
  69. *
  70. * @throws \Stripe\Exception\ApiErrorException if the request fails
  71. *
  72. * @return \Stripe\Charge
  73. */
  74. public function retrieve($id, $params = null, $opts = null)
  75. {
  76. return $this->request('get', $this->buildPath('/v1/charges/%s', $id), $params, $opts);
  77. }
  78. /**
  79. * Updates the specified charge by setting the values of the parameters passed. Any
  80. * parameters not provided will be left unchanged.
  81. *
  82. * @param string $id
  83. * @param null|array $params
  84. * @param null|array|\Stripe\Util\RequestOptions $opts
  85. *
  86. * @throws \Stripe\Exception\ApiErrorException if the request fails
  87. *
  88. * @return \Stripe\Charge
  89. */
  90. public function update($id, $params = null, $opts = null)
  91. {
  92. return $this->request('post', $this->buildPath('/v1/charges/%s', $id), $params, $opts);
  93. }
  94. }