-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Purchases: Individual purchases not loading on sites with Site Redirect #536
Conversation
👍 This fixes my issue from #122 |
This seems to solve the issues with Site Redirect, but is failing some tests. Moving back to Awaiting Author Response. |
1f21c28
to
7df2ac6
Compare
Yes, due to some twisted dependencies. I've added |
e6227b5
to
c0a113c
Compare
@@ -27,6 +30,7 @@ function getPurchasesBySite( purchases ) { | |||
domain: currentValue.domain, | |||
id: currentValue.siteId, | |||
name: currentValue.siteName, | |||
slug: sites.getSite( currentValue.siteId ).slug, |
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.
Is there a guarantee that sites
has been fetched at this point?
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.
It's only called in a single place under client/me/purchases/list/index.jsx
, and I think that page is only loaded after we have the sites. But apart from that, there is no guarantee. I have come to think that it might be a better idea to move the function to somewhere else, because a dependency to sites-list
breaks many tests since sites-list
depends on DOM and we need to add react-test-env-setup
to many tests to get them running.
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.
What do you think about removing this call to SitesList
and updating this function to accept an array of sites as a parameter, like getPurchasesBySite( purchases, sites )
? It would keep the function pure, make this easier to test, and would be clearer that information from SitesList
is necessary in modules that use getPurchasesBySite
.
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.
That's a great idea, I've changed the code to implement it as such.
@umurkontaci A potentially unresolved blocker for using the primary domain in the purchases/checkout URLs is that Jetpack sites are represented with two site objects, each with separate
Purchases are sometimes (possibly always, I'm unsure) associated with the .com site, but if we redirect users from @dzver or @matthusby: Do either of you know whether subscriptions for Jetpack sites are always associated with the .com site, in this case? |
I'm having trouble confirming that a Jetpack site has two blog_ids. My Jetpack site seems to only have one. Do you mind giving me an example? |
@dzver Apparently, the example I was using was the following, non-standard case of a user with:
@umurkontaci's approach of setting the |
c0a113c
to
0cdd3b6
Compare
This has been updated with @drewblaisdell suggestion about sending the |
I tested this with .com sites and it works well. I think we should test it with a Jetpack site before we merge. The code looks good |
@scruffian I've tested with an account on a single Jetpack site and confirm that it's using the correct URL. |
@jeherve @v18, my concern is that this will reintroduce a problem with domain mapping for Jetpack site that we saw last week: The problem occours when a user has a Jetpack-connected self-hosted site and a domain registered at WordPress.com, mapped to the self-hosted site. In this case the user couldn’t renew the domain through the Jetpack-connected site using Calypso – this makes some sense as the domain is registered in connection with her .com site, but it is definitely confusing. In this case users were able to see the domain and attempt to renew it, but they got an error about requiring domain registration details. (p2MSmN-4aE-p2) I have tried setting up my Jetpack site to test this, but I couldn't connect it. Could one of you test it? |
I tested the branch with a domain of mine, registered on WordPress.com, and currently pointed to a Jetpack site connected to the same WordPress.com account. I was able to go through the renewal.
I might not be the perfect test subject for this, but I must say that it was less confusing than I expected. The domain name is displayed in a much bigger font size than the site title on I did, however ran into another site during the renewal. The following js error appeared when clicking the "Purchase subscription" button: I didn't click on anything else before on that page, my stored credit card was automatically selected for me. When entering a new credit card, payment went through. I couldn't reproduce when trying the same steps on WordPress.com, and could reproduce again with another subscription when in that branch. |
I was getting an error if a site was deleted and still had purchases - since it won't be in |
I tried mocking @jeherve's credit card data to see if I could reproduce it, and I was unable to, so the problem must lie elsewhere. I'm not sure the best way to proceed now... |
|
||
// If a site has been deleted then there will be no site with this ID in site. | ||
if ( site ) { | ||
slug = site.domain; |
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.
@scruffian I believe this should be site.slug
.
74b46d2
to
ceeb93b
Compare
@scruffian I updated your commit to use I'm fairly confident that the credit card issues above are unrelated to this change and that this is safe to merge. I'm going to try and pair with @jeherve soon to make sure we figure out what is causing that error. |
|
||
if ( ! this.props.purchases.isFetching && ! this.props.purchases.hasLoadedFromServer ) { | ||
return null; | ||
if ( ! this.props.sites.fetched ) { |
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.
What about checking against sites.initialized
? It looks like it works the same way as sites.fetched
, but also works for data cached in local storage.
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.
Nice catch - fixed.
895d34b
to
cd7a33b
Compare
After another test, I can't reproduce these js errors anymore. Renewal went well, no issues at all. Not sure what happened before, and what fixed it... |
@scruffian and @gziolo checked the code and QA box for this, and I reviewed @scruffian's last commit (making only minor style changes), so this is ready to merge. |
👍 |
…ct (Fixes #122) This fixes the issue of individual purchases not loading on site with Site Redirect record set as primary domain. It changes the use of `domain` property from purchases data to getting the site slug from `SitesList`. This will the URLs will behave the same as in store.
This removes the `SitesList` dependency from this function, and makes the behavior a bit more explicit.
…sites list - it might be deleted
cd7a33b
to
f76af43
Compare
…edirect Purchases: Individual purchases not loading on sites with Site Redirect
\o/ |
This fixes the issue of individual purchases not loading on site with Site Redirect record set as primary domain. (Fixes #122)
It changes the use of
domain
property from purchases data to getting the site slug fromSitesList
. This will the URLs will behave the same as in store.Testing
/purchases
./purchases
.