mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Add EAP fees to domain create flow
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126411200
This commit is contained in:
parent
d6bd2d56cd
commit
273fc0014d
7 changed files with 118 additions and 18 deletions
|
@ -36,7 +36,6 @@ import static google.registry.model.EppResourceUtils.loadByUniqueId;
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -66,8 +65,8 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.smd.SignedMark;
|
||||
import google.registry.model.tmch.ClaimsListShard;
|
||||
|
||||
import org.joda.money.Money;
|
||||
import google.registry.pricing.TldSpecificLogicEngine;
|
||||
import google.registry.pricing.TldSpecificLogicEngine.EppCommandOperations;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -89,7 +88,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
protected InternetDomainName domainName;
|
||||
protected String idnTableName;
|
||||
protected FeeCreateExtension feeCreate;
|
||||
protected Money createCost;
|
||||
protected EppCommandOperations commandOperations;
|
||||
protected boolean hasSignedMarks;
|
||||
protected SignedMark signedMark;
|
||||
protected boolean isAnchorTenantViaReservation;
|
||||
|
@ -181,7 +180,8 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
tldState = registry.getTldState(now);
|
||||
checkRegistryStateForTld(tld);
|
||||
domainLabel = domainName.parts().get(0);
|
||||
createCost = getDomainCreateCost(targetId, now, command.getPeriod().getValue());
|
||||
commandOperations = TldSpecificLogicEngine.getCreatePrice(
|
||||
registry, domainName.toString(), now, command.getPeriod().getValue());
|
||||
// The TLD should always be the parent of the requested domain name.
|
||||
isAnchorTenantViaReservation = matchesAnchorTenantReservation(
|
||||
domainLabel, tld, command.getAuthInfo().getPw().getValue());
|
||||
|
|
|
@ -33,7 +33,6 @@ import google.registry.model.domain.DomainApplication;
|
|||
import google.registry.model.domain.DomainApplication.Builder;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.domain.fee.FeeCreateExtension;
|
||||
import google.registry.model.domain.fee.FeeCreateResponseExtension;
|
||||
import google.registry.model.domain.launch.ApplicationStatus;
|
||||
|
@ -143,7 +142,8 @@ public class DomainApplicationCreateFlow extends BaseDomainCreateFlow<DomainAppl
|
|||
|
||||
@Override
|
||||
protected void verifyDomainCreateIsAllowed() throws EppException {
|
||||
validateFeeChallenge(targetId, getTld(), now, feeCreate, createCost);
|
||||
validateFeeChallenge(
|
||||
targetId, getTld(), now, feeCreate, commandOperations.getTotalCost());
|
||||
if (tldState == TldState.LANDRUSH && !isSuperuser) {
|
||||
// Prohibit creating a landrush application in LANDRUSH (but not in SUNRUSH) if there is
|
||||
// exactly one sunrise application for the same name.
|
||||
|
@ -214,8 +214,8 @@ public class DomainApplicationCreateFlow extends BaseDomainCreateFlow<DomainAppl
|
|||
.build());
|
||||
if (feeCreate != null) {
|
||||
responseExtensionsBuilder.add(new FeeCreateResponseExtension.Builder()
|
||||
.setCurrency(createCost.getCurrencyUnit())
|
||||
.setFee(ImmutableList.of(Fee.create(createCost.getAmount(), "create")))
|
||||
.setCurrency(commandOperations.getCurrency())
|
||||
.setFee(commandOperations.getFees())
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.validateFeeChallenge;
|
||||
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
@ -112,7 +111,7 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
|
|||
@Override
|
||||
protected final void verifyDomainCreateIsAllowed() throws EppException {
|
||||
String tld = getTld();
|
||||
validateFeeChallenge(targetId, tld, now, feeCreate, createCost);
|
||||
validateFeeChallenge(targetId, tld, now, feeCreate, commandOperations.getTotalCost());
|
||||
if (!isSuperuser) {
|
||||
// Prohibit creating a domain if there is an open application for the same name.
|
||||
for (DomainApplication application : loadActiveApplicationsByDomainName(targetId, now)) {
|
||||
|
@ -151,13 +150,15 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
|
|||
@Override
|
||||
protected final void setDomainCreateOrAllocateProperties(Builder builder) throws EppException {
|
||||
Registry registry = Registry.get(getTld());
|
||||
|
||||
// Bill for the create.
|
||||
BillingEvent.OneTime createEvent = new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(targetId)
|
||||
.setClientId(getClientId())
|
||||
.setPeriodYears(command.getPeriod().getValue())
|
||||
.setCost(checkNotNull(createCost))
|
||||
// TODO(b/29089413): the EAP fee needs to be a separate billing event.
|
||||
.setCost(commandOperations.getTotalCost())
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plus(isAnchorTenant()
|
||||
? registry.getAnchorTenantAddGracePeriodLength()
|
||||
|
|
|
@ -31,7 +31,6 @@ import google.registry.model.billing.BillingEvent.Reason;
|
|||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.DomainResource.Builder;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.domain.fee.FeeCreateResponseExtension;
|
||||
import google.registry.model.eppoutput.CreateData.DomainCreateData;
|
||||
import google.registry.model.eppoutput.EppOutput;
|
||||
|
@ -113,8 +112,8 @@ public abstract class DomainCreateOrAllocateFlow
|
|||
newResource.getRegistrationExpirationTime()),
|
||||
(feeCreate == null) ? null : ImmutableList.of(
|
||||
new FeeCreateResponseExtension.Builder()
|
||||
.setCurrency(createCost.getCurrencyUnit())
|
||||
.setFee(ImmutableList.of(Fee.create(createCost.getAmount(), "create")))
|
||||
.setCurrency(commandOperations.getCurrency())
|
||||
.setFee(commandOperations.getFees())
|
||||
.build()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue