Failed Conditions
Push — develop ( f0e449...041528 )
by Reüel
05:35
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->dashboard_url = 'https://www.sisow.nl/Sisow/iDeal/Login.aspx';
35
		$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...
36
		$this->provider      = 'sisow';
37
		$this->supports      = array(
38
			'webhook',
39
			'webhook_log',
40
			'webhook_no_config',
41
		);
42
43
		$this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-sisow-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) );
0 ignored issues
show
The method set_manual_url() does not exist on Pronamic\WordPress\Pay\Gateways\Sisow\Integration. ( Ignorable by Annotation )

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

43
		$this->/** @scrutinizer ignore-call */ 
44
         set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-sisow-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...
44
	}
45
46
	/**
47
	 * Get settings fields.
48
	 *
49
	 * @return array
50
	 */
51
	public function get_settings_fields() {
52
		$fields = array();
53
54
		// Intro.
55
		$fields[] = array(
56
			'section' => 'general',
57
			'type'    => 'html',
58
			'html'    => sprintf(
59
				/* translators: %s: Sisow */
60
				__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ),
61
				__( 'Sisow', 'pronamic_ideal' )
62
			),
63
		);
64
65
		// Merchant ID.
66
		$fields[] = array(
67
			'section'  => 'general',
68
			'filter'   => FILTER_SANITIZE_STRING,
69
			'methods'  => array( 'sisow' ),
70
			'meta_key' => '_pronamic_gateway_sisow_merchant_id',
71
			'title'    => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ),
72
			'type'     => 'text',
73
			'classes'  => array( 'code' ),
74
			'tooltip'  => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
75
		);
76
77
		// Merchant Key.
78
		$fields[] = array(
79
			'section'  => 'general',
80
			'filter'   => FILTER_SANITIZE_STRING,
81
			'methods'  => array( 'sisow' ),
82
			'meta_key' => '_pronamic_gateway_sisow_merchant_key',
83
			'title'    => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ),
84
			'type'     => 'text',
85
			'classes'  => array( 'regular-text', 'code' ),
86
			'tooltip'  => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
87
		);
88
89
		// Shop ID.
90
		$fields[] = array(
91
			'section'     => 'general',
92
			'filter'      => FILTER_SANITIZE_STRING,
93
			'methods'     => array( 'sisow' ),
94
			'meta_key'    => '_pronamic_gateway_sisow_shop_id',
95
			'title'       => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ),
96
			'type'        => 'text',
97
			'classes'     => array( 'regular-text', 'code' ),
98
			'tooltip'     => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
99
			/* translators: %s: 0 */
100
			'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ),
101
			'default'     => 0,
102
		);
103
104
		return $fields;
105
	}
106
107
	/**
108
	 * Get configuration.
109
	 *
110
	 * @param int $post_id Post ID.
111
	 * @return Config
112
	 */
113
	public function get_config( $post_id ) {
114
		$config = new Config();
115
116
		$config->merchant_id  = $this->get_meta( $post_id, 'sisow_merchant_id' );
117
		$config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' );
118
		$config->shop_id      = $this->get_meta( $post_id, 'sisow_shop_id' );
119
		$config->mode         = $this->get_meta( $post_id, 'mode' );
120
121
		return $config;
122
	}
123
124
	/**
125
	 * Get gateway.
126
	 *
127
	 * @param int $post_id Post ID.
128
	 * @return Gateway
129
	 */
130
	public function get_gateway( $post_id ) {
131
		return new Gateway( $this->get_config( $post_id ) );
132
	}
133
}
134