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

Prevent Guardian Ad-Lite purchase by users who have either of adFree or allowRejectAll benefits already #6675

Merged
merged 13 commits into from
Jan 23, 2025

Conversation

tjmw
Copy link
Member

@tjmw tjmw commented Jan 6, 2025

What are you doing in this PR?

If a non signed-in user already has the adFree or allowRejectAll benefit, they shouldn't be able to purchase Guardian Ad-Lite. We're assuming that a signed-in user with adFree or allowRejectAll wouldn't make it to the checkout as there's no user journey for this.

Trello Card

Why are you doing this?

It doesn't make sense to buy Guardian Ad-Lite if you get ad free reading or can already reject tracking.

How to test

I've tested locally and in CODE. When a signed out user already has the ad-free or reject-tracking benefit, an error is shown:

Screenshot 2025-01-10 at 11 55 40

A user without these benefits is able to purchase successfully.

How can we measure success?

Have we considered potential risks?

Accessibility test checklist

Screenshots

Copy link
Contributor

github-actions bot commented Jan 6, 2025

Size Change: +402 B (+0.02%)

Total Size: 2.37 MB

ℹ️ View Unchanged
Filename Size Change
./public/compiled-assets/javascripts/[countryGroupId]/events/router.js 90.5 kB 0 B
./public/compiled-assets/javascripts/[countryGroupId]/lazyRouter.js 93.2 kB 0 B
./public/compiled-assets/javascripts/[countryGroupId]/router.js 254 kB +87 B (+0.03%)
./public/compiled-assets/javascripts/ausMomentMap.js 108 kB 0 B
./public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./public/compiled-assets/javascripts/digitalSubscriptionLandingPage.js 223 kB +56 B (+0.03%)
./public/compiled-assets/javascripts/downForMaintenancePage.js 67.7 kB 0 B
./public/compiled-assets/javascripts/error404Page.js 67.6 kB 0 B
./public/compiled-assets/javascripts/error500Page.js 67.5 kB 0 B
./public/compiled-assets/javascripts/favicons.js 617 B 0 B
./public/compiled-assets/javascripts/paperSubscriptionCheckoutPage.js 164 kB +67 B (+0.04%)
./public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 87.9 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPage.js 66.1 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./public/compiled-assets/javascripts/promotionTerms.js 73.8 kB 0 B
./public/compiled-assets/javascripts/subscriptionsLandingPage.js 73.2 kB 0 B
./public/compiled-assets/javascripts/subscriptionsRedemptionPage.js 118 kB +65 B (+0.05%)
./public/compiled-assets/javascripts/supporterPlusLandingPage.js 226 kB 0 B
./public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 160 kB +65 B (+0.04%)
./public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 88 kB 0 B
./public/compiled-assets/webpack/136.js 2.17 kB 0 B
./public/compiled-assets/webpack/186.js 3.35 kB 0 B
./public/compiled-assets/webpack/187.js 21.7 kB 0 B
./public/compiled-assets/webpack/3.js 19.2 kB 0 B
./public/compiled-assets/webpack/311.js 40.1 kB 0 B
./public/compiled-assets/webpack/344.js 2.01 kB 0 B
./public/compiled-assets/webpack/397.js 10.2 kB 0 B
./public/compiled-assets/webpack/426.js 36.6 kB +62 B (+0.17%)
./public/compiled-assets/webpack/643.js 22.4 kB 0 B
./public/compiled-assets/webpack/706.js 107 kB 0 B
./public/compiled-assets/webpack/754.js 9.96 kB 0 B
./public/compiled-assets/webpack/847.js 26 kB 0 B
./public/compiled-assets/webpack/checkout.js 14.3 kB 0 B
./public/compiled-assets/webpack/GuardianAdLiteLanding.js 9.05 kB 0 B
./public/compiled-assets/webpack/oneTimeCheckout.js 9.96 kB 0 B
./public/compiled-assets/webpack/ThankYou.js 1.08 kB 0 B

compressed-size-action

for {
benefits <- userBenefitsApiService
.getUserBenefits(userDetails.userDetails.identityId)
.leftMap(_ => ServerError("Something went wrong calling the user benefits API"))
Copy link
Member Author

Choose a reason for hiding this comment

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

If there's an issue with calling the user benefits API the purchase will be blocked and we'll show a generic error message to the user.

userDetails: UserDetails,
isSignedIn: Boolean,
)

private def createSubscription(implicit
settings: AllSettings,
request: CreateRequest,
): EitherT[Future, CreateSubscriptionError, CreateSubscriptionResponse] = {

val maybeLoggedInUserDetails =
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this now be "maybeUserDetails" since the signed in status can vary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had this same thought and decided to leave it as is because in the case of this val it's still either:

  1. None or
  2. The details of a user who is signed in.

I.e. maybeLoggedInUserDetails won't ever contain information about a user who isn't signed in. Though like you say it's true that the Option type UserDetailsWithSignedInStatus can represent this state. What do you reckon?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, right. That's quite subtle but seems fine to leave as is

@tjmw tjmw marked this pull request as ready for review January 10, 2025 11:48
@rupertbates
Copy link
Member

Does this work for test users? We're going to need to query the code version of user-benefits api I think.

@tjmw tjmw changed the title Prevent Guardian Ad-Lite purchase by users who have the adFree benefit already Prevent Guardian Ad-Lite purchase by users who have either of adFree or rejectTracking benefits already Jan 17, 2025
@tjmw tjmw force-pushed the tw/prevent-guardian-light-purchase branch from 2bd1b98 to 1f5716c Compare January 17, 2025 15:28
@tjmw tjmw force-pushed the tw/prevent-guardian-light-purchase branch from 1f5716c to 0be1361 Compare January 20, 2025 16:29
@tjmw
Copy link
Member Author

tjmw commented Jan 21, 2025

TODO: update the benefit checked after guardian/support-service-lambdas#2645 is merged. Done ✔️

This was left over after the migration to touchpoint envs so we could
support test users.
Copy link
Member

@rupertbates rupertbates left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@tjmw tjmw changed the title Prevent Guardian Ad-Lite purchase by users who have either of adFree or rejectTracking benefits already Prevent Guardian Ad-Lite purchase by users who have either of adFree or allowRejectAll benefits already Jan 23, 2025
@tjmw tjmw merged commit 4070775 into main Jan 23, 2025
19 checks passed
@tjmw tjmw deleted the tw/prevent-guardian-light-purchase branch January 23, 2025 09:37
@prout-bot
Copy link

Seen on PROD (merged by @tjmw 10 minutes and 58 seconds ago)

Sentry Release: support-client-side, support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants