Test Failed
Push — develop ( 094d0d...633e1a )
by Reüel
10:46
created

src/Integration.php (1 issue)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\TargetPay;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: TargetPay 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
	public function __construct() {
19
		$this->id            = 'targetpay-ideal';
20
		$this->name          = 'TargetPay - iDEAL';
21
		$this->product_url   = __( 'https://www.targetpay.com/info/ideal?setlang=en', 'pronamic_ideal' );
22
		$this->manual_url    = __( 'https://www.pronamic.eu/support/how-to-connect-targetpay-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...
23
		$this->dashboard_url = 'https://www.targetpay.com/login';
24
		$this->provider      = 'targetpay';
25
	}
26
27
	/**
28
	 * Get settings fields.
29
	 *
30
	 * @return array
31
	 */
32
	public function get_settings_fields() {
33
		$fields = array();
34
35
		// Intro.
36
		$fields[] = array(
37
			'section' => 'general',
38
			'type'    => 'html',
39
			'html'    => sprintf(
40
				/* translators: 1: TargetPay */
41
				__( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ),
42
				__( 'TargetPay', 'pronamic_ideal' )
43
			),
44
		);
45
46
		// Layout Code.
47
		$fields[] = array(
48
			'section'  => 'general',
49
			'filter'   => FILTER_SANITIZE_STRING,
50
			'meta_key' => '_pronamic_gateway_targetpay_layoutcode',
51
			'title'    => __( 'Layout Code', 'pronamic_ideal' ),
52
			'type'     => 'text',
53
			'tooltip'  => __( 'Layout code as mentioned at <strong>Sub accounts</strong> in the TargetPay dashboard.', 'pronamic_ideal' ),
54
		);
55
56
		return $fields;
57
	}
58
59
	public function get_config( $post_id ) {
60
		$config = new Config();
61
62
		$config->layoutcode = get_post_meta( $post_id, '_pronamic_gateway_targetpay_layoutcode', true );
63
		$config->mode       = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
64
65
		return $config;
66
	}
67
68
	/**
69
	 * Get gateway.
70
	 *
71
	 * @param int $post_id Post ID.
72
	 * @return Gateway
73
	 */
74
	public function get_gateway( $post_id ) {
75
		return new Gateway( $this->get_config( $post_id ) );
76
	}
77
}
78