1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 14:25:44 +00:00

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
This commit is contained in:
gbrodman
2025-01-28 13:31:29 -05:00
committed by GitHub
parent 120bcc33be
commit 2ceb52a7c4
2 changed files with 22 additions and 0 deletions

View File

@@ -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(),

View File

@@ -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));
}
}