diff --git a/java/google/registry/flows/domain/DomainFlowUtils.java b/java/google/registry/flows/domain/DomainFlowUtils.java index f30ef953f..7eeff164e 100644 --- a/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/java/google/registry/flows/domain/DomainFlowUtils.java @@ -79,7 +79,6 @@ import google.registry.model.mark.Mark; import google.registry.model.mark.ProtectedMark; import google.registry.model.mark.Trademark; import google.registry.model.poll.PollMessage; -import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; @@ -89,6 +88,7 @@ import google.registry.model.smd.AbstractSignedMark; import google.registry.model.smd.EncodedSignedMark; import google.registry.model.smd.SignedMark; import google.registry.model.smd.SignedMarkRevocationList; +import google.registry.pricing.TldSpecificLogicEngine; import google.registry.tmch.TmchXmlSignature; import google.registry.tmch.TmchXmlSignature.CertificateSignatureException; import google.registry.util.Idn; @@ -576,13 +576,11 @@ public class DomainFlowUtils { throw new CurrencyUnitMismatchException(); } - DomainPrices prices = getPricesForDomainName(domainName, now); builder .setCommand(feeCommand) .setCurrency(registry.getCurrency()) .setPeriod(feeRequest.getPeriod()) - // Choose from four classes: premium, premium-collision, collision, or null (standard case). - .setClass(prices.getFeeClass().orNull()); + .setClass(TldSpecificLogicEngine.getFeeClass(domainName, now).orNull()); switch (feeCommand.getCommand()) { case UNKNOWN: @@ -592,25 +590,20 @@ public class DomainFlowUtils { builder.setClass("reserved"); // Override whatever class we've set above. } else { builder.setFees( - ImmutableList.of( - Fee.create(prices.getCreateCost().multipliedBy(years).getAmount(), "create"))); + TldSpecificLogicEngine.getCreatePrice(registry, domainName, now, years).getFees()); } break; case RESTORE: if (years != 1) { throw new RestoresAreAlwaysForOneYearException(); } - // Restores have a "renew" and a "restore" fee. builder.setFees( - ImmutableList.of( - Fee.create(prices.getRenewCost().multipliedBy(years).getAmount(), "renew"), - Fee.create(registry.getStandardRestoreCost().getAmount(), "restore"))); + TldSpecificLogicEngine.getRestorePrice(registry, domainName, now, years).getFees()); break; default: // Anything else (transfer|renew) will have a "renew" fee. builder.setFees( - ImmutableList.of( - Fee.create(prices.getRenewCost().multipliedBy(years).getAmount(), "renew"))); + TldSpecificLogicEngine.getRenewPrice(registry, domainName, now, years).getFees()); } } diff --git a/java/google/registry/pricing/TldSpecificLogicEngine.java b/java/google/registry/pricing/TldSpecificLogicEngine.java index 0e4b86fd8..28420e928 100644 --- a/java/google/registry/pricing/TldSpecificLogicEngine.java +++ b/java/google/registry/pricing/TldSpecificLogicEngine.java @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState; import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import google.registry.model.ImmutableObject; @@ -122,9 +123,7 @@ public final class TldSpecificLogicEngine { } /** - * Returns a new restore price for the pricer. - * - *
TODO: This probably needs to include the renew price. + * Returns a new restore price (including the renew price) for the pricer. * *
domain name, number of years and date must be defined before calling this.
*/
@@ -138,5 +137,12 @@ public final class TldSpecificLogicEngine {
Fee.create(registry.getStandardRestoreCost().getAmount(), "restore")));
}
+ /**
+ * Returns the fee class for a given domain and date.
+ */
+ public static Optional