Add EAP fee to domain check flow

(Original from mmuller@: []
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126911443
This commit is contained in:
ctingue 2016-07-08 07:54:09 -07:00 committed by Ben McIlwain
parent 5ebfb87651
commit 262aab22b9
4 changed files with 77 additions and 15 deletions

View file

@ -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());
}
}

View file

@ -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.
*
* <p>TODO: This probably needs to include the renew price.
* Returns a new restore price (including the renew price) for the pricer.
*
* <p>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<String> getFeeClass(String domainName, DateTime date) {
return getPricesForDomainName(domainName, date).getFeeClass();
}
// TODO(b/29089413): Add support for transfer prices once this is plumbed through the flows.
}