Failed Conditions
Push — develop ( d73c32...f6b486 )
by Remco
06:26
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
	}
38
39
	/**
40
	 * Get settings fields.
41
	 *
42
	 * @return array
43
	 */
44
	public function get_settings_fields() {
45
		$fields = array();
46
47
		// Intro.
48
		$fields[] = array(
49
			'section' => 'general',
50
			'type'    => 'html',
51
			'html'    => sprintf(
52
				/* translators: %s: Sisow */
53
				__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ),
54
				__( 'Sisow', 'pronamic_ideal' )
55
			),
56
		);
57
58
		// Merchant ID.
59
		$fields[] = array(
60
			'section'  => 'general',
61
			'filter'   => FILTER_SANITIZE_STRING,
62
			'methods'  => array( 'sisow' ),
63
			'meta_key' => '_pronamic_gateway_sisow_merchant_id',
64
			'title'    => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ),
65
			'type'     => 'text',
66
			'classes'  => array( 'code' ),
67
			'tooltip'  => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
68
		);
69
70
		// Merchant Key.
71
		$fields[] = array(
72
			'section'  => 'general',
73
			'filter'   => FILTER_SANITIZE_STRING,
74
			'methods'  => array( 'sisow' ),
75
			'meta_key' => '_pronamic_gateway_sisow_merchant_key',
76
			'title'    => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ),
77
			'type'     => 'text',
78
			'classes'  => array( 'regular-text', 'code' ),
79
			'tooltip'  => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
80
		);
81
82
		// Shop ID.
83
		$fields[] = array(
84
			'section'     => 'general',
85
			'filter'      => FILTER_SANITIZE_STRING,
86
			'methods'     => array( 'sisow' ),
87
			'meta_key'    => '_pronamic_gateway_sisow_shop_id',
88
			'title'       => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ),
89
			'type'        => 'text',
90
			'classes'     => array( 'regular-text', 'code' ),
91
			'tooltip'     => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ),
92
			/* translators: %s: 0 */
93
			'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ),
94
			'default'     => 0,
95
		);
96
97
		return $fields;
98
	}
99
100
	/**
101
	 * Get configuration.
102
	 *
103
	 * @param int $post_id Post ID.
104
	 * @return Config
105
	 */
106
	public function get_config( $post_id ) {
107
		$config = new Config();
108
109
		$config->merchant_id  = $this->get_meta( $post_id, 'sisow_merchant_id' );
0 ignored issues
show
The method get_meta() does not exist on Pronamic\WordPress\Pay\Gateways\Sisow\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

109
		/** @scrutinizer ignore-call */ 
110
  $config->merchant_id  = $this->get_meta( $post_id, 'sisow_merchant_id' );

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...
110
		$config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' );
111
		$config->shop_id      = $this->get_meta( $post_id, 'sisow_shop_id' );
112
		$config->mode         = $this->get_meta( $post_id, 'mode' );
113
114
		return $config;
115
	}
116
117
	/**
118
	 * Get gateway.
119
	 *
120
	 * @param int $post_id Post ID.
121
	 * @return Gateway
122
	 */
123
	public function get_gateway( $post_id ) {
124
		return new Gateway( $this->get_config( $post_id ) );
125
	}
126
}
127