SourceService.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 SourceService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * List source transactions for a given source.
  12. *
  13. * @param string $id
  14. * @param null|array $params
  15. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  16. *
  17. * @throws \Stripe\Exception\ApiErrorException if the request fails
  18. *
  19. * @return \Stripe\Collection<\Stripe\SourceTransaction>
  20. */
  21. public function allSourceTransactions($id, $params = null, $opts = null)
  22. {
  23. return $this->requestCollection('get', $this->buildPath('/v1/sources/%s/source_transactions', $id), $params, $opts);
  24. }
  25. /**
  26. * Creates a new source object.
  27. *
  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\Source
  34. */
  35. public function create($params = null, $opts = null)
  36. {
  37. return $this->request('post', '/v1/sources', $params, $opts);
  38. }
  39. /**
  40. * Delete a specified source for a given customer.
  41. *
  42. * @param string $parentId
  43. * @param string $id
  44. * @param null|array $params
  45. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  46. *
  47. * @throws \Stripe\Exception\ApiErrorException if the request fails
  48. *
  49. * @return \Stripe\Account|\Stripe\BankAccount|\Stripe\Card|\Stripe\Source
  50. */
  51. public function detach($parentId, $id, $params = null, $opts = null)
  52. {
  53. return $this->request('delete', $this->buildPath('/v1/customers/%s/sources/%s', $parentId, $id), $params, $opts);
  54. }
  55. /**
  56. * Retrieves an existing source object. Supply the unique source ID from a source
  57. * creation request and Stripe will return the corresponding up-to-date source
  58. * object information.
  59. *
  60. * @param string $id
  61. * @param null|array $params
  62. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  63. *
  64. * @throws \Stripe\Exception\ApiErrorException if the request fails
  65. *
  66. * @return \Stripe\Source
  67. */
  68. public function retrieve($id, $params = null, $opts = null)
  69. {
  70. return $this->request('get', $this->buildPath('/v1/sources/%s', $id), $params, $opts);
  71. }
  72. /**
  73. * Updates the specified source by setting the values of the parameters passed. Any
  74. * parameters not provided will be left unchanged.
  75. *
  76. * This request accepts the <code>metadata</code> and <code>owner</code> as
  77. * arguments. It is also possible to update type specific information for selected
  78. * payment methods. Please refer to our <a href="/docs/sources">payment method
  79. * guides</a> for more detail.
  80. *
  81. * @param string $id
  82. * @param null|array $params
  83. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  84. *
  85. * @throws \Stripe\Exception\ApiErrorException if the request fails
  86. *
  87. * @return \Stripe\Source
  88. */
  89. public function update($id, $params = null, $opts = null)
  90. {
  91. return $this->request('post', $this->buildPath('/v1/sources/%s', $id), $params, $opts);
  92. }
  93. /**
  94. * Verify a given source.
  95. *
  96. * @param string $id
  97. * @param null|array $params
  98. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  99. *
  100. * @throws \Stripe\Exception\ApiErrorException if the request fails
  101. *
  102. * @return \Stripe\Source
  103. */
  104. public function verify($id, $params = null, $opts = null)
  105. {
  106. return $this->request('post', $this->buildPath('/v1/sources/%s/verify', $id), $params, $opts);
  107. }
  108. }