Skip to content

Commit 644a8e1

Browse files
committed
KUSTOM-36 Adjusts the endpoints to direct to Kustom instead of Klarna API
1 parent d5d6387 commit 644a8e1

4 files changed

Lines changed: 60 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
11.0.14 / 2026-01-15
2+
==================
3+
4+
* KUSTOM-36 Adjusts the endpoints to direct to Kustom instead of Klarna API
15

26
11.0.13 / 2025-11-13
37
==================

Model/System/MerchantPortal.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
*/
2020
class MerchantPortal
2121
{
22-
public const MERCHANT_PORTAL = 'https://portal.klarna.com/orders/';
22+
public const MERCHANT_PORTAL = 'https://portal.kustom.co/';
23+
public const MERCHANT_TEST_PORTAL = 'https://portal.playground.kustom.co/';
2324

2425
/**
2526
* @var Api
@@ -45,13 +46,16 @@ public function __construct(Api $apiConfiguration)
4546
public function getOrderMerchantPortalLink(MageOrder $mageOrder, KlarnaOrder $klarnaOrder): string
4647
{
4748
$store = $mageOrder->getStore();
48-
$merchantId = $this->apiConfiguration->getUserName($store, $mageOrder->getOrderCurrencyCode());
49-
50-
$merchantIdArray = explode("_", $merchantId);
51-
return self::MERCHANT_PORTAL .
52-
"merchants/" .
53-
$merchantIdArray[0] .
54-
"/orders/" .
55-
$klarnaOrder->getKlarnaOrderId();
49+
$currency = $mageOrder->getOrderCurrencyCode();
50+
51+
$isTest = $this->apiConfiguration->isTestMode($store, $currency);
52+
$portalBaseUrl = $isTest ? self::MERCHANT_TEST_PORTAL : self::MERCHANT_PORTAL;
53+
$merchantId = $this->apiConfiguration->getUserName($store, $currency);
54+
55+
return $portalBaseUrl .
56+
"orders/" .
57+
$klarnaOrder->getKlarnaOrderId() .
58+
"?merchantId=" .
59+
$merchantId;
5660
}
5761
}

Test/Unit/Model/System/MerchantPortalTest.php

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ class MerchantPortalTest extends TestCase
3333
*/
3434
private $mageOrder;
3535

36-
/**
37-
* @covers ::getOrderMerchantPortalLink
38-
*/
39-
public function testGetOrderMerchantPortalLinkUsesGlobalUrl(): void
40-
{
41-
$merchantId = 'K1';
42-
$this->dependencyMocks['apiConfiguration']->method('getUserName')
43-
->willReturn($merchantId);
44-
45-
$urlPath = 'merchants/' . $merchantId . '/orders/';
46-
$result = $this->model->getOrderMerchantPortalLink($this->mageOrder, $this->klarnaOrder);
47-
$expected = MerchantPortal::MERCHANT_PORTAL . $urlPath;
48-
49-
static::assertEquals($result, $expected);
50-
}
51-
5236
protected function setUp(): void
5337
{
5438
$this->model = parent::setUpMocks(MerchantPortal::class);
@@ -64,5 +48,47 @@ protected function setUp(): void
6448
->willReturn($store);
6549
$this->mageOrder->method('getOrderCurrencyCode')
6650
->willReturn('currency_code');
51+
52+
$merchantId = 'MERCHANT-123';
53+
$this->dependencyMocks['apiConfiguration']
54+
->method('getUsername')
55+
->willReturn($merchantId);
56+
$this->klarnaOrder
57+
->method('getKlarnaOrderId')
58+
->willReturn('ORDER-123');
59+
}
60+
61+
/**
62+
* @covers ::getOrderMerchantPortalLink
63+
*/
64+
public function testGetOrderMerchantPortalLinkToLive(): void
65+
{
66+
$this->dependencyMocks['apiConfiguration']
67+
->method('isTestMode')
68+
->willreturn(false);
69+
70+
$urlPath = 'orders/ORDER-123?merchantId=MERCHANT-123';
71+
$expected = MerchantPortal::MERCHANT_PORTAL . $urlPath;
72+
73+
$result = $this->model->getOrderMerchantPortalLink($this->mageOrder, $this->klarnaOrder);
74+
75+
static::assertEquals($result, $expected);
76+
}
77+
78+
/**
79+
* @covers ::getOrderMerchantPortalLink
80+
*/
81+
public function testGetOrderMerchantPortalLinkToTest(): void
82+
{
83+
$this->dependencyMocks['apiConfiguration']
84+
->method('isTestMode')
85+
->willreturn(true);
86+
87+
$urlPath = 'orders/ORDER-123?merchantId=MERCHANT-123';
88+
$expected = MerchantPortal::MERCHANT_TEST_PORTAL . $urlPath;
89+
90+
$result = $this->model->getOrderMerchantPortalLink($this->mageOrder, $this->klarnaOrder);
91+
92+
static::assertEquals($result, $expected);
6793
}
6894
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Kustom Base Magento 2 Extension",
44
"type": "magento2-module",
55
"license": "Apache-2.0",
6-
"version": "11.0.13",
6+
"version": "11.0.14",
77
"scripts": {
88
"test": "phpunit",
99
"cov": "phpunit --coverage-html coverage"

0 commit comments

Comments
 (0)