1<?php
2
3// File generated from our OpenAPI spec
4
5namespace Stripe\Service;
6
7class RefundService extends \Stripe\Service\AbstractService
8{
9    /**
10     * Returns a list of all refunds you’ve previously created. The refunds are
11     * returned in sorted order, with the most recent refunds appearing first. For
12     * convenience, the 10 most recent refunds are always available by default on the
13     * charge object.
14     *
15     * @param null|array $params
16     * @param null|array|\Stripe\Util\RequestOptions $opts
17     *
18     * @throws \Stripe\Exception\ApiErrorException if the request fails
19     *
20     * @return \Stripe\Collection
21     */
22    public function all($params = null, $opts = null)
23    {
24        return $this->requestCollection('get', '/v1/refunds', $params, $opts);
25    }
26
27    /**
28     * Create a refund.
29     *
30     * @param null|array $params
31     * @param null|array|\Stripe\Util\RequestOptions $opts
32     *
33     * @throws \Stripe\Exception\ApiErrorException if the request fails
34     *
35     * @return \Stripe\Refund
36     */
37    public function create($params = null, $opts = null)
38    {
39        return $this->request('post', '/v1/refunds', $params, $opts);
40    }
41
42    /**
43     * Retrieves the details of an existing refund.
44     *
45     * @param string $id
46     * @param null|array $params
47     * @param null|array|\Stripe\Util\RequestOptions $opts
48     *
49     * @throws \Stripe\Exception\ApiErrorException if the request fails
50     *
51     * @return \Stripe\Refund
52     */
53    public function retrieve($id, $params = null, $opts = null)
54    {
55        return $this->request('get', $this->buildPath('/v1/refunds/%s', $id), $params, $opts);
56    }
57
58    /**
59     * Updates the specified refund by setting the values of the parameters passed. Any
60     * parameters not provided will be left unchanged.
61     *
62     * This request only accepts <code>metadata</code> as an argument.
63     *
64     * @param string $id
65     * @param null|array $params
66     * @param null|array|\Stripe\Util\RequestOptions $opts
67     *
68     * @throws \Stripe\Exception\ApiErrorException if the request fails
69     *
70     * @return \Stripe\Refund
71     */
72    public function update($id, $params = null, $opts = null)
73    {
74        return $this->request('post', $this->buildPath('/v1/refunds/%s', $id), $params, $opts);
75    }
76}
77