Completed
Push — master ( e2218d...b273ad )
by Olivier
12s queued 10s
created

LastPaymentError::getPaymentMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Shapin\Stripe\Model\PaymentIntent;
11
12
use Shapin\Stripe\Model\CreatableFromArray;
13
use Shapin\Stripe\Model\Source\Source;
14
15
final class LastPaymentError implements CreatableFromArray
16
{
17
    const TYPE_API_CONNECTION_ERROR = 'api_connection_error';
18
    const TYPE_API_ERROR = 'api_error';
19
    const TYPE_AUTHENTICATION_ERROR = 'authentication_error';
20
    const TYPE_CARD_ERROR = 'card_error';
21
    const TYPE_IDEMPOTENCY_ERROR = 'idempotency_error';
22
    const TYPE_INVALID_REQUEST_ERROR = 'invalid_request_error';
23
    const TYPE_RATE_LIMIT_ERROR = 'rate_limit_error';
24
25
    /**
26
     * @var string
27
     */
28
    private $type;
29
30
    /**
31
     * @var ?string
32
     */
33
    private $chargeId;
34
35
    /**
36
     * @var ?string
37
     */
38
    private $code;
39
40
    /**
41
     * @var ?string
42
     */
43
    private $declineCode;
44
45
    /**
46
     * @var string
47
     */
48
    private $docUrl;
49
50
    /**
51
     * @var string
52
     */
53
    private $message;
54
55
    /**
56
     * @var ?string
57
     */
58
    private $param;
59
60
    /**
61
     * @var ?PaymentIntent
62
     */
63
    private $paymentIntent;
64
65
    /**
66
     * @var ?Source
67
     */
68
    private $source;
69
70
    public static function createFromArray(array $data): self
71
    {
72
        $model = new self();
73
        $model->type = $data['type'];
74
        $model->chargeId = $data['charge_id'] ?? null;
75
        $model->code = $data['code'] ?? null;
76
        $model->declineCode = $data['decline_code'] ?? null;
77
        $model->docUrl = $data['doc_url'];
78
        $model->message = $data['message'];
79
        $model->param = $data['param'] ?? null;
80
        $model->paymentIntent = isset($data['payment_intent']) ? PaymentIntent::createFromArray($data['payment_intent']) : null;
81
        $model->source = isset($data['source']) ? Source::createFromArray($data['source']) : null;
82
83
        return $model;
84
    }
85
86
    public function getType(): string
87
    {
88
        return $this->type;
89
    }
90
91
    public function getChargeId(): ?string
92
    {
93
        return $this->chargeId;
94
    }
95
96
    public function getCode(): ?string
97
    {
98
        return $this->code;
99
    }
100
101
    public function getDeclineCode(): ?string
102
    {
103
        return $this->declineCode;
104
    }
105
106
    public function getDocUrl(): ?string
107
    {
108
        return $this->docUrl;
109
    }
110
111
    public function getMessage(): string
112
    {
113
        return $this->message;
114
    }
115
116
    public function getParam(): ?string
117
    {
118
        return $this->param;
119
    }
120
121
    public function getPaymentIntent(): ?PaymentIntent
122
    {
123
        return $this->paymentIntent;
124
    }
125
126
    public function getSource(): ?Source
127
    {
128
        return $this->source;
129
    }
130
}
131