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

Purchases: Fix purchase not updated upon privacy protection cancelation #555

Merged
merged 11 commits into from
Nov 30, 2015

Conversation

stephanethomas
Copy link
Contributor

This pull request fixes #189 by retrieving the domain registration purchase returned by the API when users cancel the associated private registration. The goal is to display the Manage Purchase page with up-to-date information as soon as the cancelation is successful:

screenshot-wpcalypso wordpress com 2015-11-19 16-47-38

This pull request also fixes a small bug and refactor some code, mostly for consistency purposes.

Testing instructions

Scenario _#_1
  1. Get a new test account and blog
  2. Enable the store sandbox
  3. Navigate to the Domains page
  4. Click on any Add button to add a domain to the shopping cart
  5. Click on the No thanks, I don't need email or will use another provider. link on the next page
  6. Fill in the Domain Registration Details page and click on the Add Privacy Protection button
  7. Submit the form on the Secure Payment page with fake credit card information
  8. Head to the Purchases page
  9. Click the new domain registration to display the corresponding Manage Purchase page
  10. Note the current price and click the Cancel Private Registration navigation link
  11. Click the Cancel Private Registration on the page of the same name
  12. Check that you are redirected on the Manage Purchase page with a success message
  13. Check that the price is updated instantaneously and matches the cost of a domain registration without privacy protection

@stephanethomas stephanethomas added [Type] Bug [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Purchase Management Related to managing purchases such as subscriptions, plans, history, auto-renew, cancellation, etc. labels Nov 23, 2015
@stephanethomas stephanethomas self-assigned this Nov 23, 2015
@stephanethomas stephanethomas added this to the Purchases: v1 milestone Nov 23, 2015
@stephanethomas
Copy link
Contributor Author

This is still in progress because of a discrepancy between purchases returned by the /me/purchases API endpoint and the one returned by the /upgrades/:purchaseId/cancel-privacy-protection endpoint: for some reasons - probably legacy ones - the content of the purchase differs. Otherwise this is good for feedback.

assert( find( PurchasesStore.get().data, { id: 2 } ) );
assert( find( PurchasesStore.get().data, { id: 3 } ) );
expect( PurchasesStore.get() ).to.be.eql( {
data: [ { id: 2 }, { id: 3 }, { id: 1 } ],
Copy link
Member

Choose a reason for hiding this comment

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

does order matter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, surprisingly it does :(.

Copy link
Member

Choose a reason for hiding this comment

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

I see now in code why it works this way. It's okey, because it's predictable.

@gziolo
Copy link
Member

gziolo commented Nov 24, 2015

Code looks good 👍
BTW, this is great approach with returning purchase updated purchase data from REST endpoint, we should implement similar approach in other actions.

@gziolo
Copy link
Member

gziolo commented Nov 24, 2015

This is what has displayed to me after canceling privacy protection:
screen shot 2015-11-24 at 11 53 10

Errors in JS console:
screen shot 2015-11-24 at 11 54 12

Do I need any backend patch to make it work properly?

@gziolo gziolo added [Status] Awaiting Fixes [Status] Needs Author Reply and removed [Status] In Progress [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Awaiting Fixes labels Nov 24, 2015
@stephanethomas
Copy link
Contributor Author

Yes, that's what I mentioned earlier. The purchase data returned by the /upgrades/:purchaseId/cancel-privacy-protection endpoint doesn't match exactly the structure returned by the /me/purchases endpoint.

@gziolo
Copy link
Member

gziolo commented Nov 24, 2015

I changed to In Progress, so far so good! :D

@stephanethomas stephanethomas force-pushed the fix/privacy-protection-cancelation branch from b0dece3 to d85efd8 Compare November 24, 2015 11:02
@scruffian
Copy link
Member

This will be fixed by #699. Not sure if its worth continuing with this PR...

@fabianapsimoes
Copy link
Contributor

This will be fixed by #699. Not sure if its worth continuing with this PR.

FYI, #699 does not fix #189.

@scruffian
Copy link
Member

FYI, #699 does not fix #189.

Ok, thanks for testing. The approach in #699 could be used here though, as an alternative fix... Only an idea :)

@stephanethomas
Copy link
Contributor Author

This pull request is complete, we just need to fix the API to return the right data structure.

@stephanethomas stephanethomas force-pushed the fix/privacy-protection-cancelation branch 4 times, most recently from d79d0d2 to 45b4b92 Compare November 30, 2015 15:40
@scruffian
Copy link
Member

QA 👍

This checks the actual data structure of the store after fetching.
This better handles the case where an error is returned by the API.
This makes this action more consistent with other actions.
Let's follow one naming convention and make this code simpler.
…th other stores

This also formats a block of code and adds some blank lines - to help us breathe.
…n of private registration is successful

This allows to update the Purchases store as soon as possible with up-to-date information (such as the correct price of the domain registration purchase) without resorting to fetching the list of updates.
@stephanethomas stephanethomas force-pushed the fix/privacy-protection-cancelation branch from 45b4b92 to b01894f Compare November 30, 2015 16:21
@scruffian scruffian added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Nov 30, 2015
stephanethomas added a commit that referenced this pull request Nov 30, 2015
…ation

Purchases: Fix purchase not updated upon privacy protection cancelation
@stephanethomas stephanethomas merged commit 6cdf032 into master Nov 30, 2015
@stephanethomas stephanethomas removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Nov 30, 2015
@stephanethomas stephanethomas deleted the fix/privacy-protection-cancelation branch November 30, 2015 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Purchase Management Related to managing purchases such as subscriptions, plans, history, auto-renew, cancellation, etc. [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Purchases: Update domain price after cancelling privacy
4 participants