diff --git a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java index dfaeee896..29526c206 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java @@ -280,8 +280,12 @@ public final class DomainCreateFlow implements TransactionalFlow { registrarId, now, eppInput.getSingleExtension(AllocationTokenExtension.class)); + boolean defaultTokenUsed = false; if (!allocationToken.isPresent() && !registry.getDefaultPromoTokens().isEmpty()) { allocationToken = checkForDefaultToken(registry, command); + if (allocationToken.isPresent()) { + defaultTokenUsed = true; + } } boolean isAnchorTenant = isAnchorTenant( @@ -340,7 +344,7 @@ public final class DomainCreateFlow implements TransactionalFlow { FeesAndCredits feesAndCredits = pricingLogic.getCreatePrice( registry, targetId, now, years, isAnchorTenant, allocationToken); - validateFeeChallenge(feeCreate, feesAndCredits); + validateFeeChallenge(feeCreate, feesAndCredits, defaultTokenUsed); Optional secDnsCreate = validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class)); DateTime registrationExpirationTime = leapSafeAddYears(now, years); diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index 599bf8b59..d4b692e36 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -778,12 +778,13 @@ public class DomainFlowUtils { */ public static void validateFeeChallenge( final Optional feeCommand, - FeesAndCredits feesAndCredits) + FeesAndCredits feesAndCredits, + boolean defaultTokenUsed) throws EppException { if (feesAndCredits.hasAnyPremiumFees() && !feeCommand.isPresent()) { throw new FeesRequiredForPremiumNameException(); } - validateFeesAckedIfPresent(feeCommand, feesAndCredits); + validateFeesAckedIfPresent(feeCommand, feesAndCredits, defaultTokenUsed); } /** @@ -795,7 +796,8 @@ public class DomainFlowUtils { */ public static void validateFeesAckedIfPresent( final Optional feeCommand, - FeesAndCredits feesAndCredits) + FeesAndCredits feesAndCredits, + boolean defaultTokenUsed) throws EppException { // Check for the case where a fee command extension was required but not provided. // This only happens when the total fees are non-zero and include custom fees requiring the @@ -856,7 +858,9 @@ public class DomainFlowUtils { // Checking if total amount is expected. Extra fees that we are not expecting may be passed in. // Or if there is only a single fee type expected. if (!feeTotal.equals(feesAndCredits.getTotalCost())) { - throw new FeesMismatchException(feesAndCredits.getTotalCost()); + if (!defaultTokenUsed || feeTotal.isLessThan(feesAndCredits.getTotalCost())) { + throw new FeesMismatchException(feesAndCredits.getTotalCost()); + } } } diff --git a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java index 916cec59f..ad7ef8311 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java @@ -199,7 +199,7 @@ public final class DomainRenewFlow implements TransactionalFlow { now, years, existingRecurringBillingEvent); - validateFeeChallenge(feeRenew, feesAndCredits); + validateFeeChallenge(feeRenew, feesAndCredits, false); flowCustomLogic.afterValidation( AfterValidationParameters.newBuilder() .setExistingDomain(existingDomain) diff --git a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index 75d99eeb6..dcffe4d24 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -226,7 +226,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { if (!existingDomain.getGracePeriodStatuses().contains(GracePeriodStatus.REDEMPTION)) { throw new DomainNotEligibleForRestoreException(); } - validateFeeChallenge(feeUpdate, feesAndCredits); + validateFeeChallenge(feeUpdate, feesAndCredits, false); } private static Domain performRestore( diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 507dfc0ef..d6aa33066 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -210,7 +210,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { } if (feesAndCredits.isPresent()) { - validateFeeChallenge(feeTransfer, feesAndCredits.get()); + validateFeeChallenge(feeTransfer, feesAndCredits.get(), false); } HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain); historyBuilder diff --git a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java index 0d3b887bc..caeaa76d1 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -231,7 +231,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { Optional feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(registry, targetId, now); - validateFeesAckedIfPresent(feeUpdate, feesAndCredits); + validateFeesAckedIfPresent(feeUpdate, feesAndCredits, false); verifyNotInPendingDelete( add.getContacts(), command.getInnerChange().getRegistrant(), diff --git a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java index 35de5af75..e8f0cdfe8 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java @@ -703,7 +703,9 @@ class DomainCreateFlowTest extends ResourceFlowTestCase USD - 26.00 + %FEE%