Test Failed
Push — develop ( 7cb291...9cc0c5 )
by Reüel
03:00
created

src/Settings.php (4 issues)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Ingenico;
4
5
use Pronamic\WordPress\Pay\Core\GatewaySettings;
6
7
/**
8
 * Title: Ingenico gateway settings
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.3.0
16
 */
17
class Settings extends GatewaySettings {
18
	public function __construct() {
19
		add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
0 ignored issues
show
The function add_filter was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
		/** @scrutinizer ignore-call */ 
20
  add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
Loading history...
20
		add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) );
21
	}
22
23
	public function sections( array $sections ) {
24
		// General
25
		$sections['ogone'] = array(
26
			'title'       => __( 'Ogone', 'pronamic_ideal' ),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
			'title'       => /** @scrutinizer ignore-call */ __( 'Ogone', 'pronamic_ideal' ),
Loading history...
27
			'methods'     => array( 'ogone_orderstandard_easy', 'ogone_orderstandard', 'ogone_directlink' ),
28
			'description' => __( 'Account details are provided by the payment provider after registration. These settings need to match with the payment provider dashboard.', 'pronamic_ideal' ),
29
		);
30
31
		// Payment page look and feel
32
		$sections['ogone_advanced'] = array(
33
			'title'       => __( 'Advanced', 'pronamic_ideal' ),
34
			'methods'     => array( 'ogone_orderstandard_easy', 'ogone_orderstandard', 'ogone_directlink' ),
35
			'description' => __( 'Optional settings for advanced usage only.', 'pronamic_ideal' ),
36
		);
37
38
		// Direct HTTP server-to-server request
39
		$sections['ogone_feedback'] = array(
40
			'title'       => __( 'Transaction feedback', 'pronamic_ideal' ),
41
			'methods'     => array( 'ogone_orderstandard', 'ogone_directlink' ),
42
			'description' => __( 'The URLs below need to be copied to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
43
		);
44
45
		// Return sections
46
		return $sections;
47
	}
48
49
	public function fields( array $fields ) {
50
		/*
51
		 * General
52
		 */
53
54
		// PSPID
55
		$fields[] = array(
56
			'filter'   => FILTER_SANITIZE_STRING,
57
			'section'  => 'ogone',
58
			'meta_key' => '_pronamic_gateway_ogone_psp_id',
59
			'title'    => __( 'PSPID', 'pronamic_ideal' ),
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
			'title'    => /** @scrutinizer ignore-call */ __( 'PSPID', 'pronamic_ideal' ),
Loading history...
60
			'type'     => 'text',
61
			'classes'  => array( 'code' ),
62
			'tooltip'  => __( 'PSPID as mentioned in the payment provider dashboard.', 'pronamic_ideal' ),
63
			'methods'  => array( 'ogone_orderstandard_easy', 'ogone_orderstandard', 'ogone_directlink' ),
64
		);
65
66
		// API user ID
67
		$fields[] = array(
68
			'filter'   => FILTER_SANITIZE_STRING,
69
			'section'  => 'ogone',
70
			'meta_key' => '_pronamic_gateway_ogone_user_id',
71
			'title'    => __( 'API user ID', 'pronamic_ideal' ),
72
			'type'     => 'text',
73
			'classes'  => array( 'regular-text', 'code' ),
74
			'methods'  => array( 'ogone_orderstandard', 'ogone_directlink' ),
75
			'tooltip'  => __( 'User ID of the API user in the payment provider dashboard: Configuration &raquo; Users', 'pronamic_ideal' ),
76
		);
77
78
		// API user password
79
		$fields[] = array(
80
			'filter'   => FILTER_SANITIZE_STRING,
81
			'section'  => 'ogone',
82
			'meta_key' => '_pronamic_gateway_ogone_password',
83
			'title'    => __( 'API user password', 'pronamic_ideal' ),
84
			'type'     => 'password',
85
			'classes'  => array( 'regular-text', 'code' ),
86
			'methods'  => array( 'ogone_orderstandard', 'ogone_directlink' ),
87
			'tooltip'  => __( 'Password of the API user in the payment provider dashboard: Configuration &raquo; Users', 'pronamic_ideal' ),
88
		);
89
90
		// SHA-IN Pass phrase
91
		$fields[] = array(
92
			'filter'   => FILTER_SANITIZE_STRING,
93
			'section'  => 'ogone',
94
			'meta_key' => '_pronamic_gateway_ogone_sha_in_pass_phrase',
95
			'title'    => __( 'SHA-IN Pass phrase', 'pronamic_ideal' ),
96
			'type'     => 'password',
97
			'classes'  => array( 'regular-text', 'code' ),
98
			'tooltip'  => __( 'SHA-IN pass phrase as mentioned in the payment provider dashboard: Configuration &raquo; Technical information &raquo; Data and origin verification.', 'pronamic_ideal' ),
99
			'methods'  => array( 'ogone_orderstandard' ),
100
		);
101
102
		// SHA-IN Pass phrase
103
		$fields[] = array(
104
			'filter'   => FILTER_SANITIZE_STRING,
105
			'section'  => 'ogone',
106
			'meta_key' => '_pronamic_gateway_ogone_directlink_sha_in_pass_phrase',
107
			'title'    => __( 'SHA-IN Pass phrase', 'pronamic_ideal' ),
108
			'type'     => 'password',
109
			'classes'  => array( 'regular-text', 'code' ),
110
			'tooltip'  => __( 'SHA-IN pass phrase as mentioned in the payment provider dashboard: Configuration &raquo; Technical information &raquo; Data and origin verification.', 'pronamic_ideal' ),
111
			'methods'  => array( 'ogone_directlink' ),
112
		);
113
114
		// SHA-OUT Pass phrase
115
		$fields[] = array(
116
			'filter'   => FILTER_SANITIZE_STRING,
117
			'section'  => 'ogone',
118
			'meta_key' => '_pronamic_gateway_ogone_sha_out_pass_phrase',
119
			'title'    => __( 'SHA-OUT Pass phrase', 'pronamic_ideal' ),
120
			'type'     => 'password',
121
			'classes'  => array( 'regular-text', 'code' ),
122
			'tooltip'  => __( 'SHA-OUT pass phrase as mentioned in the payment provider dashboard: Configuration &raquo; Technical information &raquo; Transaction feedback.', 'pronamic_ideal' ),
123
			'methods'  => array( 'ogone_orderstandard', 'ogone_directlink' ),
124
		);
125
126
		// Hash algorithm
127
		$fields[] = array(
128
			'filter'   => FILTER_SANITIZE_STRING,
129
			'section'  => 'ogone',
130
			'meta_key' => '_pronamic_gateway_ogone_hash_algorithm',
131
			'title'    => __( 'Hash algorithm', 'pronamic_ideal' ),
132
			'type'     => 'optgroup',
133
			'tooltip'  => 'Hash algorithm as mentioned in the payment provider dashboard: Configuration &raquo; Technical information',
134
			'options'  => array(
135
				Ingenico::SHA_1   => __( 'SHA-1', 'pronamic_ideal' ),
136
				Ingenico::SHA_256 => __( 'SHA-256', 'pronamic_ideal' ),
137
				Ingenico::SHA_512 => __( 'SHA-512', 'pronamic_ideal' ),
138
			),
139
			'default'  => Ingenico::SHA_1,
140
			'methods'  => array( 'ogone_orderstandard', 'ogone_directlink' ),
141
		);
142
143
		// 3-D Secure
144
		$fields[] = array(
145
			'filter'   => FILTER_VALIDATE_BOOLEAN,
146
			'section'  => 'ogone',
147
			'meta_key' => '_pronamic_gateway_ogone_3d_secure_enabled',
148
			'title'    => __( '3-D Secure', 'pronamic_ideal' ),
149
			'type'     => 'checkbox',
150
			'label'    => __( 'Enable 3-D Secure protocol', 'pronamic_ideal' ),
151
			'methods'  => array( 'ogone_directlink' ),
152
		);
153
154
		// Transaction feedback fields
155
		$fields[] = array(
156
			'section' => 'ogone',
157
			'title'   => __( 'Transaction feedback', 'pronamic_ideal' ),
158
			'type'    => 'description',
159
			'methods' => array( 'ogone_orderstandard_easy' ),
160
			'html'    => sprintf(
161
				'<span class="dashicons dashicons-no"></span> %s',
162
				__( 'Payment status updates are not supported by this payment provider.', 'pronamic_ideal' )
163
			),
164
		);
165
166
		$fields[] = array(
167
			'section' => 'ogone',
168
			'title'   => __( 'Transaction feedback', 'pronamic_ideal' ),
169
			'type'    => 'description',
170
			'methods' => array( 'ogone_orderstandard', 'ogone_directlink' ),
171
			'html'    => sprintf(
172
				'<span class="dashicons dashicons-warning"></span> %s',
173
				__( 'Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal' )
174
			),
175
		);
176
177
		/*
178
		 * Advanced settings
179
		 */
180
181
		// Form Action URL
182
		$fields[] = array(
183
			'filter'   => FILTER_SANITIZE_STRING,
184
			'section'  => 'ogone_advanced',
185
			'meta_key' => '_pronamic_gateway_ogone_form_action_url',
186
			'title'    => __( 'Form Action URL', 'pronamic_ideal' ),
187
			'type'     => 'text',
188
			'classes'  => array( 'regular-text', 'code' ),
189
			'tooltip'  => __( 'With this setting you can override the default Ogone e-Commerce form action URL to the payment processing page.', 'pronamic_ideal' ),
190
			'methods'  => array( 'ogone_orderstandard_easy', 'ogone_orderstandard' ),
191
		);
192
193
		// Order ID
194
		$fields[] = array(
195
			'filter'      => FILTER_SANITIZE_STRING,
196
			'section'     => 'ogone_advanced',
197
			'meta_key'    => '_pronamic_gateway_ogone_order_id',
198
			'title'       => __( 'Order ID', 'pronamic_ideal' ),
199
			'type'        => 'text',
200
			'classes'     => array( 'regular-text', 'code' ),
201
			'tooltip'     => sprintf(
202
				__( 'The Ogone %s parameter.', 'pronamic_ideal' ),
203
				sprintf( '<code>%s</code>', 'ORDERID' )
204
			),
205
			'description' => sprintf(
206
				'%s<br />%s',
207
				sprintf( __( 'Available tags: %s', 'pronamic_ideal' ), sprintf( '<code>%s</code> <code>%s</code>', '{order_id}', '{payment_id}' ) ),
208
				sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), '{payment_id}' )
209
			),
210
			'methods'     => array( 'ogone_orderstandard_easy', 'ogone_orderstandard', 'ogone_directlink' ),
211
		);
212
213
		// Parameter Variable
214
		$fields[] = array(
215
			'filter'      => FILTER_SANITIZE_STRING,
216
			'section'     => 'ogone_advanced',
217
			'meta_key'    => '_pronamic_gateway_ogone_param_var',
218
			'title'       => __( 'Parameter Variable', 'pronamic_ideal' ),
219
			'type'        => 'text',
220
			'classes'     => array( 'regular-text', 'code' ),
221
			'tooltip'     => sprintf(
222
				__( 'The Ogone %s parameter.', 'pronamic_ideal' ),
223
				sprintf( '<code>%s</code>', 'PARAMVAR' )
224
			),
225
			'description' => sprintf(
226
				__( 'Available tags: %s', 'pronamic_ideal' ),
227
				sprintf( '<code>%s</code> <code>%s</code>', '{site_url}', '{home_url}' )
228
			),
229
			'methods'     => array( 'ogone_orderstandard', 'ogone_directlink' ),
230
		);
231
232
		// Template Page
233
		$fields[] = array(
234
			'filter'   => FILTER_SANITIZE_STRING,
235
			'section'  => 'ogone_advanced',
236
			'meta_key' => '_pronamic_gateway_ogone_template_page',
237
			'title'    => __( 'Template Page', 'pronamic_ideal' ),
238
			'type'     => 'text',
239
			'tooltip'  => sprintf(
240
				__( 'The Ogone %s parameter.', 'pronamic_ideal' ),
241
				sprintf( '<code>%s</code>', 'TP' )
242
			),
243
			'methods'  => array( 'ogone_orderstandard', 'ogone_directlink' ),
244
		);
245
246
		/*
247
		 * Transaction feedback - Direct HTTP server-to-server request URLs
248
		 */
249
250
		// URL accepted, on hold or uncertain
251
		$fields[] = array(
252
			'section'  => 'ogone_feedback',
253
			'title'    => __( 'URL accepted, on hold or uncertain', 'pronamic_ideal' ),
254
			'type'     => 'text',
255
			'value'    => site_url( '/' ),
0 ignored issues
show
The function site_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

255
			'value'    => /** @scrutinizer ignore-call */ site_url( '/' ),
Loading history...
256
			'classes'  => array( 'regular-text', 'code' ),
257
			'tooltip'  => __( 'Direct HTTP server-to-server request URL for payment statuses accepted, on hold or uncertain".', 'pronamic_ideal' ),
258
			'readonly' => true,
259
		);
260
261
		// URL cancel or deny
262
		$fields[] = array(
263
			'section'  => 'ogone_feedback',
264
			'title'    => __( 'URL cancel or deny', 'pronamic_ideal' ),
265
			'type'     => 'text',
266
			'value'    => site_url( '/' ),
267
			'classes'  => array( 'regular-text', 'code' ),
268
			'tooltip'  => __( 'Direct HTTP server-to-server request URL for payment statuses "cancelled by the client" or "too many rejections by the acquirer".', 'pronamic_ideal' ),
269
			'readonly' => true,
270
		);
271
272
		// Return fields
273
		return $fields;
274
	}
275
}
276