|
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 Spryker\Yves\StepEngine\Dependency\Form\AbstractSubFormType; |
|
11
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface; |
|
12
|
|
|
use Spryker\Yves\StepEngine\Dependency\Form\SubFormProviderNameInterface; |
|
13
|
|
|
use SprykerEco\Shared\Payone\PayoneConstants; |
|
14
|
|
|
use SprykerEco\Yves\Payone\Form\Constraint\BankAccount; |
|
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
|
16
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
17
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @method \SprykerEco\Client\Payone\PayoneClientInterface getClient() |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractPayoneSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface |
|
23
|
|
|
{ |
|
24
|
|
|
const PAYMENT_PROVIDER = PayoneConstants::PROVIDER_NAME; |
|
25
|
|
|
|
|
26
|
|
|
const FIELD_PAYMENT_METHOD = 'paymentMethod'; |
|
27
|
|
|
const FIELD_PAYONE_CREDENTIALS_MID = 'payone_mid'; |
|
28
|
|
|
const FIELD_PAYONE_CREDENTIALS_AID = 'payone_aid'; |
|
29
|
|
|
const FIELD_PAYONE_CREDENTIALS_PORTAL_ID = 'payone_portal_id'; |
|
30
|
|
|
const FIELD_PAYONE_HASH = 'payone_hash'; |
|
31
|
|
|
const FIELD_CLIENT_API_CONFIG = 'payone_client_api_config'; |
|
32
|
|
|
const FIELD_CLIENT_LANG_CODE = 'payone_client_lang_code'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return string |
|
36
|
|
|
*/ |
|
37
|
|
|
public function getProviderName() |
|
38
|
|
|
{ |
|
39
|
|
|
return static::PAYMENT_PROVIDER; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param \Symfony\Component\Form\FormBuilderInterface $builder |
|
44
|
|
|
* |
|
45
|
|
|
* @return $this |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function addHiddenInputs(FormBuilderInterface $builder) |
|
48
|
|
|
{ |
|
49
|
|
|
$formData = $this->getClient()->getCreditCardCheckRequest(); |
|
50
|
|
|
$builder->add( |
|
51
|
|
|
self::FIELD_CLIENT_API_CONFIG, |
|
52
|
|
|
HiddenType::class, |
|
53
|
|
|
[ |
|
54
|
|
|
'label' => false, |
|
55
|
|
|
'data' => $formData->toJson(), |
|
56
|
|
|
] |
|
57
|
|
|
); |
|
58
|
|
|
|
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return \Symfony\Component\Validator\Constraint |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function createNotBlankConstraint() |
|
66
|
|
|
{ |
|
67
|
|
|
return new NotBlank(['groups' => $this->getPropertyPath()]); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return \SprykerEco\Yves\Payone\Form\Constraint\BankAccount |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function createBankAccountConstraint() |
|
74
|
|
|
{ |
|
75
|
|
|
return new BankAccount([BankAccount::OPTION_PAYONE_CLIENT => $this->getClient()]); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|