Failed Conditions
Push — develop ( b48a0e...170d92 )
by Reüel
15:46
created

Integration::get_gateway()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
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(
36
			'payment_status_request',
37
			'webhook',
38
			'webhook_log',
39
		);
40
41
		$this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-ing-kassa-compleet-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) );
0 ignored issues
show
Bug introduced by
The method set_manual_url() does not exist on Pronamic\WordPress\Pay\G...ssaCompleet\Integration. ( Ignorable by Annotation )

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

41
		$this->/** @scrutinizer ignore-call */ 
42
         set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-ing-kassa-compleet-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) );

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...
42
43
		// Actions.
44
		$function = array( __NAMESPACE__ . '\Listener', 'listen' );
45
46
		if ( ! has_action( 'wp_loaded', $function ) ) {
47
			add_action( 'wp_loaded', $function );
48
		}
49
	}
50
51
	/**
52
	 * Get settings fields.
53
	 *
54
	 * @return array
55
	 */
56
	public function get_settings_fields() {
57
		$fields = array();
58
59
		// API Key.
60
		$fields[] = array(
61
			'section'  => 'general',
62
			'filter'   => FILTER_SANITIZE_STRING,
63
			'meta_key' => '_pronamic_gateway_ing_kassa_compleet_api_key',
64
			'title'    => _x( 'API Key', 'ing_kassa_compleet', 'pronamic_ideal' ),
65
			'type'     => 'text',
66
			'classes'  => array( 'regular-text', 'code' ),
67
			'tooltip'  => sprintf(
68
				'%s %s.',
69
				__( 'API key', 'pronamic_ideal' ),
70
				sprintf(
71
					/* translators: %s: ING Kassa Compleet */
72
					__( 'as mentioned in the %s dashboard', 'pronamic_ideal' ),
73
					__( 'ING Kassa Compleet', 'pronamic_ideal' )
74
				)
75
			),
76
		);
77
78
		// Webhook URL.
79
		$fields[] = array(
80
			'section'  => 'feedback',
81
			'title'    => __( 'Webhook URL', 'pronamic_ideal' ),
82
			'type'     => 'text',
83
			'classes'  => array( 'large-text', 'code' ),
84
			'value'    => add_query_arg( 'ing_kassa_compleet_webhook', '', home_url( '/' ) ),
85
			'readonly' => true,
86
			'tooltip'  => sprintf(
87
				/* translators: %s: ING Kassa Compleet */
88
				__( 'Copy the Webhook URL to the %s dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
89
				__( 'ING Kassa Compleet', 'pronamic_ideal' )
90
			),
91
		);
92
93
		return $fields;
94
	}
95
	/**
96
	 * Get config with specified post ID.
97
	 *
98
	 * @param int $post_id Post ID.
99
	 *
100
	 * @return Config|null
101
	 */
102
	public function get_config( $post_id ) {
103
		$config = new Config();
104
105
		$config->api_key = $this->get_meta( $post_id, 'ing_kassa_compleet_api_key' );
106
		$config->mode    = $this->get_meta( $post_id, 'mode' );
107
108
		return $config;
109
	}
110
111
	/**
112
	 * Get gateway.
113
	 *
114
	 * @param int $post_id Post ID.
115
	 * @return Gateway
116
	 */
117
	public function get_gateway( $post_id ) {
118
		return new Gateway( $this->get_config( $post_id ) );
119
	}
120
}
121