Failed Conditions
Push — develop ( 0d0a44...ee3e7b )
by Remco
04:33
created

Integration::get_config_factory_class()   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 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\IDealBasic;
4
5
use Pronamic\WordPress\Pay\Gateways\IDeal\AbstractIntegration;
6
7
/**
8
 * Title: Integration
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.0.0
16
 */
17
class Integration extends AbstractIntegration {
18
	/**
19
	 * Construct and initialize integration.
20
	 */
21
	public function __construct( $args = array() ) {
22
		$args = wp_parse_args( $args, array(
23
			'id'            => 'ideal-basic',
24
			'name'          => 'iDEAL Basic',
25
			'url'           => __( 'https://www.ideal.nl/en/', 'pronamic_ideal' ),
26
			'product_url'   => __( 'https://www.ideal.nl/en/', 'pronamic_ideal' ),
27
			'dashboard_url' => null,
28
			'provider'      => null,
29
		) );
30
31
		$this->id            = $args['id'];
32
		$this->name          = $args['name'];
33
		$this->url           = $args['url'];
34
		$this->product_url   = $args['product_url'];
35
		$this->dashboard_url = $args['dashboard_url'];
36
		$this->provider      = $args['provider'];
37
38
		$this->supports = array(
0 ignored issues
show
Bug Best Practice introduced by
The property supports does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
			'webhook',
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
	public function get_settings_fields() {
51
		$fields = parent::get_settings_fields();
0 ignored issues
show
Bug introduced by
The method get_settings_fields() does not exist on Pronamic\WordPress\Pay\G...eal\AbstractIntegration. Did you maybe mean get_settings()? ( Ignorable by Annotation )

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

51
		/** @scrutinizer ignore-call */ 
52
  $fields = parent::get_settings_fields();

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...
52
53
		// Hash Key
54
		$fields[] = array(
55
			'section'  => 'general',
56
			'filter'   => FILTER_SANITIZE_STRING,
57
			'meta_key' => '_pronamic_gateway_ideal_hash_key',
58
			'title'    => __( 'Hash Key', 'pronamic_ideal' ),
59
			'type'     => 'text',
60
			'classes'  => array( 'regular-text', 'code' ),
61
			'tooltip'  => __( 'Hash key (also known as: key or secret key) as mentioned in the payment provider dashboard.', 'pronamic_ideal' ),
62
			'methods'  => array( 'ideal-basic' ),
63
		);
64
65
		// XML Notification URL.
66
		$fields[] = array(
67
			'section'  => 'feedback',
68
			'title'    => __( 'XML Notification URL', 'pronamic_ideal' ),
69
			'type'     => 'text',
70
			'classes'  => array( 'regular-text', 'code' ),
71
			'value'    => add_query_arg(
72
				array(
73
					'gateway'          => 'IDealBasic',
74
					'xml_notification' => 'true',
75
				),
76
				site_url( '/' )
77
			),
78
			'methods'  => array( 'ideal-basic' ),
79
			'readonly' => true,
80
			'size'     => 200,
81
			'tooltip'  => __( 'Copy the XML notification URL to the payment provider dashboard to receive automatic transaction status updates.', 'pronamic_ideal' ),
82
		);
83
84
		// Return fields.
85
		return $fields;
86
	}
87
88
	public function get_config( $post_id ) {
89
		$mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
0 ignored issues
show
Unused Code introduced by
The assignment to $mode is dead and can be removed.
Loading history...
90
91
		$config = new Config();
92
93
		$config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true );
94
		$config->sub_id      = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true );
95
		$config->hash_key    = get_post_meta( $post_id, '_pronamic_gateway_ideal_hash_key', true );
96
		$config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true );
97
98
		return $config;
99
	}
100
}
101