Skip to content

Commit

Permalink
Merge pull request wso2#12427 from AnuGayan/master
Browse files Browse the repository at this point in the history
Fix the subscription policy creation issue when monetization is enabled
  • Loading branch information
PasanT9 authored Apr 22, 2024
2 parents 26e1da6 + 2bce23e commit 36bad50
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static org.wso2.carbon.apimgt.impl.APIConstants.COMMERCIAL_TIER_PLAN;

/**
* This class provides the core API provider functionality. It is implemented in a very
* self-contained and 'pure' manner, without taking requirements like security into account,
Expand Down Expand Up @@ -3304,10 +3306,12 @@ public void addPolicy(Policy policy) throws APIManagementException {
handleException("Subscription Policy with name " + subPolicy.getPolicyName() + " already exists");
}
apiMgtDAO.addSubscriptionPolicy(subPolicy);
String monetizationPlan = subPolicy.getMonetizationPlan();
Map<String, String> monetizationPlanProperties = subPolicy.getMonetizationPlanProperties();
if (StringUtils.isNotBlank(monetizationPlan) && MapUtils.isNotEmpty(monetizationPlanProperties)) {
createMonetizationPlan(subPolicy);
if (subPolicy.getBillingPlan().equalsIgnoreCase(COMMERCIAL_TIER_PLAN)) {
String monetizationPlan = subPolicy.getMonetizationPlan();
Map<String, String> monetizationPlanProperties = subPolicy.getMonetizationPlanProperties();
if (StringUtils.isNotBlank(monetizationPlan) && MapUtils.isNotEmpty(monetizationPlanProperties)) {
createMonetizationPlan(subPolicy);
}
}
//policy id is not set. retrieving policy to get the id.
SubscriptionPolicy retrievedPolicy = apiMgtDAO.getSubscriptionPolicy(subPolicy.getPolicyName(), tenantId);
Expand Down

0 comments on commit 36bad50

Please sign in to comment.