Failed Conditions
Push — develop ( 743001...0d6ec1 )
by Reüel
08:06
created

src/Integration.php (2 issues)

1
<?php
2
/**
3
 * Integration.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 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\Gateways\Common\AbstractIntegration;
14
15
/**
16
 * Title: ING Kassa Compleet integration
17
 * Description:
18
 * Copyright: 2005-2019 Pronamic
19
 * Company: Pronamic
20
 *
21
 * @author  Reüel van der Steege
22
 * @version 2.0.0
23
 * @since   1.0.0
24
 */
25
class Integration extends AbstractIntegration {
26
	/**
27
	 * Integration constructor.
28
	 */
29
	public function __construct() {
30
		$this->id            = 'ing-kassa-compleet';
31
		$this->name          = 'ING - Kassa Compleet';
32
		$this->provider      = 'ing';
33
		$this->product_url   = 'https://www.ing.nl/zakelijk/betalen/geld-ontvangen/kassa-compleet/';
34
		$this->dashboard_url = 'https://portal.kassacompleet.nl/';
35
		$this->supports      = array(
0 ignored issues
show
Bug Best Practice introduced by
The property supports does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
			'payment_status_request',
37
			'webhook',
38
			'webhook_log',
39
		);
40
41
		// Actions.
42
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
43
44
		if ( ! has_action( 'wp_loaded', $function ) ) {
45
			add_action( 'wp_loaded', $function );
46
		}
47
	}
48
49
	/**
50
	 * Get settings fields.
51
	 *
52
	 * @return array
53
	 */
54
	public function get_settings_fields() {
55
		$fields = array();
56
57
		// API Key.
58
		$fields[] = array(
59
			'section'  => 'general',
60
			'filter'   => FILTER_SANITIZE_STRING,
61
			'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key',
62
			'title'    => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ),
63
			'type'     => 'text',
64
			'classes'  => array( 'regular-text', 'code' ),
65
			'tooltip'  => sprintf(
66
				'%s %s.',
67
				__( 'API key', 'pronamic_ideal' ),
68
				sprintf(
69
					/* translators: %s: ING Kassa Compleet */
70
					__( 'as mentioned in the %s dashboard', 'pronamic_ideal' ),
71
					__( 'ING Kassa Compleet', 'pronamic_ideal' )
72
				)
73
			),
74
		);
75
76
		// Webhook URL.
77
		$fields[] = array(
78
			'section'  => 'feedback',
79
			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
80
			'type'     => 'text',
81
			'classes'  => array( 'large-text', 'code' ),
82
			'value'    => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ),
83
			'readonly' => true,
84
			'tooltip'  => sprintf(
85
				/* translators: %s: ING Kassa Compleet */
86
				__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
87
				__( 'ING Kassa Compleet', 'pronamic_ideal' )
88
			),
89
		);
90
91
		return $fields;
92
	}
93
	/**
94
	 * Get config with specified post ID.
95
	 *
96
	 * @param int $post_id Post ID.
97
	 *
98
	 * @return Config|null
99
	 */
100
	public function get_config( $post_id ) {
101
		$config = new Config();
102
103
		$config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );
0 ignored issues
show
The method get_meta() does not exist on Pronamic\WordPress\Pay\G...ssaCompleet\Integration. Did you maybe mean get_name()? ( Ignorable by Annotation )

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

103
		/** @scrutinizer ignore-call */ 
104
  $config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
		$config->mode    = $this->get_meta( $post_id, 'mode' );
105
106
		return $config;
107
	}
108
109
	/**
110
	 * Get gateway.
111
	 *
112
	 * @param int $post_id Post ID.
113
	 * @return Gateway
114
	 */
115
	public function get_gateway( $post_id ) {
116
		return new Gateway( $this->get_config( $post_id ) );
117
	}
118
}
119