Skip to content

Commit

Permalink
PIWOO-414 Add feature flag for bancomat
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Mar 7, 2024
1 parent f3aa7b1 commit ddd7453
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,20 @@ public function services(): array
}
return $availableMethods;
},
'gateway.getKlarnaPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array {
'gateway.getPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array {
$availablePaymentMethods = $container->get('gateway.listAllMethodsAvailable');
$klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', true);
if (!$klarnaOneFlag) {
return array_filter($availablePaymentMethods, static function ($method) {
return $method['id'] !== Constants::KLARNA;
});
}
$bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', false);
if (!$bancomatpayFlag) {
return array_filter($availablePaymentMethods, static function ($method) {
return $method['id'] !== Constants::BANCOMATPAY;
});
}
return $availablePaymentMethods;
},
'gateway.isSDDGatewayEnabled' => static function (ContainerInterface $container): bool {
Expand Down Expand Up @@ -611,7 +617,7 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):
protected function instantiatePaymentMethods($container): array
{
$paymentMethods = [];
$listAllAvailablePaymentMethods = $container->get('gateway.getKlarnaPaymentMethodsAfterFeatureFlag');
$listAllAvailablePaymentMethods = $container->get('gateway.getPaymentMethodsAfterFeatureFlag');
$iconFactory = $container->get(IconFactory::class);
assert($iconFactory instanceof IconFactory);
$settingsHelper = $container->get('settings.settings_helper');
Expand Down
2 changes: 2 additions & 0 deletions src/PaymentMethods/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ class Constants
public const KLARNA = 'klarna';
public const DIRECTDEBIT = 'directdebit';
public const BANKTRANSFER = 'banktransfer';

public const BANCOMATPAY = 'bancomatpay';
}

0 comments on commit ddd7453

Please sign in to comment.