Failed Conditions
Push — feature/webhook-status ( c2cf79 )
by Reüel
05:45
created

Settings   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 48
dl 0
loc 83
ccs 0
cts 61
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A feedback_status() 0 4 1
A fields() 0 53 1
A __construct() 0 3 1
A sections() 0 11 1
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic;
4
5
use Pronamic\WordPress\Pay\Core\GatewaySettings;
6
use Pronamic\WordPress\Pay\WebhookManager;
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\WebhookManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
/**
9
 * Title: iDEAL Basic settings
10
 * Description:
11
 * Copyright: 2005-2019 Pronamic
12
 * Company: Pronamic
13
 *
14
 * @author  Remco Tolsma
15
 * @version 2.0.0
16
 * @since   1.1.0
17
 */
18
class Settings extends GatewaySettings {
19
	public function __construct() {
20
		add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) );
21
		add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) );
22
	}
23
24
	public function sections( array $sections ) {
25
		// Transaction feedback
26
		$sections['IDealBasic_feedback'] = array(
27
			'title'       => __( 'Transaction feedback', 'pronamic_ideal' ),
28
			'methods'     => array( 'ideal-basic' ),
29
			'description' => __( 'The URL below needs to be copied to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
30
			'features'    => Gateway::get_supported_features(),
31
		);
32
33
		// Return sections
34
		return $sections;
35
	}
36
37
	public function fields( array $fields ) {
38
		// Hash Key
39
		$fields[] = array(
40
			'filter'   => FILTER_SANITIZE_STRING,
41
			'section'  => 'ideal',
42
			'meta_key' => '_pronamic_gateway_ideal_hash_key',
43
			'title'    => __( 'Hash Key', 'pronamic_ideal' ),
44
			'type'     => 'text',
45
			'classes'  => array( 'regular-text', 'code' ),
46
			'tooltip'  => __( 'Hash key (also known as: key or secret key) as mentioned in the payment provider dashboard.', 'pronamic_ideal' ),
47
			'methods'  => array( 'ideal-basic' ),
48
		);
49
50
		// Transaction feedback
51
		$fields[] = array(
52
			'section'  => 'ideal',
53
			'methods'  => array( 'ideal-basic' ),
54
			'title'    => __( 'Transaction feedback', 'pronamic_ideal' ),
55
			'type'     => 'description',
56
			'html'     => __( 'Receiving payment status updates needs additional configuration.', 'pronamic_ideal' ),
57
			'features' => Gateway::get_supported_features(),
58
		);
59
60
		// XML Notification URL.
61
		$fields[] = array(
62
			'section'  => 'IDealBasic_feedback',
63
			'title'    => __( 'XML Notification URL', 'pronamic_ideal' ),
64
			'type'     => 'text',
65
			'classes'  => array( 'regular-text', 'code' ),
66
			'value'    => add_query_arg(
67
				array(
68
					'gateway'          => 'IDealBasic',
69
					'xml_notification' => 'true',
70
				),
71
				site_url( '/' )
72
			),
73
			'methods'  => array( 'ideal-basic' ),
74
			'readonly' => true,
75
			'size'     => 200,
76
			'tooltip'  => __( 'Copy the XML notification URL to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
77
		);
78
79
		// Webhook status.
80
		$fields[] = array(
81
			'section'  => 'IDealBasic_feedback',
82
			'methods'  => array( 'ideal-basic' ),
83
			'title'    => __( 'Status', 'pronamic_ideal' ),
84
			'type'     => 'description',
85
			'callback' => array( $this, 'feedback_status' ),
86
		);
87
88
		// Return fields.
89
		return $fields;
90
	}
91
92
	/**
93
	 * Transaction feedback status.
94
	 *
95
	 * @param array $field Settings field.
96
	 */
97
	public function feedback_status( $field ) {
98
		$features = Gateway::get_supported_features();
99
100
		WebhookManager::settings_status( $field, $features );
101
	}
102
}
103