1 | <?php |
||
13 | class Payment implements PaymentInterface |
||
14 | { |
||
15 | /** |
||
16 | * Fee is a fixed price |
||
17 | */ |
||
18 | const FEE_FIXED = 'fixed'; |
||
19 | |||
20 | /** |
||
21 | * Fee is calculated as a percentage of total price |
||
22 | */ |
||
23 | const FEE_PERCENTAGE = 'percentage'; |
||
24 | |||
25 | /** |
||
26 | * Payment id |
||
27 | * @var int |
||
28 | */ |
||
29 | private $id; |
||
30 | |||
31 | /** |
||
32 | * Payment name |
||
33 | * @var string |
||
34 | */ |
||
35 | private $name; |
||
36 | |||
37 | /** |
||
38 | * Payment description |
||
39 | * @var string |
||
40 | */ |
||
41 | private $description; |
||
42 | |||
43 | /** |
||
44 | * Payment fee |
||
45 | * @var int|float |
||
46 | */ |
||
47 | private $fee; |
||
48 | |||
49 | /** |
||
50 | * Payment fee type (fee_fixed|fee_percentage) |
||
51 | * @var string |
||
52 | */ |
||
53 | private $feeType = self::FEE_FIXED; |
||
54 | |||
55 | /** |
||
56 | * Price format object |
||
57 | * @var \Plane\Shop\PriceFormat\PriceFormatInterface |
||
58 | */ |
||
59 | private $priceFormat; |
||
60 | |||
61 | /** |
||
62 | * Constructor |
||
63 | * @param array $data |
||
64 | */ |
||
65 | 3 | public function __construct(array $data) |
|
71 | |||
72 | /** |
||
73 | * Return id |
||
74 | * @return int |
||
75 | */ |
||
76 | 1 | public function getId() |
|
80 | |||
81 | /** |
||
82 | * Return name |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | public function getName() |
|
89 | |||
90 | /** |
||
91 | * Return description |
||
92 | * @return string |
||
93 | */ |
||
94 | 1 | public function getDescription() |
|
98 | |||
99 | /** |
||
100 | * Set fee as fixed price |
||
101 | */ |
||
102 | 1 | public function setFixed() |
|
106 | |||
107 | /** |
||
108 | * Set fee as percentage of total price |
||
109 | */ |
||
110 | 1 | public function setPercentage() |
|
114 | |||
115 | /** |
||
116 | * Return fee |
||
117 | * @param float $totalPrice |
||
118 | * @return float |
||
119 | */ |
||
120 | 3 | public function getFee($totalPrice) |
|
128 | |||
129 | /** |
||
130 | * Set price format object |
||
131 | * @param \Plane\Shop\PriceFormat\PriceFormatInterface $priceFormat |
||
132 | */ |
||
133 | 1 | public function setPriceFormat(PriceFormatInterface $priceFormat) |
|
137 | |||
138 | /** |
||
139 | * Calculate fee based on feeType |
||
140 | * @param double $totalPrice |
||
141 | * @return float |
||
142 | */ |
||
143 | 3 | protected function calculateFee($totalPrice) |
|
151 | } |
||
152 |