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
|
|
|
* Google Pay merchant identifier. |
54
|
|
|
* |
55
|
|
|
* @var string|null |
56
|
|
|
*/ |
57
|
11 |
|
public $google_pay_merchant_identifier; |
58
|
11 |
|
|
59
|
|
|
/** |
60
|
|
|
* Get API key. |
61
|
|
|
* |
62
|
|
|
* @return string|null |
63
|
|
|
*/ |
64
|
|
|
public function get_api_key() { |
65
|
|
|
return $this->api_key; |
66
|
1 |
|
} |
67
|
1 |
|
|
68
|
|
|
/** |
69
|
|
|
* Get merchant account. |
70
|
|
|
* |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function get_merchant_account() { |
74
|
|
|
return strval( $this->merchant_account ); |
75
|
|
|
} |
76
|
|
|
|
77
|
12 |
|
/** |
78
|
12 |
|
* Get Google Pay merchant identifier. |
79
|
11 |
|
* |
80
|
|
|
* @return string|null |
81
|
|
|
*/ |
82
|
2 |
|
public function get_google_pay_merchant_identifier() { |
83
|
1 |
|
return $this->google_pay_merchant_identifier; |
84
|
|
|
} |
85
|
|
|
|
86
|
1 |
|
/** |
87
|
|
|
* Get API URL. |
88
|
|
|
* |
89
|
|
|
* @param string $method API method. |
90
|
|
|
* @return string |
91
|
|
|
* @throws \Exception Throws exception when mode is live and API live URL prefix is empty. |
92
|
|
|
*/ |
93
|
|
|
public function get_api_url( $method ) { |
94
|
|
|
if ( Core_Gateway::MODE_TEST === $this->mode ) { |
95
|
|
|
return sprintf( Endpoint::API_URL_TEST, $method ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
if ( empty( $this->api_live_url_prefix ) ) { |
99
|
|
|
throw new \Exception( 'Adyen API Live URL prefix is required for live configurations.' ); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return sprintf( Endpoint::API_URL_LIVE, $this->api_live_url_prefix, $method ); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|