Failed Conditions
Push — develop ( 1fd1c4...b48a0e )
by Reüel
11:07
created

src/Integration.php (1 issue)

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