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\SyliusQuadPayPlugin\Form\Type; |
14
|
|
|
|
15
|
|
|
use Sylius\Bundle\MoneyBundle\Form\Type\MoneyType; |
16
|
|
|
use Symfony\Component\Form\AbstractType; |
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 QuadPayGatewayConfigurationType extends AbstractType |
24
|
|
|
{ |
25
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void |
26
|
|
|
{ |
27
|
|
|
$builder |
28
|
|
|
->add('clientId', TextType::class, [ |
29
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.client_id', |
30
|
|
|
'constraints' => [ |
31
|
|
|
new NotBlank([ |
32
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.client_id.not_blank', |
33
|
|
|
'groups' => ['sylius'], |
34
|
|
|
]), |
35
|
|
|
], |
36
|
|
|
]) |
37
|
|
|
->add('clientSecret', TextType::class, [ |
38
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.client_secret', |
39
|
|
|
'constraints' => [ |
40
|
|
|
new NotBlank([ |
41
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.client_secret.not_blank', |
42
|
|
|
'groups' => ['sylius'], |
43
|
|
|
]), |
44
|
|
|
], |
45
|
|
|
]) |
46
|
|
|
->add('apiEndpoint', TextType::class, [ |
47
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.api_endpoint', |
48
|
|
|
'constraints' => [ |
49
|
|
|
new NotBlank([ |
50
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.api_endpoint.not_blank', |
51
|
|
|
'groups' => ['sylius'], |
52
|
|
|
]), |
53
|
|
|
], |
54
|
|
|
]) |
55
|
|
|
->add('authTokenEndpoint', TextType::class, [ |
56
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.auth_token_endpoint', |
57
|
|
|
'constraints' => [ |
58
|
|
|
new NotBlank([ |
59
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.auth_token_endpoint.not_blank', |
60
|
|
|
'groups' => ['sylius'], |
61
|
|
|
]), |
62
|
|
|
], |
63
|
|
|
]) |
64
|
|
|
->add('apiAudience', TextType::class, [ |
65
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.api_audience', |
66
|
|
|
'constraints' => [ |
67
|
|
|
new NotBlank([ |
68
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.api_audience.not_blank', |
69
|
|
|
'groups' => ['sylius'], |
70
|
|
|
]), |
71
|
|
|
], |
72
|
|
|
]) |
73
|
|
|
->add('minimumAmount', MoneyType::class, [ |
74
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.minimum_amount', |
75
|
|
|
'currency' => 'USD', |
76
|
|
|
'constraints' => [ |
77
|
|
|
new NotBlank([ |
78
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.minimum_amount.not_blank', |
79
|
|
|
'groups' => ['sylius'], |
80
|
|
|
]), |
81
|
|
|
], |
82
|
|
|
]) |
83
|
|
|
->add('maximumAmount', MoneyType::class, [ |
84
|
|
|
'label' => 'bitbag_sylius_quadpay_plugin.ui.maximum_amount', |
85
|
|
|
'currency' => 'USD', |
86
|
|
|
'constraints' => [ |
87
|
|
|
new NotBlank([ |
88
|
|
|
'message' => 'bitbag_sylius_quadpay_plugin.payment_method.maximum_amount.not_blank', |
89
|
|
|
'groups' => ['sylius'], |
90
|
|
|
]), |
91
|
|
|
], |
92
|
|
|
]) |
93
|
|
|
->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { |
94
|
|
|
$data = $event->getData(); |
95
|
|
|
|
96
|
|
|
$data['payum.http_client'] = '@bitbag_sylius_quadpay_plugin.quadpay_api_client'; |
97
|
|
|
|
98
|
|
|
$event->setData($data); |
99
|
|
|
}) |
100
|
|
|
; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|