TopupService.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class TopupService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of top-ups.
  12. *
  13. * @param null|array $params
  14. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  15. *
  16. * @throws \Stripe\Exception\ApiErrorException if the request fails
  17. *
  18. * @return \Stripe\Collection<\Stripe\Topup>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/topups', $params, $opts);
  23. }
  24. /**
  25. * Cancels a top-up. Only pending top-ups can be canceled.
  26. *
  27. * @param string $id
  28. * @param null|array $params
  29. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  30. *
  31. * @throws \Stripe\Exception\ApiErrorException if the request fails
  32. *
  33. * @return \Stripe\Topup
  34. */
  35. public function cancel($id, $params = null, $opts = null)
  36. {
  37. return $this->request('post', $this->buildPath('/v1/topups/%s/cancel', $id), $params, $opts);
  38. }
  39. /**
  40. * Top up the balance of an account.
  41. *
  42. * @param null|array $params
  43. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  44. *
  45. * @throws \Stripe\Exception\ApiErrorException if the request fails
  46. *
  47. * @return \Stripe\Topup
  48. */
  49. public function create($params = null, $opts = null)
  50. {
  51. return $this->request('post', '/v1/topups', $params, $opts);
  52. }
  53. /**
  54. * Retrieves the details of a top-up that has previously been created. Supply the
  55. * unique top-up ID that was returned from your previous request, and Stripe will
  56. * return the corresponding top-up information.
  57. *
  58. * @param string $id
  59. * @param null|array $params
  60. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  61. *
  62. * @throws \Stripe\Exception\ApiErrorException if the request fails
  63. *
  64. * @return \Stripe\Topup
  65. */
  66. public function retrieve($id, $params = null, $opts = null)
  67. {
  68. return $this->request('get', $this->buildPath('/v1/topups/%s', $id), $params, $opts);
  69. }
  70. /**
  71. * Updates the metadata of a top-up. Other top-up details are not editable by
  72. * design.
  73. *
  74. * @param string $id
  75. * @param null|array $params
  76. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  77. *
  78. * @throws \Stripe\Exception\ApiErrorException if the request fails
  79. *
  80. * @return \Stripe\Topup
  81. */
  82. public function update($id, $params = null, $opts = null)
  83. {
  84. return $this->request('post', $this->buildPath('/v1/topups/%s', $id), $params, $opts);
  85. }
  86. }