Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change billing for multi-year domain creation #2446

Merged
merged 2 commits into from
May 29, 2024

Conversation

weiminyu
Copy link
Collaborator

@weiminyu weiminyu commented May 16, 2024

From the second year on, charge the renewal price.

See b/322833077


This change is Reviewable

From the second year on, charge the renewal price.

See b/322833077
Copy link
Member

@CydeWeys CydeWeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @weiminyu)


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 290 at r1 (raw file):

  }

  private Money getDomainCostWithDiscount(

It might be worth adding a Javadoc here clarifying that for renewals, firstYearCost is the per-year renewal cost and subsequentYearCost is empty, and then how they work for creates, with subsequentYearCost always being present even if in most cases it will be the same as firstYearCost.


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 297 at r1 (raw file):

      Optional<Money> subsequentYearCost)
      throws AllocationTokenInvalidForPremiumNameException {
    checkArgument(years > 0, "Domain creation/renew for zero years.");

A better error message here would be something like "Registration years to get cost for must be positive"

The error message as written is saying the error state, rather than the valid state that wasn't met, also it's not technically accurate (if you passed in -1 it would still say "zero years" which is just confusing).


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 306 at r1 (raw file):

    if (allocationToken.isPresent()
        && allocationToken.get().getTokenBehavior().equals(TokenBehavior.DEFAULT)
        && (discountedYears = Math.min(years, allocationToken.get().getDiscountYears())) > 0) {

We shouldn't be inlining a variable assignment inside a conditional clause; it's confusing to understand at first pass. Nested ifs (if that's logically the best) would be more understandable.

Copy link
Collaborator Author

@weiminyu weiminyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @CydeWeys)


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 290 at r1 (raw file):

Previously, CydeWeys (Ben McIlwain) wrote…

It might be worth adding a Javadoc here clarifying that for renewals, firstYearCost is the per-year renewal cost and subsequentYearCost is empty, and then how they work for creates, with subsequentYearCost always being present even if in most cases it will be the same as firstYearCost.

Done.


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 297 at r1 (raw file):

Previously, CydeWeys (Ben McIlwain) wrote…

A better error message here would be something like "Registration years to get cost for must be positive"

The error message as written is saying the error state, rather than the valid state that wasn't met, also it's not technically accurate (if you passed in -1 it would still say "zero years" which is just confusing).

Done.


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 306 at r1 (raw file):

Previously, CydeWeys (Ben McIlwain) wrote…

We shouldn't be inlining a variable assignment inside a conditional clause; it's confusing to understand at first pass. Nested ifs (if that's logically the best) would be more understandable.

Done.

Copy link
Member

@CydeWeys CydeWeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion (waiting on @weiminyu)


core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java line 320 at r2 (raw file):

                .plus(subsequentYearCost.orElse(firstYearCost).multipliedBy(discountedYears - 1))
                .multipliedBy(allocationToken.get().getDiscountFraction(), RoundingMode.HALF_EVEN);
        totalDomainFlowCost = totalDomainFlowCost.minus(discount);

Rather than reassigning a value to totalDomainFlowCost, this could just be return totalDomainFlowCost.minus(discount);

Copy link
Member

@CydeWeys CydeWeys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion (waiting on @weiminyu)

@weiminyu weiminyu added this pull request to the merge queue May 28, 2024
@weiminyu weiminyu removed this pull request from the merge queue due to a manual request May 28, 2024
@weiminyu weiminyu added this pull request to the merge queue May 28, 2024
@jianglai jianglai removed this pull request from the merge queue due to the queue being cleared May 29, 2024
@weiminyu weiminyu merged commit b3e67e5 into google:master May 29, 2024
8 of 9 checks passed
@weiminyu weiminyu deleted the multi-year-creation-2 branch May 29, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants