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\Refund; |
11
|
|
|
|
12
|
|
|
use Money\Currency; |
13
|
|
|
use Money\Money; |
14
|
|
|
use Shapin\Stripe\Model\ContainsMetadata; |
15
|
|
|
use Shapin\Stripe\Model\CreatableFromArray; |
16
|
|
|
use Shapin\Stripe\Model\MetadataCollection; |
17
|
|
|
use Shapin\Stripe\Model\MetadataTrait; |
18
|
|
|
|
19
|
|
|
final class Refund implements CreatableFromArray, ContainsMetadata |
20
|
|
|
{ |
21
|
|
|
use MetadataTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Money |
25
|
|
|
*/ |
26
|
|
|
private $amount; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $balanceTransaction; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $charge; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var \DateTimeImmutable |
40
|
|
|
*/ |
41
|
|
|
private $createdAt; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var Currency |
45
|
|
|
*/ |
46
|
|
|
private $currency; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
private $failureBalanceTransaction; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $failureReason; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
private $reason; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
private $receiptNumber; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var string |
70
|
|
|
*/ |
71
|
|
|
private $sourceTransferReversal; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
private $status; |
77
|
|
|
|
78
|
8 |
|
public static function createFromArray(array $data): self |
79
|
|
|
{ |
80
|
8 |
|
$currency = new Currency(strtoupper($data['currency'])); |
81
|
|
|
|
82
|
8 |
|
$model = new self(); |
83
|
8 |
|
$model->amount = new Money($data['amount'], $currency); |
84
|
8 |
|
$model->balanceTransaction = $data['balance_transaction']; |
85
|
8 |
|
$model->charge = $data['charge']; |
86
|
8 |
|
$model->createdAt = new \DateTimeImmutable('@'.$data['created']); |
87
|
8 |
|
$model->currency = $currency; |
88
|
8 |
|
$model->failureBalanceTransaction = $data['failure_balance_transaction'] ?? null; |
89
|
8 |
|
$model->failureReason = $data['failure_reason'] ?? null; |
90
|
8 |
|
$model->metadata = MetadataCollection::createFromArray($data['metadata']); |
|
|
|
|
91
|
8 |
|
$model->reason = $data['reason']; |
92
|
8 |
|
$model->receiptNumber = $data['receipt_number']; |
93
|
8 |
|
$model->sourceTransferReversal = $data['source_transfer_reversal'] ?? null; |
94
|
8 |
|
$model->status = $data['status']; |
95
|
|
|
|
96
|
8 |
|
return $model; |
97
|
|
|
} |
98
|
|
|
|
99
|
1 |
|
public function getAmount(): Money |
100
|
|
|
{ |
101
|
1 |
|
return $this->amount; |
102
|
|
|
} |
103
|
|
|
|
104
|
1 |
|
public function getBalanceTransaction(): ?string |
105
|
|
|
{ |
106
|
1 |
|
return $this->balanceTransaction; |
107
|
|
|
} |
108
|
|
|
|
109
|
1 |
|
public function getCharge(): string |
110
|
|
|
{ |
111
|
1 |
|
return $this->charge; |
112
|
|
|
} |
113
|
|
|
|
114
|
1 |
|
public function getCreatedAt(): \DateTimeImmutable |
115
|
|
|
{ |
116
|
1 |
|
return $this->createdAt; |
117
|
|
|
} |
118
|
|
|
|
119
|
1 |
|
public function getCurrency(): Currency |
120
|
|
|
{ |
121
|
1 |
|
return $this->currency; |
122
|
|
|
} |
123
|
|
|
|
124
|
1 |
|
public function getFailureBalanceTransaction(): ?string |
125
|
|
|
{ |
126
|
1 |
|
return $this->failureBalanceTransaction; |
127
|
|
|
} |
128
|
|
|
|
129
|
1 |
|
public function getFailureReason(): ?string |
130
|
|
|
{ |
131
|
1 |
|
return $this->failureReason; |
132
|
|
|
} |
133
|
|
|
|
134
|
1 |
|
public function getReason(): ?string |
135
|
|
|
{ |
136
|
1 |
|
return $this->reason; |
137
|
|
|
} |
138
|
|
|
|
139
|
1 |
|
public function getReceiptNumber(): ?string |
140
|
|
|
{ |
141
|
1 |
|
return $this->receiptNumber; |
142
|
|
|
} |
143
|
|
|
|
144
|
1 |
|
public function getSourceTransferReversal(): ?string |
145
|
|
|
{ |
146
|
1 |
|
return $this->sourceTransferReversal; |
147
|
|
|
} |
148
|
|
|
|
149
|
1 |
|
public function getStatus(): string |
150
|
|
|
{ |
151
|
1 |
|
return $this->status; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..