|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Magium\Magento\Actions\Checkout; |
|
4
|
|
|
|
|
5
|
|
|
use Magium\AbstractConfigurableElement; |
|
6
|
|
|
use Magium\Util\Configuration\ConfigurationCollector\DefaultPropertyCollector; |
|
7
|
|
|
use Magium\Util\Configuration\StandardConfigurationProvider; |
|
8
|
|
|
|
|
9
|
|
|
class PaymentInformation extends AbstractConfigurableElement |
|
10
|
|
|
{ |
|
11
|
|
|
const ACTION = 'Checkout\PaymentInformation'; |
|
12
|
|
|
|
|
13
|
|
|
public $creditCardNumber; |
|
14
|
|
|
public $expiryYear; |
|
15
|
|
|
public $expiryMonth; |
|
16
|
|
|
public $cvv; |
|
17
|
|
|
public $type; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(StandardConfigurationProvider $configurationProvider, DefaultPropertyCollector $collector) |
|
20
|
|
|
{ |
|
21
|
|
|
/* |
|
22
|
|
|
* Note: payment information is placed in this class instead of the payment step because I wanted to make |
|
23
|
|
|
* the payment easily configurable which is why this class extends AbstractConfigurableElement. The payment |
|
24
|
|
|
* step class does not extend AbstractConfigurableElement (because it needs the constructor for dependency |
|
25
|
|
|
* injection) and so this class is here so payment can be globally configured. |
|
26
|
|
|
* |
|
27
|
|
|
* This way if you want to handle your own credit card you only have to configure this class |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
parent::__construct($configurationProvider, $collector); |
|
31
|
|
|
$this->setDefaults(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
protected function setDefaults() |
|
36
|
|
|
{ |
|
37
|
|
|
if (!$this->creditCardNumber) { |
|
38
|
|
|
$this->creditCardNumber = '4111111111111111'; |
|
39
|
|
|
} |
|
40
|
|
|
if (!$this->expiryMonth) { |
|
41
|
|
|
$this->expiryMonth = '1'; |
|
42
|
|
|
} |
|
43
|
|
|
if (!$this->expiryYear) { |
|
44
|
|
|
$this->expiryYear = date('Y', time() + (60 * 60 * 24 * 365 * 5)); // January plus 5 years |
|
45
|
|
|
} |
|
46
|
|
|
if (!$this->cvv) { |
|
47
|
|
|
$this->cvv = '123'; |
|
48
|
|
|
} |
|
49
|
|
|
if (!$this->type) { |
|
50
|
|
|
$this->type = 'VI'; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getCreditCardNumber() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->creditCardNumber; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param string $creditCardNumber |
|
64
|
|
|
*/ |
|
65
|
|
|
public function setCreditCardNumber($creditCardNumber) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->creditCardNumber = $creditCardNumber; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getExpiryMonth() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->expiryMonth; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return string |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getExpiryYear() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->expiryYear; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @param string $expiryDate |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setExpiryDate($expiryDate) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->expiryDate = $expiryDate; |
|
|
|
|
|
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getType() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->type; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return string |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getCvv() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->cvv; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param string $cvv |
|
112
|
|
|
*/ |
|
113
|
|
|
public function setCvv($cvv) |
|
114
|
|
|
{ |
|
115
|
|
|
$this->cvv = $cvv; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @param mixed $expiryMonth |
|
120
|
|
|
*/ |
|
121
|
|
|
public function setExpiryMonth($expiryMonth) |
|
122
|
|
|
{ |
|
123
|
|
|
$this->expiryMonth = $expiryMonth; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param mixed $expiryYear |
|
128
|
|
|
*/ |
|
129
|
|
|
public function setExpiryYear($expiryYear) |
|
130
|
|
|
{ |
|
131
|
|
|
$this->expiryYear = $expiryYear; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* @param mixed $type |
|
136
|
|
|
*/ |
|
137
|
|
|
public function setType($type) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->type = $type; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
|
|
143
|
|
|
|
|
144
|
|
|
} |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.