Failed Conditions
Push — master ( 84f509...0a235e )
by Remco
14:29 queued 05:04
created

Config::get_google_pay_merchant_identifier()   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
 * Config
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Adyen
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway;
14
use Pronamic\WordPress\Pay\Core\GatewayConfig;
15
16
/**
17
 * Config
18
 *
19
 * @author  Remco Tolsma
20
 * @version 1.0.4
21
 * @since   1.0.0
22
 */
23
class Config extends GatewayConfig {
24
	/**
25
	 * API Key.
26
	 *
27
	 * @var string|null
28
	 */
29
	public $api_key;
30
31
	/**
32
	 * API Live URL Prefix.
33
	 *
34
	 * @var string|null
35
	 */
36
	public $api_live_url_prefix;
37
38
	/**
39
	 * Merchant Account.
40
	 *
41
	 * @var string|null
42
	 */
43
	public $merchant_account;
44
45
	/**
46
	 * Origin key.
47
	 *
48
	 * @var string|null
49
	 */
50
	public $origin_key;
51
52
	/**
53
	 * Apple Pay merchant identifier.
54
	 *
55
	 * @var string|null
56
	 */
57
	public $apple_pay_merchant_id;
58
59
	/**
60
	 * Apple Pay merchant identity certificate.
61
	 *
62
	 * @var string|null
63
	 */
64
	public $apple_pay_merchant_id_certificate;
65
66
	/**
67
	 * Apple Pay merchant identity private key.
68
	 *
69
	 * @var string|null
70
	 */
71
	public $apple_pay_merchant_id_private_key;
72
73
	/**
74
	 * Apple Pay merchant identity private key password.
75
	 *
76
	 * @var string|null
77
	 */
78
	public $apple_pay_merchant_id_private_key_password;
79
80
	/**
81
	 * Google Pay merchant identifier.
82
	 *
83
	 * @var string|null
84
	 */
85
	public $google_pay_merchant_identifier;
86
87
	/**
88
	 * Get API key.
89
	 *
90
	 * @return string|null
91
	 */
92 11
	public function get_api_key() {
93 11
		return $this->api_key;
94
	}
95
96
	/**
97
	 * Get merchant account.
98
	 *
99
	 * @return string
100
	 */
101 1
	public function get_merchant_account() {
102 1
		return strval( $this->merchant_account );
103
	}
104
105
	/**
106
	 * Get Apple Pay merchant identifier.
107
	 *
108
	 * @return string|null
109
	 */
110
	public function get_apple_pay_merchant_id() {
111
		return $this->apple_pay_merchant_id;
112
	}
113
114
	/**
115
	 * Get Apple Pay merchant identity certificate.
116
	 *
117
	 * @return string|null
118
	 */
119
	public function get_apple_pay_merchant_id_certificate() {
120
		return $this->apple_pay_merchant_id_certificate;
121
	}
122
123
	/**
124
	 * Get Apple Pay merchant identity private key.
125
	 *
126
	 * @return string|null
127
	 */
128
	public function get_apple_pay_merchant_id_private_key() {
129
		return $this->apple_pay_merchant_id_private_key;
130
	}
131
132
	/**
133
	 * Get Apple Pay merchant identity private key password.
134
	 *
135
	 * @return string|null
136
	 */
137
	public function get_apple_pay_merchant_id_private_key_password() {
138
		return $this->apple_pay_merchant_id_private_key_password;
139
	}
140
141
	/**
142
	 * Get Google Pay merchant identifier.
143
	 *
144
	 * @return string|null
145
	 */
146
	public function get_google_pay_merchant_identifier() {
147
		return $this->google_pay_merchant_identifier;
148
	}
149
150
	/**
151
	 * Get API URL.
152
	 *
153
	 * @param string $method API method.
154
	 * @return string
155
	 * @throws \Exception Throws exception when mode is live and API live URL prefix is empty.
156
	 */
157 12
	public function get_api_url( $method ) {
158 12
		if ( Core_Gateway::MODE_TEST === $this->mode ) {
159 11
			return sprintf( Endpoint::API_URL_TEST, $method );
160
		}
161
162 2
		if ( empty( $this->api_live_url_prefix ) ) {
163 1
			throw new \Exception( 'Adyen API Live URL prefix is required for live configurations.' );
164
		}
165
166 1
		return sprintf( Endpoint::API_URL_LIVE, $this->api_live_url_prefix, $method );
167
	}
168
}
169