1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Yves\Payone\Form; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\PaymentTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\PayonePaymentCreditCardTransfer; |
|
|
|
|
12
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface; |
13
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
14
|
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
16
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
17
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @method \SprykerEco\Yves\Payone\PayoneConfig getConfig() |
21
|
|
|
*/ |
22
|
|
|
class CreditCardSubForm extends AbstractPayoneSubForm |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
public const PAYMENT_METHOD = 'credit_card'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
public const FIELD_CARD_TYPE = 'cardtype'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
public const FIELD_CARD_NUMBER = 'cardpan'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public const FIELD_NAME_ON_CARD = 'cardholder'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
public const FIELD_CARD_EXPIRES_MONTH = 'cardexpiredate_month'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public const FIELD_CARD_EXPIRES_YEAR = 'cardexpiredate_year'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
public const FIELD_CARD_SECURITY_CODE = 'cardcvc2'; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
public const FIELD_PSEUDO_CARD_NUMBER = 'pseudocardpan'; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var string |
66
|
|
|
*/ |
67
|
|
|
public const OPTION_CARD_EXPIRES_CHOICES_MONTH = 'month choices'; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
public const OPTION_CARD_EXPIRES_CHOICES_YEAR = 'year choices'; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @var string |
76
|
|
|
*/ |
77
|
|
|
public const OPTION_CARD_TYPES = 'card types'; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
public const OPTION_PAYONE_SETTINGS = 'payone settings'; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getName(): string |
88
|
|
|
{ |
89
|
|
|
return PaymentTransfer::PAYONE_CREDIT_CARD; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public function getPropertyPath(): string |
96
|
|
|
{ |
97
|
|
|
return PaymentTransfer::PAYONE_CREDIT_CARD; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
102
|
|
|
* |
103
|
|
|
* @return void |
104
|
|
|
*/ |
105
|
|
|
public function configureOptions(OptionsResolver $resolver): void |
106
|
|
|
{ |
107
|
|
|
$resolver->setDefaults([ |
108
|
|
|
'data_class' => PayonePaymentCreditCardTransfer::class, |
109
|
|
|
])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver |
114
|
|
|
* |
115
|
|
|
* @return void |
116
|
|
|
*/ |
117
|
|
|
public function setDefaultOptions(OptionsResolver $resolver): void |
118
|
|
|
{ |
119
|
|
|
$this->configureOptions($resolver); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
124
|
|
|
* @param array $options |
125
|
|
|
* |
126
|
|
|
* @return void |
127
|
|
|
*/ |
128
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
129
|
|
|
{ |
130
|
|
|
$this->addNameOnCard($builder) |
131
|
|
|
->addHiddenInputs($builder); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @deprecated Card types from iFrame should be used instead. |
136
|
|
|
* |
137
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
138
|
|
|
* @param array $options |
139
|
|
|
* |
140
|
|
|
* @return $this |
141
|
|
|
*/ |
142
|
|
|
public function addCardType(FormBuilderInterface $builder, array $options) |
143
|
|
|
{ |
144
|
|
|
$builder->add( |
145
|
|
|
static::FIELD_CARD_TYPE, |
146
|
|
|
ChoiceType::class, |
147
|
|
|
[ |
148
|
|
|
'choices' => $options[static::OPTIONS_FIELD_NAME][static::OPTION_CARD_TYPES], |
149
|
|
|
'label' => false, |
150
|
|
|
'required' => true, |
151
|
|
|
'expanded' => false, |
152
|
|
|
'multiple' => false, |
153
|
|
|
'placeholder' => false, |
154
|
|
|
'constraints' => [ |
155
|
|
|
$this->createNotBlankConstraint(), |
156
|
|
|
], |
157
|
|
|
], |
158
|
|
|
); |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
165
|
|
|
* |
166
|
|
|
* @return $this |
167
|
|
|
*/ |
168
|
|
|
protected function addCardNumber(FormBuilderInterface $builder) |
169
|
|
|
{ |
170
|
|
|
$builder->add( |
171
|
|
|
static::FIELD_CARD_NUMBER, |
172
|
|
|
TextType::class, |
173
|
|
|
[ |
174
|
|
|
'label' => false, |
175
|
|
|
'required' => false, |
176
|
|
|
], |
177
|
|
|
); |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
184
|
|
|
* |
185
|
|
|
* @return $this |
186
|
|
|
*/ |
187
|
|
|
protected function addNameOnCard(FormBuilderInterface $builder) |
188
|
|
|
{ |
189
|
|
|
$builder->add( |
190
|
|
|
static::FIELD_NAME_ON_CARD, |
191
|
|
|
TextType::class, |
192
|
|
|
[ |
193
|
|
|
'label' => false, |
194
|
|
|
'required' => true, |
195
|
|
|
'constraints' => [ |
196
|
|
|
$this->createNotBlankConstraint(), |
197
|
|
|
], |
198
|
|
|
], |
199
|
|
|
); |
200
|
|
|
|
201
|
|
|
return $this; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
206
|
|
|
* @param array $options |
207
|
|
|
* |
208
|
|
|
* @return $this |
209
|
|
|
*/ |
210
|
|
|
protected function addCardExpiresMonth(FormBuilderInterface $builder, array $options) |
211
|
|
|
{ |
212
|
|
|
$builder->add( |
213
|
|
|
static::FIELD_CARD_EXPIRES_MONTH, |
214
|
|
|
ChoiceType::class, |
215
|
|
|
[ |
216
|
|
|
'label' => false, |
217
|
|
|
'choices' => $options[static::OPTIONS_FIELD_NAME][static::OPTION_CARD_EXPIRES_CHOICES_MONTH], |
218
|
|
|
'required' => true, |
219
|
|
|
'constraints' => [ |
220
|
|
|
$this->createNotBlankConstraint(), |
221
|
|
|
], |
222
|
|
|
], |
223
|
|
|
); |
224
|
|
|
|
225
|
|
|
return $this; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
230
|
|
|
* @param array $options |
231
|
|
|
* |
232
|
|
|
* @return $this |
233
|
|
|
*/ |
234
|
|
|
protected function addCardExpiresYear(FormBuilderInterface $builder, array $options) |
235
|
|
|
{ |
236
|
|
|
$builder->add( |
237
|
|
|
static::FIELD_CARD_EXPIRES_YEAR, |
238
|
|
|
ChoiceType::class, |
239
|
|
|
[ |
240
|
|
|
'label' => false, |
241
|
|
|
'choices' => $options[static::OPTIONS_FIELD_NAME][static::OPTION_CARD_EXPIRES_CHOICES_YEAR], |
242
|
|
|
'required' => true, |
243
|
|
|
'attr' => [ |
244
|
|
|
'placeholder' => 'Expires year', |
245
|
|
|
], |
246
|
|
|
'constraints' => [ |
247
|
|
|
$this->createNotBlankConstraint(), |
248
|
|
|
], |
249
|
|
|
], |
250
|
|
|
); |
251
|
|
|
|
252
|
|
|
return $this; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
257
|
|
|
* |
258
|
|
|
* @return $this |
259
|
|
|
*/ |
260
|
|
|
protected function addCardSecurityCode(FormBuilderInterface $builder) |
261
|
|
|
{ |
262
|
|
|
$builder->add( |
263
|
|
|
static::FIELD_CARD_SECURITY_CODE, |
264
|
|
|
TextType::class, |
265
|
|
|
[ |
266
|
|
|
'label' => false, |
267
|
|
|
'required' => false, |
268
|
|
|
], |
269
|
|
|
); |
270
|
|
|
|
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
276
|
|
|
* |
277
|
|
|
* @return $this |
278
|
|
|
*/ |
279
|
|
|
protected function addHiddenInputs(FormBuilderInterface $builder) |
280
|
|
|
{ |
281
|
|
|
parent::addHiddenInputs($builder); |
282
|
|
|
|
283
|
|
|
$builder->add( |
284
|
|
|
static::FIELD_PSEUDO_CARD_NUMBER, |
285
|
|
|
HiddenType::class, |
286
|
|
|
[ |
287
|
|
|
'label' => false, |
288
|
|
|
], |
289
|
|
|
); |
290
|
|
|
|
291
|
|
|
return $this; |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths