Skip to content

Commit

Permalink
Merge pull request #190 from bold-commerce/Q1-656
Browse files Browse the repository at this point in the history
Make storefront client url configurable.
  • Loading branch information
p-bystritsky authored Nov 28, 2023
2 parents bfcba77 + b1e4283 commit 38a881d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions Model/Http/BoldStorefrontClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
class BoldStorefrontClient implements ClientInterface
{
public const URL = 'https://api.boldcommerce.com/checkout/storefront/';

/**
* @var ConfigInterface
*/
Expand Down Expand Up @@ -172,13 +170,14 @@ private function getHeaders(): array
* @return string
* @throws LocalizedException
*/
private function getUrl(int $websiteId, string $path): string
public function getUrl(int $websiteId, string $path): string
{
$apiUrl = $this->config->getApiUrl($websiteId) . 'checkout/storefront/';
$boldCheckoutData = $this->checkoutSession->getBoldCheckoutData();
if (!$boldCheckoutData) {
throw new LocalizedException(__('Bold Checkout data is not set.'));
}
$publicOrderId = $boldCheckoutData['data']['public_order_id'];
return self::URL . $this->config->getShopId($websiteId) . '/' . $publicOrderId . '/' . $path;
return $apiUrl . $this->config->getShopId($websiteId) . '/' . $publicOrderId . '/' . $path;
}
}
6 changes: 2 additions & 4 deletions UI/Payment/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

use Bold\Checkout\Api\Http\ClientInterface;
use Bold\Checkout\Model\ConfigInterface;
use Bold\Checkout\Model\Http\BoldStorefrontClient;
use Bold\Checkout\Model\Payment\Gateway\Service;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Checkout\Model\Session;
Expand Down Expand Up @@ -132,7 +131,7 @@ public function getConfig(): array
'publicOrderId' => $orderId,
'jwtToken' => $jwtToken,
'countries' => $this->getAllowedCountries(),
'url' => BoldStorefrontClient::URL . $shopId . '/' . $orderId . '/',
'url' => $this->client->getUrl($websiteId, ''),
],
];
}
Expand All @@ -149,7 +148,6 @@ private function getIframeSrc(): ?string
return null;
}
$websiteId = (int)$this->storeManager->getWebsite()->getId();
$shopId = $this->config->getShopId($websiteId);
try {
$styles = $this->getStyles();
if ($styles) {
Expand All @@ -163,7 +161,7 @@ private function getIframeSrc(): ?string
if (!$orderId || !$jwtToken) {
return null;
}
return BoldStorefrontClient::URL . $shopId . '/' . $orderId . '/payments/iframe?token=' . $jwtToken;
return $this->client->getUrl($websiteId, 'payments/iframe?token=' . $jwtToken);
}

/**
Expand Down

0 comments on commit 38a881d

Please sign in to comment.