1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusBraintreePlugin\Form\Type; |
14
|
|
|
|
15
|
|
|
use Symfony\Component\Form\AbstractType; |
16
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
17
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
18
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
19
|
|
|
use Symfony\Component\Form\FormEvent; |
20
|
|
|
use Symfony\Component\Form\FormEvents; |
21
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
22
|
|
|
|
23
|
|
|
final class BraintreeGatewayConfigurationType extends AbstractType |
24
|
|
|
{ |
25
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
26
|
|
|
{ |
27
|
|
|
$builder |
28
|
|
|
->add('merchantId', TextType::class, [ |
29
|
|
|
'label' => 'bitbag_sylius_braintree_plugin.ui.merchant_id', |
30
|
|
|
'constraints' => [ |
31
|
|
|
new NotBlank([ |
32
|
|
|
'message' => 'bitbag_sylius_braintree_plugin.merchant_id.not_blank', |
33
|
|
|
'groups' => 'sylius', |
34
|
|
|
]), |
35
|
|
|
], |
36
|
|
|
]) |
37
|
|
|
->add('publicKey', TextType::class, [ |
38
|
|
|
'label' => 'bitbag_sylius_braintree_plugin.ui.public_key', |
39
|
|
|
'constraints' => [ |
40
|
|
|
new NotBlank([ |
41
|
|
|
'message' => 'bitbag_sylius_braintree_plugin.public_key.not_blank', |
42
|
|
|
'groups' => 'sylius', |
43
|
|
|
]), |
44
|
|
|
], |
45
|
|
|
]) |
46
|
|
|
->add('privateKey', TextType::class, [ |
47
|
|
|
'label' => 'bitbag_sylius_braintree_plugin.ui.private_key', |
48
|
|
|
'constraints' => [ |
49
|
|
|
new NotBlank([ |
50
|
|
|
'message' => 'bitbag_sylius_braintree_plugin.private_key.not_blank', |
51
|
|
|
'groups' => 'sylius', |
52
|
|
|
]), |
53
|
|
|
], |
54
|
|
|
]) |
55
|
|
|
->add('sandbox', CheckboxType::class, [ |
56
|
|
|
'label' => 'bitbag_sylius_braintree_plugin.ui.sandbox', |
57
|
|
|
]) |
58
|
|
|
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { |
59
|
|
|
$data = $event->getData(); |
60
|
|
|
|
61
|
|
|
$data['payum.http_client'] = '@bitbag_sylius_braintree_plugin.api_client.braintree'; |
62
|
|
|
|
63
|
|
|
$event->setData($data); |
64
|
|
|
}) |
65
|
|
|
; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|