Test Failed
Push — develop ( 50881d...8bdcfe )
by Reüel
11:24
created

src/Integration.php (1 issue)

1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay;
4
5
use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration;
6
7
/**
8
 * Title: MultiSafepay Connect integration
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.2
15
 * @since   1.2.6
16
 */
17
class Integration extends AbstractIntegration {
18
	/**
19
	 * Integration constructor.
20
	 */
21
	public function __construct() {
22
		$this->id            = 'multisafepay-connect';
23
		$this->name          = 'MultiSafepay - Connect';
24
		$this->url           = 'http://www.multisafepay.com/';
25
		$this->product_url   = __( 'http://www.multisafepay.com/', 'pronamic_ideal' );
26
		$this->manual_url    = __( 'https://www.pronamic.eu/support/how-to-connect-multisafepay-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...
27
		$this->dashboard_url = 'https://merchant.multisafepay.com/';
28
		$this->provider      = 'multisafepay';
29
		$this->supports      = array(
30
			'payment_status_request',
31
			'webhook',
32
			'webhook_no_config',
33
		);
34
	}
35
36
	public function get_settings_fields() {
37
		$fields = array();
38
39
		// Account ID
40
		$fields[] = array(
41
			'section'  => 'general',
42
			'filter'   => FILTER_SANITIZE_STRING,
43
			'meta_key' => '_pronamic_gateway_multisafepay_account_id',
44
			'title'    => __( 'Account ID', 'pronamic_ideal' ),
45
			'type'     => 'text',
46
			'classes'  => array( 'code' ),
47
			'tooltip'  => sprintf(
48
				'%s %s.',
49
				__( 'Account ID', 'pronamic_ideal' ),
50
				/* translators: %s: MultiSafepay */
51
				sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) )
52
			),
53
		);
54
55
		// Site ID
56
		$fields[] = array(
57
			'section'  => 'general',
58
			'filter'   => FILTER_SANITIZE_STRING,
59
			'meta_key' => '_pronamic_gateway_multisafepay_site_id',
60
			'title'    => __( 'Site ID', 'pronamic_ideal' ),
61
			'type'     => 'text',
62
			'classes'  => array( 'code' ),
63
			'tooltip'  => sprintf(
64
				'%s %s.',
65
				__( 'Site ID', 'pronamic_ideal' ),
66
				/* translators: %s: MultiSafepay */
67
				sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) )
68
			),
69
		);
70
71
		// Site Security Code
72
		$fields[] = array(
73
			'section'  => 'general',
74
			'filter'   => FILTER_SANITIZE_STRING,
75
			'meta_key' => '_pronamic_gateway_multisafepay_site_code',
76
			'title'    => __( 'Site Security Code', 'pronamic_ideal' ),
77
			'type'     => 'text',
78
			'classes'  => array( 'code' ),
79
			'tooltip'  => sprintf(
80
				'%s %s.',
81
				__( 'Site Security Code', 'pronamic_ideal' ),
82
				/* translators: %s: MultiSafepay */
83
				sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) )
84
			),
85
		);
86
87
		return $fields;
88
	}
89
90
	/**
91
	 * Get config.
92
	 *
93
	 * @param $post_id
94
	 *
95
	 * @return Config
96
	 */
97
	public function get_config( $post_id ) {
98
		$config = new Config();
99
100
		$config->mode       = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
101
		$config->account_id = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_account_id', true );
102
		$config->site_id    = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_site_id', true );
103
		$config->site_code  = get_post_meta( $post_id, '_pronamic_gateway_multisafepay_site_code', true );
104
105
		if ( Gateway::MODE_TEST === $config->mode ) {
106
			$config->api_url = MultiSafepay::API_TEST_URL;
107
		} else {
108
			$config->api_url = MultiSafepay::API_PRODUCTION_URL;
109
		}
110
111
		return $config;
112
	}
113
114
	/**
115
	 * Get gateway.
116
	 *
117
	 * @param int $post_id Post ID.
118
	 * @return Gateway
119
	 */
120
	public function get_gateway( $post_id ) {
121
		return new Gateway( $this->get_config( $post_id ) );
122
	}
123
}
124