diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
index 0f8aefb..8da4994 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/SubscriptionResource.java
@@ -193,12 +193,12 @@ public class SubscriptionResource extends JaxRsResourceBase {
logDeprecationParameterWarningIfNeeded(QUERY_REQUESTED_DT, QUERY_ENTITLEMENT_REQUESTED_DT, QUERY_BILLING_REQUESTED_DT);
// For ADD_ON we need to provide externalKey or the bundleId
- if (ProductCategory.ADD_ON.toString().equals(subscription.getProductCategory())) {
+ if (ProductCategory.ADD_ON.equals(subscription.getProductCategory())) {
Preconditions.checkArgument(subscription.getExternalKey() != null || subscription.getBundleId() != null, "SubscriptionJson bundleId or externalKey should be specified for ADD_ON");
}
- final boolean isInitialBundle = ProductCategory.BASE == subscription.getProductCategory() ||
- (ProductCategory.STANDALONE == subscription.getProductCategory() && subscription.getBundleId() == null);
+ final boolean isReusingExistingBundle = ProductCategory.ADD_ON == subscription.getProductCategory() ||
+ (ProductCategory.STANDALONE == subscription.getProductCategory() && subscription.getBundleId() != null);
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
@@ -218,9 +218,9 @@ public class SubscriptionResource extends JaxRsResourceBase {
final LocalDate resolvedEntitlementDate = requestedDate != null ? toLocalDate(requestedDate) : toLocalDate(entitlementDate);
final LocalDate resolvedBillingDate = requestedDate != null ? toLocalDate(requestedDate) : toLocalDate(billingDate);
final List<PlanPhasePriceOverride> overrides = PhasePriceOverrideJson.toPlanPhasePriceOverrides(subscription.getPriceOverrides(), spec, account.getCurrency());
- final Entitlement result = isInitialBundle
- ? entitlementApi.createBaseEntitlement(account.getId(), spec, subscription.getExternalKey(), overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, renameKeyIfExistsAndUnused, pluginProperties, callContext)
- : entitlementApi.addEntitlement(getBundleIdForAddOnCreation(subscription), spec, overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, pluginProperties, callContext);
+ final Entitlement result = isReusingExistingBundle
+ ? entitlementApi.addEntitlement(getBundleIdForAddOnCreation(subscription), spec, overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, pluginProperties, callContext)
+ : entitlementApi.createBaseEntitlement(account.getId(), spec, subscription.getExternalKey(), overrides, resolvedEntitlementDate, resolvedBillingDate, isMigrated, renameKeyIfExistsAndUnused, pluginProperties, callContext);
if (newBCD != null) {
result.updateBCD(newBCD, null, callContext);
}