ApplicationFee.php 2.77 KB
Newer Older
1 2 3 4 5 6 7
<?php

namespace Stripe;

/**
 * Class ApplicationFee
 *
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 * @property string $id
 * @property string $object
 * @property string $account
 * @property int $amount
 * @property int $amount_refunded
 * @property string $application
 * @property string $balance_transaction
 * @property string $charge
 * @property int $created
 * @property string $currency
 * @property bool $livemode
 * @property string $originating_transaction
 * @property bool $refunded
 * @property Collection $refunds
 *
23 24 25 26
 * @package Stripe
 */
class ApplicationFee extends ApiResource
{
27 28 29 30 31 32 33 34 35

    const OBJECT_NAME = "application_fee";

    use ApiOperations\All;
    use ApiOperations\NestedResource;
    use ApiOperations\Retrieve;

    const PATH_REFUNDS = '/refunds';

36
    /**
37 38
     * @param array|null $params
     * @param array|string|null $opts
39
     *
40
     * @return ApplicationFee The refunded application fee.
41
     */
42
    public function refund($params = null, $opts = null)
43
    {
44 45 46
        $this->refunds->create($params, $opts);
        $this->refresh();
        return $this;
47 48 49
    }

    /**
50
     * @param string|null $id The ID of the application fee on which to create the refund.
51
     * @param array|null $params
52 53
     * @param array|string|null $opts
     *
54
     * @return ApplicationFeeRefund
55
     */
56
    public static function createRefund($id, $params = null, $opts = null)
57
    {
58
        return self::_createNestedResource($id, static::PATH_REFUNDS, $params, $opts);
59 60 61
    }

    /**
62
     * @param string|null $id The ID of the application fee to which the refund belongs.
63
     * @param array|null $refundId The ID of the refund to retrieve.
64
     * @param array|null $params
65
     * @param array|string|null $opts
66
     *
67
     * @return ApplicationFeeRefund
68
     */
69
    public static function retrieveRefund($id, $refundId, $params = null, $opts = null)
70
    {
71
        return self::_retrieveNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
72 73 74
    }

    /**
75
     * @param string|null $id The ID of the application fee to which the refund belongs.
76
     * @param array|null $refundId The ID of the refund to update.
77 78 79
     * @param array|null $params
     * @param array|string|null $opts
     *
80
     * @return ApplicationFeeRefund
81
     */
82
    public static function updateRefund($id, $refundId, $params = null, $opts = null)
83
    {
84
        return self::_updateNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
85 86 87
    }

    /**
88
     * @param string|null $id The ID of the application fee on which to retrieve the refunds.
89 90 91
     * @param array|null $params
     * @param array|string|null $opts
     *
mattwire's avatar
mattwire committed
92
     * @return Collection The list of refunds.
93
     */
94
    public static function allRefunds($id, $params = null, $opts = null)
95
    {
96
        return self::_allNestedResources($id, static::PATH_REFUNDS, $params, $opts);
97 98
    }
}