1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class EduSveaWebPayBaseConfig implements \Svea\WebPay\Config\ConfigurationProvider { |
4
|
|
|
/** |
5
|
|
|
* @var EDU_SveaWebPay |
6
|
|
|
*/ |
7
|
|
|
public $plugin; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* EduSveaWebPayProductionConfig constructor. |
11
|
|
|
* |
12
|
|
|
* @param EDU_SveaWebPay $_plugin |
13
|
|
|
*/ |
14
|
|
|
public function __construct( $_plugin ) { |
15
|
|
|
$this->plugin = $_plugin; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* fetch username, used with invoice or payment plan (i.e. Svea WebService Europe API) |
20
|
|
|
* |
21
|
|
|
* @return string |
22
|
|
|
* |
23
|
|
|
* @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
24
|
|
|
* @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings |
25
|
|
|
* |
26
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
27
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
28
|
|
|
*/ |
29
|
|
|
public function getUsername( $type, $country ) { |
|
|
|
|
30
|
|
|
echo 'username'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* fetch password, used with invoice or payment plan (i.e. Svea WebService Europe API) |
35
|
|
|
* |
36
|
|
|
* @return string |
37
|
|
|
* |
38
|
|
|
* @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
39
|
|
|
* @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings |
40
|
|
|
* |
41
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
42
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
43
|
|
|
*/ |
44
|
|
|
public function getPassword( $type, $country ) { |
|
|
|
|
45
|
|
|
echo 'password'; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* fetch client number, used with invoice or payment plan (i.e. Svea WebService Europe API) |
50
|
|
|
* |
51
|
|
|
* @return \Svea\WebPay\Config\ClientNumber |
52
|
|
|
* |
53
|
|
|
* @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
54
|
|
|
* @param string $country iso3166 alpha-2 CountryCode, eg. SE, NO, DK, FI, NL, DE can be used if needed to match different configuration settings |
55
|
|
|
* |
56
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
57
|
|
|
* @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
58
|
|
|
*/ |
59
|
|
|
public function getClientNumber( $type, $country ) { |
|
|
|
|
60
|
|
|
echo 'client'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* fetch merchant id, used with card or direct bank payments (i.e. Svea Hosted Web Service API) |
65
|
|
|
* |
66
|
|
|
* @return string |
67
|
|
|
* |
68
|
|
|
* @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
69
|
|
|
* @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE |
70
|
|
|
*/ |
71
|
|
|
public function getMerchantId( $type, $country ) { |
|
|
|
|
72
|
|
|
$merchantId = $this->plugin->get_option( 'merchant_key', '' ); |
73
|
|
|
|
74
|
|
|
return $merchantId; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* fetch secret word, used with card or direct bank payments (i.e. Svea Hosted Web Service API) |
79
|
|
|
* |
80
|
|
|
* @return string |
81
|
|
|
* |
82
|
|
|
* @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
83
|
|
|
* @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE |
84
|
|
|
*/ |
85
|
|
|
public function getSecret( $type, $country ) { |
|
|
|
|
86
|
|
|
$secret = $this->plugin->get_option( 'merchant_secret', '' ); |
87
|
|
|
|
88
|
|
|
return $secret; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Constants for the endpoint url found in the class ConfigurationService.php |
93
|
|
|
* getEndPoint() should return an url corresponding to $type. |
94
|
|
|
* |
95
|
|
|
* @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE |
96
|
|
|
* |
97
|
|
|
* @throws Exception |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
|
101
|
|
|
public function getEndPoint( $type ) { /* Defined in subclasses */ |
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* fetch Checkout Merchant id, used for Checkout order type |
106
|
|
|
* |
107
|
|
|
* @return string |
108
|
|
|
*/ |
109
|
|
|
public function getCheckoutMerchantId() { |
|
|
|
|
110
|
|
|
$merchantId = $this->plugin->get_option( 'merchant_key', '' ); |
111
|
|
|
|
112
|
|
|
return $merchantId; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* fetch Checkout Secret word, used for Checkout order type |
117
|
|
|
* |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
public function getCheckoutSecret() { |
|
|
|
|
121
|
|
|
$secret = $this->plugin->get_option( 'merchant_secret', '' ); |
122
|
|
|
|
123
|
|
|
return $secret; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getIntegrationCompany() { |
|
|
|
|
127
|
|
|
return 'MultiNet Interactive AB : EduAdmin WordPress-plugin'; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getIntegrationPlatform() { |
|
|
|
|
131
|
|
|
return 'EduAdmin WordPress'; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
View Code Duplication |
class EduSveaWebPayProductionConfig extends EduSveaWebPayBaseConfig { |
|
|
|
|
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Constants for the endpoint url found in the class ConfigurationService.php |
139
|
|
|
* getEndPoint() should return an url corresponding to $type. |
140
|
|
|
* |
141
|
|
|
* @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE |
142
|
|
|
* |
143
|
|
|
* @throws Exception |
144
|
|
|
* @return string |
145
|
|
|
*/ |
146
|
|
|
|
147
|
|
|
public function getEndPoint( $type ) { |
|
|
|
|
148
|
|
|
switch ( strtoupper( $type ) ) { |
149
|
|
|
case 'HOSTED': |
150
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_PROD_URL; |
151
|
|
|
break; |
|
|
|
|
152
|
|
|
case 'INVOICE': |
153
|
|
|
case 'PAYMENTPLAN': |
154
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_PROD_WS_URL; |
155
|
|
|
break; |
|
|
|
|
156
|
|
|
case 'HOSTED_ADMIN': |
157
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_PROD_HOSTED_ADMIN_URL; |
158
|
|
|
break; |
|
|
|
|
159
|
|
|
case 'ADMIN': |
160
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_PROD_ADMIN_URL; |
161
|
|
|
break; |
|
|
|
|
162
|
|
|
case 'CHECKOUT': |
163
|
|
|
return Svea\WebPay\Config\ConfigurationService::CHECKOUT_PROD_BASE_URL; |
164
|
|
|
break; |
|
|
|
|
165
|
|
|
default: |
166
|
|
|
throw new Exception( 'Invalid type. Accepted values: INVOICE, PAYMENTPLAN, HOSTED, HOSTED_ADMIN, CHECKOUT' ); |
167
|
|
|
break; |
|
|
|
|
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
View Code Duplication |
class EduSveaWebPayTestConfig extends EduSveaWebPayBaseConfig { |
|
|
|
|
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Constants for the endpoint url found in the class ConfigurationService.php |
176
|
|
|
* getEndPoint() should return an url corresponding to $type. |
177
|
|
|
* |
178
|
|
|
* @param string $type one of Svea\WebPay\Config\ConfigurationProvider::HOSTED_TYPE, ::INVOICE_TYPE, ::PAYMENTPLAN_TYPE, ::HOSTED_ADMIN_TYPE, ::ADMIN_TYPE |
179
|
|
|
* |
180
|
|
|
* @throws Exception |
181
|
|
|
* @return string |
182
|
|
|
*/ |
183
|
|
|
public function getEndPoint( $type ) { |
|
|
|
|
184
|
|
|
switch ( strtoupper( $type ) ) { |
185
|
|
|
case 'HOSTED': |
186
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_TEST_URL; |
187
|
|
|
break; |
|
|
|
|
188
|
|
|
case 'INVOICE': |
189
|
|
|
case 'PAYMENTPLAN': |
190
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_TEST_WS_URL; |
191
|
|
|
break; |
|
|
|
|
192
|
|
|
case 'HOSTED_ADMIN': |
193
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_TEST_HOSTED_ADMIN_URL; |
194
|
|
|
break; |
|
|
|
|
195
|
|
|
case 'ADMIN': |
196
|
|
|
return Svea\WebPay\Config\ConfigurationService::SWP_TEST_ADMIN_URL; |
197
|
|
|
break; |
|
|
|
|
198
|
|
|
case 'CHECKOUT': |
199
|
|
|
return Svea\WebPay\Config\ConfigurationService::CHECKOUT_TEST_BASE_URL; |
200
|
|
|
break; |
|
|
|
|
201
|
|
|
default: |
202
|
|
|
throw new Exception( 'Invalid type. Accepted values: INVOICE, PAYMENTPLAN, HOSTED, HOSTED_ADMIN, CHECKOUT' ); |
203
|
|
|
break; |
|
|
|
|
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
} |