Skip to content

Commit 533aead

Browse files
authored
Merge pull request #13 from getkevin/feature/configure-domain-optionaly-by-env
Add domain option based on env variables
2 parents 7911bd2 + ecd9c17 commit 533aead

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

Api/Kevin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public function getConnection($clientId = null, $clientSecret = null)
5454
'version' => '0.3',
5555
];
5656

57+
if (getenv('API_KEVIN_DOMAIN')) {
58+
$options['domain'] = getenv('API_KEVIN_DOMAIN');
59+
}
60+
5761
$options = array_merge($options, $this->config->getSystemData());
5862

5963
return new \Kevin\Client($clientId, $clientSecret, $options);

Model/Adapter.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public function initPayment($order)
8080
$companyBankAccount = $this->config->getCompanyBankAccount();
8181

8282
$params = [
83-
'Redirect-URL' => $this->url->getUrl('kevin/payment/callback'),
84-
'Webhook-URL' => $this->url->getUrl('kevin/payment/notify'),
83+
'Redirect-URL' => $this->getRedirectContextUrl('kevin/payment/callback'),
84+
'Webhook-URL' => $this->getWebHookContextUrl('kevin/payment/notify'),
8585
'description' => sprintf('Order %s', $order->getIncrementId()),
8686
'currencyCode' => $order->getOrderCurrency()->ToString(),
8787
'amount' => number_format($order->getGrandTotal(), 2, '.', ''),
@@ -208,4 +208,32 @@ public function getTransaction($transactionId)
208208

209209
return $transaction;
210210
}
211+
212+
/**
213+
* @param $uri
214+
*
215+
* @return string
216+
*/
217+
private function getWebHookContextUrl($uri)
218+
{
219+
if (getenv('CUSTOM_WEBHOOK_URL')) {
220+
return getenv('CUSTOM_WEBHOOK_URL').$uri;
221+
}
222+
223+
return $this->url->getUrl($uri);
224+
}
225+
226+
/**
227+
* @param $uri
228+
*
229+
* @return string
230+
*/
231+
private function getRedirectContextUrl($uri)
232+
{
233+
if (getenv('CUSTOM_REDIRECT_URL')) {
234+
return getenv('CUSTOM_REDIRECT_URL').$uri;
235+
}
236+
237+
return $this->url->getUrl($uri);
238+
}
211239
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "getkevin/kevin-magento2",
33
"description": "Implements integration with the Kevin payment service provider.",
4-
"version": "1.2.0",
4+
"version": "1.3.0",
55
"authors": [
66
{
77
"name": "kevin.",

0 commit comments

Comments
 (0)