-
Notifications
You must be signed in to change notification settings - Fork 212
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
feat(payments): Add Upgrade - Purchase Details + Layout #18173
base: main
Are you sure you want to change the base?
Conversation
bd90b6e
to
f24741a
Compare
66d42cc
to
f487fae
Compare
c141087
to
b50376a
Compare
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.
Overall this looks good. Just some minor comments.
@@ -423,12 +432,42 @@ export class CartService { | |||
customer = await this.customerManager.retrieve(cart.stripeCustomerId); | |||
} | |||
|
|||
const eligibility = await this.eligibilityService.checkEligibility( |
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.
Why is it necessary to checkEligibility
again? Eligibility had already been calculated as part of setupCart
and the eligibilityStatus was stored in the Cart DB table.
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.
I'm guessing it's because eligibleSourcePrice
is needed and that's currently only being returned by checkEligibility
?
If it's known that the eligibilityStatus is UPGRADE
, is there no easier/faster way to get the price the customer is upgrading from?
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.
Maybe we leave this as is for now, and see if we can iterate on this at a later time. Happy to hear your or anyone else's thoughts on this.
const invoices = [upcomingInvoice]; | ||
|
||
let proratedInvoice; | ||
if (isUpgrade) { |
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.
Thus far with SP3 we've been steering clear of conditionals in methods, instead favoring explicit methods per task. (See CheckoutService.payWithStripe
and CheckoutService.payWithPaypal
vs CheckoutService.pay(isStripe: boolean)
). I think having a separate method fetching invoicePreview for upgrades makes sense here.
): InvoicePreview { | ||
const taxAmounts = invoice.total_tax_amounts.map((amount) => ({ | ||
const taxAmounts = invoice[0].total_tax_amounts.map((amount) => ({ |
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 is a minor note, and can be picked up as a polish PR, but it'd be great to be more explicit about which invoice is the current and which is prorated, instead of just assuming it's index 0 and index 1 respectively.
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.
I reverted this update as we only need the total of the prorated invoice (I did not see the prorated amount being used anywhere other than in the legacy tests and stories).
<Localized | ||
id="list-positive-amount" | ||
vars={{ | ||
amount: getLocalizedCurrency(listAmount, currency), | ||
}} | ||
> | ||
<p>{getLocalizedCurrencyString(listAmount, currency)}</p> | ||
</Localized> |
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.
Thank you for making all these changes as discussed last week.
Just as an FYI, separately @bcolsson had reached out to me last week questioning the need for localization of list-positive-amount
and list-negative-amount
. I had a quick look, and doesn't seem like fxa-payments-server
currently has localization on these fields, so we should be able to simplify this a bit. But happy to do that as a polish PR once this lands.
@@ -472,6 +511,11 @@ export class CartService { | |||
metricsOptedOut, | |||
latestInvoicePreview, | |||
paymentInfo, | |||
eligibilityStatus: cartEligibilityStatus, | |||
eligibleSourcePrice: currentPrice, |
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.
nit. Could this be renamed to something more appropriate? AFAIK this price isn't used in anything related to eligibility, but instead is needed for the upgrade pages? If so, maybe something like upgradeFromPrice
makes more sense?
4fe8427
to
80e5b3e
Compare
8cb99af
to
6023739
Compare
9ff5203
to
56dc183
Compare
This pull request
eligibilityMananger.compareOverlap
to also return the offering id when status is upgradeeligibilityService.checkEligibility
to also return offering id and StripePrice of the plan being upgraded frominvoiceManager.previewUpcomingForUpgrade
cartService.getCart
and addsoneTimeCharge
as part of invoicePreviewIssue that this pull request solves
Closes: FXA-7588
Checklist
Put an
x
in the boxes that applyScreenshots (Optional)