Failed Conditions
Push — develop ( 16cd13...98dc41 )
by Remco
05:11
created

src/Integration.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Integration.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\ING\KassaCompleet;
12
13
use Pronamic\WordPress\Pay\AbstractGatewayIntegration;
0 ignored issues
show
The type Pronamic\WordPress\Pay\AbstractGatewayIntegration 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...
14
15
/**
16
 * Title: ING Kassa Compleet integration
17
 * Description:
18
 * Copyright: 2005-2020 Pronamic
19
 * Company: Pronamic
20
 *
21
 * @author  Reüel van der Steege
22
 * @version 2.0.3
23
 * @since   1.0.0
24
 */
25
class Integration extends AbstractGatewayIntegration {
26
	/**
27
	 * Construct ING Kassa Compleet integration.
28
	 *
29
	 * @param array $args Arguments.
30
	 */
31
	public function __construct( $args = array() ) {
32
		$args = wp_parse_args(
33
			$args,
34
			array(
35
				'id'            => 'ing-kassa-compleet',
36
				'name'          => 'ING - Kassa Compleet',
37
				'provider'      => 'ing',
38
				'product_url'   => 'https://www.ing.nl/zakelijk/betalen/geld-ontvangen/kassa-compleet/',
39
				'dashboard_url' => 'https://portal.kassacompleet.nl/',
40
				'supports'      => array(
41
					'payment_status_request',
42
					'webhook',
43
					'webhook_log',
44
				),
45
				'manual_url'    => \__( 'https://www.pronamic.eu/support/how-to-connect-ing-kassa-compleet-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ),
46
			)
47
		);
48
49
		parent::__construct( $args );
50
51
		// Actions.
52
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
53
54
		if ( ! has_action( 'wp_loaded', $function ) ) {
55
			add_action( 'wp_loaded', $function );
56
		}
57
	}
58
59
	/**
60
	 * Get settings fields.
61
	 *
62
	 * @return array
63
	 */
64
	public function get_settings_fields() {
65
		$fields = array();
66
67
		// API Key.
68
		$fields[] = array(
69
			'section'  => 'general',
70
			'filter'   => FILTER_SANITIZE_STRING,
71
			'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key',
72
			'title'    => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ),
73
			'type'     => 'text',
74
			'classes'  => array( 'regular-text', 'code' ),
75
			'tooltip'  => sprintf(
76
				'%s %s.',
77
				__( 'API key', 'pronamic_ideal' ),
78
				sprintf(
79
					/* translators: %s: ING Kassa Compleet */
80
					__( 'as mentioned in the %s dashboard', 'pronamic_ideal' ),
81
					__( 'ING Kassa Compleet', 'pronamic_ideal' )
82
				)
83
			),
84
		);
85
86
		// Webhook URL.
87
		$fields[] = array(
88
			'section'  => 'feedback',
89
			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
90
			'type'     => 'text',
91
			'classes'  => array( 'large-text', 'code' ),
92
			'value'    => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ),
93
			'readonly' => true,
94
			'tooltip'  => sprintf(
95
				/* translators: %s: ING Kassa Compleet */
96
				__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
97
				__( 'ING Kassa Compleet', 'pronamic_ideal' )
98
			),
99
		);
100
101
		return $fields;
102
	}
103
	/**
104
	 * Get config with specified post ID.
105
	 *
106
	 * @param int $post_id Post ID.
107
	 *
108
	 * @return Config|null
109
	 */
110
	public function get_config( $post_id ) {
111
		$config = new Config();
112
113
		$config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );
114
		$config->mode    = $this->get_meta( $post_id, 'mode' );
115
116
		return $config;
117
	}
118
119
	/**
120
	 * Get gateway.
121
	 *
122
	 * @param int $post_id Post ID.
123
	 * @return Gateway
124
	 */
125
	public function get_gateway( $post_id ) {
126
		return new Gateway( $this->get_config( $post_id ) );
127
	}
128
}
129