@@ -1,9 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace tuyakhov\braintree; |
3 | 3 | |
4 | -use yii\base\InvalidCallException; |
|
5 | 4 | use yii\base\Model; |
6 | -use yii\base\ModelEvent; |
|
7 | 5 | |
8 | 6 | class BraintreeForm extends Model |
9 | 7 | { |
@@ -132,10 +132,18 @@ discard block |
||
132 | 132 | { |
133 | 133 | $this->options['creditCard'] = []; |
134 | 134 | $this->options['creditCard']['number'] = $number; |
135 | - if (isset($cvv)) $this->options['creditCard']['cvv'] = $cvv; |
|
136 | - if (isset($expirationMonth)) $this->options['creditCard']['expirationMonth'] = $expirationMonth; |
|
137 | - if (isset($expirationYear)) $this->options['creditCard']['expirationYear'] = $expirationYear; |
|
138 | - if (isset($expirationDate)) $this->options['creditCard']['expirationDate'] = $expirationDate; |
|
135 | + if (isset($cvv)) { |
|
136 | + $this->options['creditCard']['cvv'] = $cvv; |
|
137 | + } |
|
138 | + if (isset($expirationMonth)) { |
|
139 | + $this->options['creditCard']['expirationMonth'] = $expirationMonth; |
|
140 | + } |
|
141 | + if (isset($expirationYear)) { |
|
142 | + $this->options['creditCard']['expirationYear'] = $expirationYear; |
|
143 | + } |
|
144 | + if (isset($expirationDate)) { |
|
145 | + $this->options['creditCard']['expirationDate'] = $expirationDate; |
|
146 | + } |
|
139 | 147 | } |
140 | 148 | |
141 | 149 | public function getCreditCard($input_values) |
@@ -155,12 +163,13 @@ discard block |
||
155 | 163 | { |
156 | 164 | if (!empty($values)) { |
157 | 165 | foreach ($values as $key => $value) { |
158 | - if ($key == 'amount') |
|
159 | - $this->setAmount($values['amount']); |
|
160 | - elseif ($key == 'creditCard') |
|
161 | - $this->getCreditCard($values['creditCard']); |
|
162 | - else |
|
163 | - $this->options[$key] = $value; |
|
166 | + if ($key == 'amount') { |
|
167 | + $this->setAmount($values['amount']); |
|
168 | + } elseif ($key == 'creditCard') { |
|
169 | + $this->getCreditCard($values['creditCard']); |
|
170 | + } else { |
|
171 | + $this->options[$key] = $value; |
|
172 | + } |
|
164 | 173 | } |
165 | 174 | } |
166 | 175 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @author Anton Tuyakhov <[email protected]> |
|
4 | - */ |
|
3 | + * @author Anton Tuyakhov <[email protected]> |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | namespace tuyakhov\braintree; |
7 | 7 |