|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Settings |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2019 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\Adyen |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\Adyen; |
|
12
|
|
|
|
|
13
|
|
|
use Pronamic\WordPress\Pay\Core\GatewaySettings; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Settings |
|
17
|
|
|
* |
|
18
|
|
|
* @author Remco Tolsma |
|
19
|
|
|
* @version 1.0.0 |
|
20
|
|
|
* @since 1.0.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
class Settings extends GatewaySettings { |
|
23
|
|
|
/** |
|
24
|
|
|
* Constructs and initialize settings. |
|
25
|
|
|
*/ |
|
26
|
1 |
|
public function __construct() { |
|
27
|
1 |
|
add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
|
28
|
1 |
|
add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
|
29
|
1 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Sections. |
|
33
|
|
|
* |
|
34
|
|
|
* @param array $sections Sections. |
|
35
|
|
|
* @return array |
|
36
|
|
|
*/ |
|
37
|
1 |
|
public function sections( array $sections ) { |
|
38
|
1 |
|
$sections['adyen'] = array( |
|
39
|
1 |
|
'title' => __( 'Adyen', 'pronamic_ideal' ), |
|
40
|
|
|
'methods' => array( 'adyen' ), |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
// Transaction feedback. |
|
44
|
1 |
|
$sections['adyen_feedback'] = array( |
|
45
|
1 |
|
'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
46
|
|
|
'methods' => array( 'adyen' ), |
|
47
|
1 |
|
'description' => sprintf( |
|
48
|
1 |
|
'%s %s', |
|
49
|
1 |
|
__( |
|
50
|
1 |
|
'The URLs below need to be copied to the payment provider dashboard to receive automatic transaction status updates.', |
|
51
|
1 |
|
'pronamic_ideal' |
|
52
|
|
|
), |
|
53
|
1 |
|
__( |
|
54
|
1 |
|
'Set the user name and password below and in the webhook authentication settings in the Adyen dashboard for increased security (recommended).', |
|
55
|
1 |
|
'pronamic_ideal' |
|
56
|
|
|
) |
|
57
|
|
|
), |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
1 |
|
return $sections; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Fields. |
|
65
|
|
|
* |
|
66
|
|
|
* @param array $fields Fields. |
|
67
|
|
|
* @return array |
|
68
|
|
|
*/ |
|
69
|
1 |
|
public function fields( array $fields ) { |
|
70
|
|
|
// API Key. |
|
71
|
1 |
|
$fields[] = array( |
|
72
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
|
73
|
1 |
|
'section' => 'adyen', |
|
74
|
1 |
|
'meta_key' => '_pronamic_gateway_adyen_api_key', |
|
75
|
1 |
|
'title' => _x( 'API Key', 'adyen', 'pronamic_ideal' ), |
|
76
|
1 |
|
'type' => 'textarea', |
|
77
|
|
|
'classes' => array( 'code' ), |
|
78
|
|
|
'methods' => array( 'adyen' ), |
|
79
|
1 |
|
'tooltip' => __( 'API key as mentioned in the payment provider dashboard', 'pronamic_ideal' ), |
|
80
|
|
|
); |
|
81
|
|
|
|
|
82
|
|
|
// Live API URL prefix. |
|
83
|
1 |
|
$fields[] = array( |
|
84
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
|
85
|
1 |
|
'section' => 'adyen', |
|
86
|
1 |
|
'meta_key' => '_pronamic_gateway_adyen_live_url_prefix', |
|
87
|
1 |
|
'title' => _x( 'API Live URL Prefix', 'adyen', 'pronamic_ideal' ), |
|
88
|
1 |
|
'type' => 'text', |
|
89
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
90
|
|
|
'methods' => array( 'adyen' ), |
|
91
|
1 |
|
'tooltip' => __( 'The unique prefix for the live API URL, as mentioned at <strong>Account » API URLs</strong> in the Adyen dashboard', 'pronamic_ideal' ), |
|
92
|
|
|
); |
|
93
|
|
|
|
|
94
|
|
|
// Merchant Account. |
|
95
|
1 |
|
$fields[] = array( |
|
96
|
1 |
|
'filter' => FILTER_SANITIZE_STRING, |
|
97
|
1 |
|
'section' => 'adyen', |
|
98
|
1 |
|
'meta_key' => '_pronamic_gateway_adyen_merchant_account', |
|
99
|
1 |
|
'title' => _x( 'Merchant Account', 'adyen', 'pronamic_ideal' ), |
|
100
|
1 |
|
'type' => 'text', |
|
101
|
|
|
'classes' => array( 'regular-text', 'code' ), |
|
102
|
|
|
'methods' => array( 'adyen' ), |
|
103
|
1 |
|
'tooltip' => __( 'The merchant account identifier, with which you want to process the transaction', 'pronamic_ideal' ), |
|
104
|
|
|
); |
|
105
|
|
|
|
|
106
|
|
|
// Transaction feedback. |
|
107
|
1 |
|
$fields[] = array( |
|
108
|
1 |
|
'section' => 'adyen', |
|
109
|
|
|
'methods' => array( 'adyen' ), |
|
110
|
1 |
|
'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
|
111
|
1 |
|
'type' => 'description', |
|
112
|
1 |
|
'html' => sprintf( |
|
113
|
1 |
|
'<span class="dashicons dashicons-warning"></span> %s', |
|
114
|
1 |
|
__( |
|
115
|
1 |
|
'Receiving payment status updates needs additional configuration, if not yet completed.', |
|
116
|
1 |
|
'pronamic_ideal' |
|
117
|
|
|
) |
|
118
|
|
|
), |
|
119
|
|
|
); |
|
120
|
|
|
|
|
121
|
|
|
// Webhook URL. |
|
122
|
1 |
|
$fields[] = array( |
|
123
|
1 |
|
'section' => 'adyen_feedback', |
|
124
|
1 |
|
'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
|
125
|
1 |
|
'type' => 'text', |
|
126
|
|
|
'classes' => array( 'large-text', 'code' ), |
|
127
|
1 |
|
'value' => get_rest_url( null, NotificationsController::REST_ROUTE_NAMESPACE . '/notifications' ), |
|
128
|
|
|
'readonly' => true, |
|
129
|
1 |
|
'tooltip' => sprintf( |
|
130
|
|
|
/* translators: %s: Adyen */ |
|
131
|
1 |
|
__( |
|
132
|
1 |
|
'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', |
|
133
|
1 |
|
'pronamic_ideal' |
|
134
|
|
|
), |
|
135
|
1 |
|
__( 'Adyen', 'pronamic_ideal' ) |
|
136
|
|
|
), |
|
137
|
|
|
); |
|
138
|
|
|
|
|
139
|
|
|
// Webhook authentication settings. |
|
140
|
1 |
|
$fields[] = array( |
|
141
|
1 |
|
'section' => 'adyen_feedback', |
|
142
|
|
|
'methods' => array( 'adyen' ), |
|
143
|
1 |
|
'title' => __( 'Authentication', 'pronamic_ideal' ), |
|
144
|
1 |
|
'type' => 'description', |
|
145
|
1 |
|
'html' => sprintf( |
|
146
|
1 |
|
'For webhook authentication settings, please visit <a href="%2$s" title="Settings">%1$s settings</a>.', |
|
147
|
1 |
|
__( 'Pronamic Pay', 'pronamic_ideal' ), |
|
148
|
1 |
|
$url = add_query_arg( |
|
149
|
|
|
array( |
|
150
|
1 |
|
'page' => 'pronamic_pay_settings', |
|
151
|
|
|
), |
|
152
|
1 |
|
admin_url( 'admin.php' ) |
|
153
|
|
|
) |
|
154
|
|
|
), |
|
155
|
|
|
); |
|
156
|
|
|
|
|
157
|
1 |
|
return $fields; |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|