|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// --------------------------------------------------------------------- |
|
4
|
|
|
// |
|
5
|
|
|
// Copyright (C) 2018-2024 Artem Rodygin |
|
6
|
|
|
// |
|
7
|
|
|
// You should have received a copy of the MIT License along with |
|
8
|
|
|
// this file. If not, see <https://opensource.org/licenses/MIT>. |
|
9
|
|
|
// |
|
10
|
|
|
// --------------------------------------------------------------------- |
|
11
|
|
|
|
|
12
|
|
|
namespace Linode\Account; |
|
13
|
|
|
|
|
14
|
|
|
use Linode\Entity; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Payment Method Response Object. |
|
18
|
|
|
* |
|
19
|
|
|
* @property int $id The unique ID of this Payment Method. |
|
20
|
|
|
* @property string $type The type of Payment Method. |
|
21
|
|
|
* @property bool $is_default Whether this Payment Method is the default method for automatically processing |
|
22
|
|
|
* service charges. |
|
23
|
|
|
* @property string $created When the Payment Method was added to the Account. |
|
24
|
|
|
* @property CreditCardData|PayPalData $data |
|
25
|
|
|
*/ |
|
26
|
|
|
class PaymentMethod extends Entity |
|
27
|
|
|
{ |
|
28
|
|
|
// Available fields. |
|
29
|
|
|
public const FIELD_ID = 'id'; |
|
30
|
|
|
public const FIELD_TYPE = 'type'; |
|
31
|
|
|
public const FIELD_IS_DEFAULT = 'is_default'; |
|
32
|
|
|
public const FIELD_CREATED = 'created'; |
|
33
|
|
|
public const FIELD_DATA = 'data'; |
|
34
|
|
|
|
|
35
|
|
|
// `FIELD_TYPE` values. |
|
36
|
|
|
public const TYPE_CREDIT_CARD = 'credit_card'; |
|
37
|
|
|
public const TYPE_GOOGLE_PAY = 'google_pay'; |
|
38
|
|
|
public const TYPE_PAYPAL = 'paypal'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __get(string $name): mixed |
|
44
|
|
|
{ |
|
45
|
|
|
return match ($name) { |
|
46
|
|
|
self::FIELD_DATA => isset($this->data[$name]['card_type']) ? new CreditCardData($this->client, $this->data[$name]) : new PayPalData($this->client, $this->data[$name]), |
|
47
|
|
|
default => parent::__get($name), |
|
48
|
|
|
}; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|