-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix: set email when creating new session for trial days #2710
Conversation
440b911
to
8ea83b9
Compare
if err := svc.validateOrderMerchantAndCaveats(ctx, orderID); err != nil { | ||
return handlers.ValidationError("merchant and caveats", map[string]interface{}{"orderMerchantAndCaveats": err.Error()}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not do anything useful for Premium orders. The endpoint is already authenticated. The merchant is always the same, it's brave.com
, and we set it ourselves. And it seems like caveats for Premium are not populated at all, so the check is useless at least, and it also wastes two queries to the database to fetch the order.
8ea83b9
to
177d15c
Compare
[puLL-Merge] - brave-intl/bat-go@2710 DescriptionThis PR refactors the handling of trial days for orders in the BAT-Go project. It introduces changes to improve the process of setting trial days and creating Stripe sessions for orders, particularly focusing on the ChangesChanges
Possible Issues
Security Hotspots
|
Wrong. The body is being read with a limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM approved.
Summary
This PR improves handling of the customer email on a Stripe checkout session when setting trial days on an order and session.
#2698 improved handling, but that was not enough. When we're setting trial days on a session, the caller already has the correct email. SKUs attempts to work out the email based on the old session. Because the two calls (the creation of the initial session and setting trial days) happen very close to each other, the customer record might not be ready yet or miss information.
This PR makes use of the passed email address, and falls back to the old behaviour (i.e. takes the email from on old session) only if it was not passed.
This should address the majority of cases where the checkout page for products with trial might be shown without a pre-filled email address.
Type of Change
Tested Environments
Before Requesting Review
Manual Test Plan