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

PaymentIntent::capture()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stripe;
4
5
/**
6
 * Class PaymentIntent
7
 *
8
 * @property string $id
9
 * @property string $object
10
 * @property int $amount
11
 * @property int $amount_capturable
12
 * @property int $amount_received
13
 * @property string $application
14
 * @property int $application_fee_amount
15
 * @property int $canceled_at
16
 * @property string $cancellation_reason
17
 * @property string $capture_method
18
 * @property Collection $charges
19
 * @property string $client_secret
20
 * @property string $confirmation_method
21
 * @property int $created
22
 * @property string $currency
23
 * @property string $customer
24
 * @property string $description
25
 * @property mixed $last_payment_error
26
 * @property bool $livemode
27
 * @property StripeObject $metadata
28
 * @property mixed $next_action
29
 * @property string $on_behalf_of
30
 * @property string $payment_method
31
 * @property string[] $payment_method_types
32
 * @property string $receipt_email
33
 * @property string $review
34
 * @property mixed $shipping
35
 * @property string $source
36
 * @property string $statement_descriptor
37
 * @property string $status
38
 * @property mixed $transfer_data
39
 * @property string $transfer_group
40
 *
41
 * @package Stripe
42
 */
43
class PaymentIntent extends ApiResource
44
{
45
46
    const OBJECT_NAME = "payment_intent";
47
48
    use ApiOperations\All;
49
    use ApiOperations\Create;
50
    use ApiOperations\Retrieve;
51
    use ApiOperations\Update;
52
53
    /**
54
     * These constants are possible representations of the status field.
55
     *
56
     * @link https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
57
     */
58
    const STATUS_CANCELED                = 'canceled';
59
    const STATUS_PROCESSING              = 'processing';
60
    const STATUS_REQUIRES_ACTION         = 'requires_action';
61
    const STATUS_REQUIRES_CAPTURE        = 'requires_capture';
62
    const STATUS_REQUIRES_CONFIRMATION   = 'requires_confirmation';
63
    const STATUS_REQUIRES_PAYMENT_METHOD = 'requires_payment_method';
64
    const STATUS_SUCCEEDED               = 'succeeded';
65
66
    /**
67
     * @param array|null $params
68
     * @param array|string|null $options
69
     *
70
     * @return PaymentIntent The canceled payment intent.
71
     */
72
    public function cancel($params = null, $options = null)
73
    {
74
        $url = $this->instanceUrl() . '/cancel';
75
        list($response, $opts) = $this->_request('post', $url, $params, $options);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
76
        $this->refreshFrom($response, $opts);
77
        return $this;
78
    }
79
80
    /**
81
     * @param array|null $params
82
     * @param array|string|null $options
83
     *
84
     * @return PaymentIntent The captured payment intent.
85
     */
86
    public function capture($params = null, $options = null)
87
    {
88
        $url = $this->instanceUrl() . '/capture';
89
        list($response, $opts) = $this->_request('post', $url, $params, $options);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
90
        $this->refreshFrom($response, $opts);
91
        return $this;
92
    }
93
94
    /**
95
     * @param array|null $params
96
     * @param array|string|null $options
97
     *
98
     * @return PaymentIntent The confirmed payment intent.
99
     */
100
    public function confirm($params = null, $options = null)
101
    {
102
        $url = $this->instanceUrl() . '/confirm';
103
        list($response, $opts) = $this->_request('post', $url, $params, $options);
0 ignored issues
show
Bug introduced by
It seems like $params can also be of type null; however, Stripe\ApiOperations\Request::_request() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
104
        $this->refreshFrom($response, $opts);
105
        return $this;
106
    }
107
}
108