1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file was created by developers working at BitBag |
5
|
|
|
* Do you need more information about us and what we do? Visit our https://bitbag.io website! |
6
|
|
|
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace BitBag\SyliusMultiSafepayPlugin\Form\Type; |
12
|
|
|
|
13
|
|
|
use BitBag\SyliusMultiSafepayPlugin\ApiClient\MultiSafepayApiClientInterface; |
14
|
|
|
use Symfony\Component\Form\AbstractType; |
15
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType; |
16
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
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 MultiSafepayGatewayConfigurationType extends AbstractType |
24
|
|
|
{ |
25
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
26
|
|
|
{ |
27
|
|
|
$builder |
28
|
|
|
->add('apiKey', TextType::class, [ |
29
|
|
|
'label' => 'bitbag_sylius_multisafepay.ui.api_key', |
30
|
|
|
'constraints' => [ |
31
|
|
|
new NotBlank([ |
32
|
|
|
'message' => 'bitbag_sylius_multisafepay.api_key.not_blank', |
33
|
|
|
'groups' => 'sylius', |
34
|
|
|
]), |
35
|
|
|
], |
36
|
|
|
]) |
37
|
|
|
->add('sandbox', CheckboxType::class, [ |
38
|
|
|
'label' => 'bitbag_sylius_multisafepay.ui.sandbox', |
39
|
|
|
]) |
40
|
|
|
->add('allow_multi_currency', CheckboxType::class, [ |
41
|
|
|
'label' => 'bitbag_sylius_multisafepay.ui.allow_multi_currency', |
42
|
|
|
]) |
43
|
|
|
->add('type', ChoiceType::class, [ |
44
|
|
|
'label' => 'bitbag_sylius_multisafepay.ui.type', |
45
|
|
|
'choices' => [ |
46
|
|
|
'bitbag_sylius_multisafepay.ui.payment_link' => MultiSafepayApiClientInterface::PAYMENT_LINK_TYPE, |
47
|
|
|
'bitbag_sylius_multisafepay.ui.redirect_order' => MultiSafepayApiClientInterface::REDIRECT_ORDER_TYPE, |
48
|
|
|
], |
49
|
|
|
'constraints' => [ |
50
|
|
|
new NotBlank([ |
51
|
|
|
'message' => 'bitbag_sylius_multisafepay.type.not_blank', |
52
|
|
|
'groups' => 'sylius', |
53
|
|
|
]), |
54
|
|
|
], |
55
|
|
|
]) |
56
|
|
|
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void { |
57
|
|
|
$data = $event->getData(); |
58
|
|
|
|
59
|
|
|
$data['payum.http_client'] = '@bitbag_sylius_multisafepay_plugin.api_client.multisafepay_api_client'; |
60
|
|
|
|
61
|
|
|
$event->setData($data); |
62
|
|
|
}) |
63
|
|
|
; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|