Skip to content

Commit

Permalink
Relax configured currency checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-signal committed Sep 17, 2024
1 parent dd7a20a commit 8cb9c60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ public boolean areLevelConstraintsSatisfied() {
@JsonIgnore
@ValidationMethod(message = "has a mismatch between the levels supported currencies")
public boolean isCurrencyListSameAcrossAllLevels() {
final Map<Long, SubscriptionLevelConfiguration> subscriptionLevels = Stream
.concat(donationLevels.entrySet().stream(), backupLevels.entrySet().stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
return isCurrencyListSameAccrossLevelConfigurations(donationLevels)
&& isCurrencyListSameAccrossLevelConfigurations(backupLevels);
}

Optional<SubscriptionLevelConfiguration> any = subscriptionLevels.values().stream().findAny();
private static boolean isCurrencyListSameAccrossLevelConfigurations(
Map<Long, ? extends SubscriptionLevelConfiguration> subscriptionLevels) {
Optional<? extends SubscriptionLevelConfiguration> any = subscriptionLevels.values().stream().findAny();
if (any.isEmpty()) {
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions service/src/test/resources/config/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ subscription: # configuration for Stripe subscriptions
backupExpiration: P30D
backupGracePeriod: P15D
backupFreeTierMediaDuration: P30D
backupLevels:
201:
playProductId: EXAMPLE
prices: {}
levels:
500:
badge: EXAMPLE
Expand Down

0 comments on commit 8cb9c60

Please sign in to comment.