Skip to content

Commit 2ceb52a

Browse files
authored
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
1 parent 120bcc3 commit 2ceb52a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ private Money getDomainRenewCostWithDiscount(
287287
|| token.getRenewalPriceBehavior().equals(RenewalPriceBehavior.NONPREMIUM)) {
288288
return tld.getStandardRenewCost(dateTime).multipliedBy(years);
289289
}
290+
if (token.getRenewalPriceBehavior().equals(RenewalPriceBehavior.SPECIFIED)) {
291+
return token.getRenewalPrice().get();
292+
}
290293
}
291294
return getDomainCostWithDiscount(
292295
domainPrices.isPremium(),

core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,4 +1242,23 @@ void testGetDomainCreatePrice_premium_multiYear_onlyNonpremiumRenewal() throws E
12421242
.addFeeOrCredit(Fee.create(new BigDecimal("120.00"), CREATE, true))
12431243
.build());
12441244
}
1245+
1246+
@Test
1247+
void testDomainRenewPrice_specifiedToken() throws Exception {
1248+
AllocationToken allocationToken =
1249+
persistResource(
1250+
new AllocationToken.Builder()
1251+
.setToken("abc123")
1252+
.setTokenType(SINGLE_USE)
1253+
.setDomainName("premium.example")
1254+
.setRenewalPriceBehavior(SPECIFIED)
1255+
.setRenewalPrice(Money.of(USD, 5))
1256+
.build());
1257+
assertThat(
1258+
domainPricingLogic
1259+
.getRenewPrice(
1260+
tld, "premium.example", clock.nowUtc(), 1, null, Optional.of(allocationToken))
1261+
.getRenewCost())
1262+
.isEqualTo(Money.of(USD, 5));
1263+
}
12451264
}

0 commit comments

Comments
 (0)