From 2ceb52a7c4f5efdff1e43a0f98f09c6dbc772ccc Mon Sep 17 00:00:00 2001 From: gbrodman Date: Tue, 28 Jan 2025 13:31:29 -0500 Subject: [PATCH] Handle SPECIFIED renewal price w/token in check flow (#2651) This is kinda nonsensical because this use case is trying to apply a single use token multiple times in the same domain:check request -- like, trying to use a single-use token for both create, renew, and transfer while having a $0 create price and a premium renewal price. This change doesn't affect any actual business / costs, since SPECIFIED token renewal prices were already set on the BillingRecurrence --- .../flows/domain/DomainPricingLogic.java | 3 +++ .../flows/domain/DomainPricingLogicTest.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java b/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java index 55d4fb8ba..4f22cc621 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java +++ b/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java @@ -287,6 +287,9 @@ public final class DomainPricingLogic { || token.getRenewalPriceBehavior().equals(RenewalPriceBehavior.NONPREMIUM)) { return tld.getStandardRenewCost(dateTime).multipliedBy(years); } + if (token.getRenewalPriceBehavior().equals(RenewalPriceBehavior.SPECIFIED)) { + return token.getRenewalPrice().get(); + } } return getDomainCostWithDiscount( domainPrices.isPremium(), diff --git a/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java b/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java index c676539e8..c0c6dd741 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java @@ -1242,4 +1242,23 @@ public class DomainPricingLogicTest { .addFeeOrCredit(Fee.create(new BigDecimal("120.00"), CREATE, true)) .build()); } + + @Test + void testDomainRenewPrice_specifiedToken() throws Exception { + AllocationToken allocationToken = + persistResource( + new AllocationToken.Builder() + .setToken("abc123") + .setTokenType(SINGLE_USE) + .setDomainName("premium.example") + .setRenewalPriceBehavior(SPECIFIED) + .setRenewalPrice(Money.of(USD, 5)) + .build()); + assertThat( + domainPricingLogic + .getRenewPrice( + tld, "premium.example", clock.nowUtc(), 1, null, Optional.of(allocationToken)) + .getRenewCost()) + .isEqualTo(Money.of(USD, 5)); + } }