|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Assert\Assert; |
|
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
8
|
|
|
|
|
9
|
|
|
class Configuration implements ConfigurationInterface |
|
10
|
|
|
{ |
|
11
|
|
|
public function getConfigTreeBuilder() |
|
12
|
|
|
{ |
|
13
|
|
|
$treeBuilder = new TreeBuilder(); |
|
14
|
|
|
$rootNode = $treeBuilder->root('loevgaard_dandomain_altapay'); |
|
15
|
|
|
|
|
16
|
|
|
$rootNode |
|
17
|
|
|
->children() |
|
18
|
|
|
->scalarNode('altapay_username') |
|
19
|
|
|
->isRequired() |
|
20
|
|
|
->cannotBeEmpty() |
|
21
|
|
|
->end() |
|
22
|
|
|
->scalarNode('altapay_password') |
|
23
|
|
|
->isRequired() |
|
24
|
|
|
->cannotBeEmpty() |
|
25
|
|
|
->end() |
|
26
|
|
|
->arrayNode('altapay_ips') |
|
27
|
|
|
->isRequired() |
|
28
|
|
|
->requiresAtLeastOneElement() |
|
29
|
|
|
->prototype('scalar')->end() |
|
30
|
|
|
->end() |
|
31
|
|
|
->scalarNode('altapay_url') |
|
32
|
|
|
->isRequired() |
|
33
|
|
|
->cannotBeEmpty() |
|
34
|
|
|
->beforeNormalization() |
|
35
|
|
|
->ifString() |
|
36
|
|
|
->then(function ($v) { |
|
37
|
|
|
return rtrim($v, '/'); |
|
38
|
|
|
}) |
|
39
|
|
|
->end() |
|
40
|
|
|
->validate() |
|
41
|
|
|
->ifTrue(function ($v) { |
|
42
|
|
|
return filter_var($v, FILTER_VALIDATE_URL) === false; |
|
43
|
|
|
}) |
|
44
|
|
|
->thenInvalid('The URL is invalid') |
|
45
|
|
|
->end() |
|
46
|
|
|
->end() |
|
47
|
|
|
->scalarNode('shared_key_1') |
|
48
|
|
|
->isRequired() |
|
49
|
|
|
->cannotBeEmpty() |
|
50
|
|
|
->end() |
|
51
|
|
|
->scalarNode('shared_key_2') |
|
52
|
|
|
->isRequired() |
|
53
|
|
|
->cannotBeEmpty() |
|
54
|
|
|
->end() |
|
55
|
|
|
->scalarNode('terminal_class') |
|
56
|
|
|
->isRequired() |
|
57
|
|
|
->cannotBeEmpty() |
|
58
|
|
|
->end() |
|
59
|
|
|
->scalarNode('callback_class') |
|
60
|
|
|
->isRequired() |
|
61
|
|
|
->cannotBeEmpty() |
|
62
|
|
|
->end() |
|
63
|
|
|
->scalarNode('http_transaction_class') |
|
64
|
|
|
->isRequired() |
|
65
|
|
|
->cannotBeEmpty() |
|
66
|
|
|
->end() |
|
67
|
|
|
->scalarNode('payment_class') |
|
68
|
|
|
->isRequired() |
|
69
|
|
|
->cannotBeEmpty() |
|
70
|
|
|
->end() |
|
71
|
|
|
->scalarNode('payment_line_class') |
|
72
|
|
|
->isRequired() |
|
73
|
|
|
->cannotBeEmpty() |
|
74
|
|
|
->end() |
|
75
|
|
|
->scalarNode('cookie_payment_id') |
|
76
|
|
|
->defaultValue('payment_id') |
|
77
|
|
|
->end() |
|
78
|
|
|
->scalarNode('cookie_checksum_complete') |
|
79
|
|
|
->defaultValue('checksum_complete') |
|
80
|
|
|
->end() |
|
81
|
|
|
->end() |
|
82
|
|
|
->fixXmlConfig('altapay_ip') |
|
83
|
|
|
; |
|
84
|
|
|
|
|
85
|
|
|
return $treeBuilder; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|