From fcf641dbd3dfedb298d83a7c30869c10aa0277d2 Mon Sep 17 00:00:00 2001 From: Artyom Jaksov Date: Wed, 11 Sep 2024 17:14:39 +0200 Subject: [PATCH] add release channel config option --- Api/Config/System/ConnectionInterface.php | 11 +++++++ Model/Config/Source/ReleaseChannel.php | 34 ++++++++++++++++++++ Model/Config/System/ConnectionRepository.php | 11 +++++++ Service/Order/PaymentCreationService.php | 2 +- etc/adminhtml/system/general.xml | 20 ++++++++++++ etc/config.xml | 2 ++ 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Model/Config/Source/ReleaseChannel.php diff --git a/Api/Config/System/ConnectionInterface.php b/Api/Config/System/ConnectionInterface.php index 0877cef..a464ee6 100644 --- a/Api/Config/System/ConnectionInterface.php +++ b/Api/Config/System/ConnectionInterface.php @@ -21,10 +21,12 @@ interface ConnectionInterface extends DebugInterface public const XML_PATH_SANDBOX_CLIENT_SECRET = 'payment/truelayer/sandbox_client_secret'; public const XML_PATH_SANDBOX_PRIVATE_KEY = 'payment/truelayer/sandbox_private_key'; public const XML_PATH_SANDBOX_KEY_ID = 'payment/truelayer/sandbox_key_id'; + public const XML_PATH_SANDBOX_RELEASE_CHANNEL = 'payment/truelayer/sandbox_release_channel'; public const XML_PATH_PRODUCTION_CLIENT_ID = 'payment/truelayer/production_client_id'; public const XML_PATH_PRODUCTION_CLIENT_SECRET = 'payment/truelayer/production_client_secret'; public const XML_PATH_PRODUCTION_PRIVATE_KEY = 'payment/truelayer/production_private_key'; public const XML_PATH_PRODUCTION_KEY_ID = 'payment/truelayer/production_key_id'; + public const XML_PATH_PRODUCTION_RELEASE_CHANNEL = 'payment/truelayer/production_release_channel'; /** * Get Merchant Account Name @@ -53,4 +55,13 @@ public function isSandbox(?int $storeId = null): bool; * @return array */ public function getCredentials(?int $storeId = null, ?bool $forceSandbox = null): array; + + /** + * Get associated array of credentials + * + * @param int|null $storeId + * + * @return array + */ + public function getReleaseChannel(?int $storeId = null): string; } diff --git a/Model/Config/Source/ReleaseChannel.php b/Model/Config/Source/ReleaseChannel.php new file mode 100644 index 0000000..8aee359 --- /dev/null +++ b/Model/Config/Source/ReleaseChannel.php @@ -0,0 +1,34 @@ + self::GENERAL_AVAILABILITY, 'label' => __('General Availability')], + ['value' => self::PUBLIC_BETA, 'label' => __('Public Beta')], + ['value' => self::PRIVATE_BETA, 'label' => __('Private Beta')] + ]; + } +} diff --git a/Model/Config/System/ConnectionRepository.php b/Model/Config/System/ConnectionRepository.php index b39fc7c..da47f51 100644 --- a/Model/Config/System/ConnectionRepository.php +++ b/Model/Config/System/ConnectionRepository.php @@ -9,6 +9,7 @@ use TrueLayer\Connect\Api\Config\System\ConnectionInterface; use TrueLayer\Connect\Model\Config\Source\Mode; +use TrueLayer\Connect\Model\Config\Source\ReleaseChannel; /** * Credentials provider class @@ -46,6 +47,16 @@ public function getCredentials(?int $storeId = null, ?bool $forceSandbox = null) ]; } + /** + * @inheritDoc + */ + public function getReleaseChannel(?int $storeId = null): string + { + $isSandBox = $this->isSandbox($storeId); + $path = $isSandBox ? self::XML_PATH_SANDBOX_RELEASE_CHANNEL : self::XML_PATH_PRODUCTION_RELEASE_CHANNEL; + return $this->getStoreValue($path, $storeId) ?: ReleaseChannel::GENERAL_AVAILABILITY; + } + /** * @param int|null $storeId * @param bool $isSandBox diff --git a/Service/Order/PaymentCreationService.php b/Service/Order/PaymentCreationService.php index 953a24f..cc83d90 100644 --- a/Service/Order/PaymentCreationService.php +++ b/Service/Order/PaymentCreationService.php @@ -125,7 +125,7 @@ private function createPaymentConfig( "countries" => [ $order->getBillingAddress()->getCountryId() ], - "release_channel" => "general_availability", + "release_channel" => $this->configRepository->getReleaseChannel((int) $order->getStoreId()), "customer_segments" => $this->configRepository->getBankingProviders(), "excludes" => [ "provider_ids" => [ diff --git a/etc/adminhtml/system/general.xml b/etc/adminhtml/system/general.xml index eb110f8..94b9a1a 100644 --- a/etc/adminhtml/system/general.xml +++ b/etc/adminhtml/system/general.xml @@ -112,6 +112,26 @@ sandbox + + + TrueLayer\Connect\Model\Config\Source\ReleaseChannel + payment/truelayer/sandbox_release_channel + Note that many EUR providers are in Public Beta or Private Beta.]]> + + 1 + sandbox + + + + + TrueLayer\Connect\Model\Config\Source\ReleaseChannel + payment/truelayer/production_release_channel + Note that many EUR providers are in Public Beta or Private Beta.]]> + + 1 + production + +