Test Failed
Push — master ( 3dd85e...34f16b )
by Devin
04:34 queued 10s
created

Payout::cancel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 7
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class Payout
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property int $amount
11
 * @property int $arrival_date
12
 * @property bool $automatic
13
 * @property string $balance_transaction
14
 * @property int $created
15
 * @property string $currency
16
 * @property string $description
17
 * @property string $destination
18
 * @property string $failure_balance_transaction
19
 * @property string $failure_code
20
 * @property string $failure_message
21
 * @property bool $livemode
22
 * @property StripeObject $metadata
23
 * @property string $method
24
 * @property string $source_type
25
 * @property string $statement_descriptor
26
 * @property string $status
27
 * @property string $type
28
 *
29
 * @package Stripe
30
 */
31 View Code Duplication
class Payout extends ApiResource
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
{
33
34
    const OBJECT_NAME = "payout";
35
36
    use ApiOperations\All;
37
    use ApiOperations\Create;
38
    use ApiOperations\Retrieve;
39
    use ApiOperations\Update;
40
41
    /**
42
     * Types of payout failure codes.
43
     * @link https://stripe.com/docs/api#payout_failures
44
     */
45
    const FAILURE_ACCOUNT_CLOSED                = 'account_closed';
46
    const FAILURE_ACCOUNT_FROZEN                = 'account_frozen';
47
    const FAILURE_BANK_ACCOUNT_RESTRICTED       = 'bank_account_restricted';
48
    const FAILURE_BANK_OWNERSHIP_CHANGED        = 'bank_ownership_changed';
49
    const FAILURE_COULD_NOT_PROCESS             = 'could_not_process';
50
    const FAILURE_DEBIT_NOT_AUTHORIZED          = 'debit_not_authorized';
51
    const FAILURE_DECLINED                      = 'declined';
52
    const FAILURE_INCORRECT_ACCOUNT_HOLDER_NAME = 'incorrect_account_holder_name';
53
    const FAILURE_INSUFFICIENT_FUNDS            = 'insufficient_funds';
54
    const FAILURE_INVALID_ACCOUNT_NUMBER        = 'invalid_account_number';
55
    const FAILURE_INVALID_CURRENCY              = 'invalid_currency';
56
    const FAILURE_NO_ACCOUNT                    = 'no_account';
57
    const FAILURE_UNSUPPORTED_CARD              = 'unsupported_card';
58
59
    /**
60
     * Possible string representations of the payout methods.
61
     * @link https://stripe.com/docs/api/payouts/object#payout_object-method
62
     */
63
    const METHOD_STANDARD = 'standard';
64
    const METHOD_INSTANT  = 'instant';
65
66
    /**
67
     * Possible string representations of the status of the payout.
68
     * @link https://stripe.com/docs/api/payouts/object#payout_object-status
69
     */
70
    const STATUS_CANCELED   = 'canceled';
71
    const STATUS_IN_TRANSIT = 'in_transit';
72
    const STATUS_FAILED     = 'failed';
73
    const STATUS_PAID       = 'paid';
74
    const STATUS_PENDING    = 'pending';
75
76
    /**
77
     * Possible string representations of the type of payout.
78
     * @link https://stripe.com/docs/api/payouts/object#payout_object-type
79
     */
80
    const TYPE_BANK_ACCOUNT = 'bank_account';
81
    const TYPE_CARD         = 'card';
82
83
    /**
84
     * @return Payout The canceled payout.
85
     */
86
    public function cancel()
87
    {
88
        $url = $this->instanceUrl() . '/cancel';
89
        list($response, $opts) = $this->_request('post', $url);
90
        $this->refreshFrom($response, $opts);
91
        return $this;
92
    }
93
}
94