Skip to content

Commit

Permalink
fix #851 - do not expect STRIPE_CONNECTED_ID if the current context i…
Browse files Browse the repository at this point in the history
…s System
  • Loading branch information
cbellone committed Dec 18, 2019
1 parent 0577b34 commit 1a48079
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/alfio/manager/payment/BaseStripeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import alfio.model.EventAndOrganizationId;
import alfio.model.PaymentInformation;
import alfio.model.system.ConfigurationKeys;
import alfio.model.system.ConfigurationPathLevel;
import alfio.model.transaction.PaymentContext;
import alfio.model.transaction.PaymentMethod;
import alfio.model.transaction.PaymentProxy;
Expand Down Expand Up @@ -278,7 +279,7 @@ boolean accept(PaymentMethod paymentMethod, PaymentContext context,
var configuration = configurationManager.getFor(optionsToLoad, context.getConfigurationLevel());
return paymentMethod == PaymentMethod.CREDIT_CARD
&& configuration.get(STRIPE_CC_ENABLED).getValueAsBooleanOrDefault(false)
&& (!configuration.get(PLATFORM_MODE_ENABLED).getValueAsBooleanOrDefault(false) || configuration.get(STRIPE_CONNECTED_ID).isPresent())
&& (!configuration.get(PLATFORM_MODE_ENABLED).getValueAsBooleanOrDefault(false) || context.getConfigurationLevel().getPathLevel() == ConfigurationPathLevel.SYSTEM || configuration.get(STRIPE_CONNECTED_ID).isPresent())
&& subValidator.test(configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ void stripeConfigurationIncompletePlatformModeOn() {
assertFalse(stripeWebhookPaymentManager.accept(PaymentMethod.CREDIT_CARD, new PaymentContext(null, configurationLevel)));
}

@Test
void doNotConsiderConnectedIdIfConfigurationLevelIsSystem() {
var configuration = new HashMap<>(completeStripeConfiguration(true));
configuration.put(STRIPE_CONNECTED_ID, new MaybeConfiguration(STRIPE_CONNECTED_ID));// missing config

var configurationLevel = ConfigurationLevel.system();
when(configurationManager.getFor(EnumSet.of(STRIPE_ENABLE_SCA, BASE_URL, STRIPE_WEBHOOK_PAYMENT_KEY, STRIPE_CC_ENABLED, PLATFORM_MODE_ENABLED, STRIPE_CONNECTED_ID), configurationLevel))
.thenReturn(configuration);
assertTrue(stripeWebhookPaymentManager.accept(PaymentMethod.CREDIT_CARD, new PaymentContext(null, configurationLevel)));
}

@Test
void stripeConfigurationCompletePlatformModeOn() {
var configurationLevel = ConfigurationLevel.organization(1);
Expand Down

0 comments on commit 1a48079

Please sign in to comment.