Modify create price custom logic to return FeesAndCredits

Previously DomainPricingCustomLogic#customizeCreatePrice takes in the create
price itself and modifies it. Change it to take in the entire FeesAndCredits (previously named EppCommandOperations) which may contain other fees related to domain creation,
such as EAP fees, and returns FeesAndCredits that may either change the
fees or add new type of fees.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=141600614
This commit is contained in:
jianglai 2016-12-09 14:30:03 -08:00 committed by Ben McIlwain
parent a56a0677ba
commit 74d64f502e
7 changed files with 90 additions and 91 deletions

View file

@ -64,7 +64,7 @@ import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic.After
import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic.BeforeResponseParameters;
import google.registry.flows.custom.DomainApplicationCreateFlowCustomLogic.BeforeResponseReturnData;
import google.registry.flows.custom.EntityChanges;
import google.registry.flows.domain.DomainPricingLogic.EppCommandOperations;
import google.registry.flows.domain.DomainPricingLogic.FeesAndCredits;
import google.registry.model.ImmutableObject;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.DomainCommand.Create;
@ -201,7 +201,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
String tld = domainName.parent().toString();
checkAllowedAccessToTld(clientId, tld);
Registry registry = Registry.get(tld);
EppCommandOperations commandOperations =
FeesAndCredits feesAndCredits =
pricingLogic.getCreatePrice(registry, targetId, now, command.getPeriod().getValue());
// Superusers can create reserved domains, force creations on domains that require a claims
// notice without specifying a claims key, and override blocks on registering premium domains.
@ -224,7 +224,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
}
FeeCreateCommandExtension feeCreate =
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
validateFeeChallenge(targetId, tld, now, feeCreate, commandOperations.getTotalCost());
validateFeeChallenge(targetId, tld, now, feeCreate, feesAndCredits.getTotalCost());
SecDnsCreateExtension secDnsCreate =
validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class));
customLogic.afterValidation(
@ -292,7 +292,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
newApplication.getForeignKey(),
launchCreate.getPhase(),
feeCreate,
commandOperations))
feesAndCredits))
.build());
return responseBuilder
.setResData(responseData.resData())
@ -366,11 +366,11 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
.build();
}
private ImmutableList<ResponseExtension> createResponseExtensions(
private static ImmutableList<ResponseExtension> createResponseExtensions(
String applicationId,
LaunchPhase launchPhase,
FeeTransformCommandExtension feeCreate,
EppCommandOperations commandOperations) {
FeesAndCredits feesAndCredits) {
ImmutableList.Builder<ResponseExtension> responseExtensionsBuilder =
new ImmutableList.Builder<>();
responseExtensionsBuilder.add(new LaunchCreateResponseExtension.Builder()
@ -378,7 +378,7 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
.setApplicationId(applicationId)
.build());
if (feeCreate != null) {
responseExtensionsBuilder.add(createFeeCreateResponse(feeCreate, commandOperations));
responseExtensionsBuilder.add(createFeeCreateResponse(feeCreate, feesAndCredits));
}
return responseExtensionsBuilder.build();
}