Failed Conditions
Push — develop ( 755a8b...f93ab4 )
by Reüel
08:34
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\Payments
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Sisow;
12
13
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
14
15
/**
16
 * Title: Sisow integration
17
 * Description:
18
 * Copyright: 2005-2019 Pronamic
19
 * Company: Pronamic
20
 *
21
 * @author  Remco Tolsma
22
 * @version 2.0.0
23
 * @since   1.0.0
24
 */
25
class Integration extends AbstractIntegration {
26
	/**
27
	 * Construct integration.
28
	 */
29
	public function __construct() {
30
		$this->id            = 'sisow-ideal';
31
		$this->name          = 'Sisow';
32
		$this->url           = 'https://www.sisow.nl/';
33
		$this->product_url   = 'https://www.sisow.nl/epay-online-betaalmogelijkheden/epay-informatie';
34
		$this->manual_url    = __( 'https://www.pronamic.eu/support/how-to-connect-sisow-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://www.sisow.nl/Sisow/iDeal/Login.aspx';
36
		$this->register_url  = 'https://www.sisow.nl/Sisow/iDeal/Aanmelden.aspx?r=120872';
0 ignored issues
show
Bug Best Practice introduced by
The property register_url does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
37
		$this->provider      = 'sisow';
38
		$this->supports      = array(
39
			'webhook',
40
			'webhook_log',
41
			'webhook_no_config',
42
		);
43
	}
44
45
	/**
46
	 * Get settings fields.
47
	 *
48
	 * @return array
49
	 */
50
	public function get_settings_fields() {
51
		$fields = array();
52
53
		// Intro.
54
		$fields[] = array(
55
			'section' => 'general',
56
			'type'    => 'html',
57
			'html'    => sprintf(
58
				/* translators: %s: Sisow */
59
				__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ),
60
				__( 'Sisow', 'pronamic_ideal' )
61
			),
62
		);
63
64
		// Merchant ID.
65
		$fields[] = array(
66
			'section'  => 'general',
67
			'filter'   => FILTER_SANITIZE_STRING,
68
			'methods'  => array( 'sisow' ),
69
			'meta_key' => '_pronamic_gateway_sisow_merchant_id',
70
			'title'    => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ),
71
			'type'     => 'text',
72
			'classes'  => array( 'code' ),
73
			'tooltip'  => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
74
		);
75
76
		// Merchant Key.
77
		$fields[] = array(
78
			'section'  => 'general',
79
			'filter'   => FILTER_SANITIZE_STRING,
80
			'methods'  => array( 'sisow' ),
81
			'meta_key' => '_pronamic_gateway_sisow_merchant_key',
82
			'title'    => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ),
83
			'type'     => 'text',
84
			'classes'  => array( 'regular-text', 'code' ),
85
			'tooltip'  => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
86
		);
87
88
		// Shop ID.
89
		$fields[] = array(
90
			'section'     => 'general',
91
			'filter'      => FILTER_SANITIZE_STRING,
92
			'methods'     => array( 'sisow' ),
93
			'meta_key'    => '_pronamic_gateway_sisow_shop_id',
94
			'title'       => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ),
95
			'type'        => 'text',
96
			'classes'     => array( 'regular-text', 'code' ),
97
			'tooltip'     => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
98
			/* translators: %s: 0 */
99
			'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ),
100
			'default'     => 0,
101
		);
102
103
		return $fields;
104
	}
105
106
	/**
107
	 * Get configuration.
108
	 *
109
	 * @param int $post_id Post ID.
110
	 * @return Config
111
	 */
112
	public function get_config( $post_id ) {
113
		$config = new Config();
114
115
		$config->merchant_id  = $this->get_meta( $post_id, 'sisow_merchant_id' );
116
		$config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' );
117
		$config->shop_id      = $this->get_meta( $post_id, 'sisow_shop_id' );
118
		$config->mode         = $this->get_meta( $post_id, 'mode' );
119
120
		return $config;
121
	}
122
123
	/**
124
	 * Get gateway.
125
	 *
126
	 * @param int $post_id Post ID.
127
	 * @return Gateway
128
	 */
129
	public function get_gateway( $post_id ) {
130
		return new Gateway( $this->get_config( $post_id ) );
131
	}
132
}
133