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: Reduxify Stored Cards on Edit Card Details page #6748

Merged
merged 5 commits into from
Jul 18, 2016

Conversation

stephanethomas
Copy link
Contributor

@stephanethomas stephanethomas commented Jul 13, 2016

This pull request is a follow-up of #6613, #6628, #6665, #6710 that updates the Edit Card Details page to use the global state tree to manage credit cards (stored during previous purchases or when a user added a new payment method to an existing purchase) instead of the former Flux store:

screenshot

It also fixes the prefilling of the card holder name that was broken.

Testing instructions

  1. Run git checkout update/reduxify-edit-card-details and start your server, or open a live branch
  2. Sandbox the store
  3. Purchase e.g. a plan or a site redirect with a fake credit card
  4. Open the Purchases page
  5. Click on the new purchase
  6. Click on the Edit Payment Method action
  7. Check that the Name on Card field contains the card holder name used in the checkout
  8. Enter a new fake credit card (with a different name) and click the Save Card button
  9. Check that you are redirected back to the Manage Purchase page with a success message
  10. Check that you can see this new card on the Billing History page
  11. Navigate back to the same Edit Card Details page
  12. Check that the Name on Card field is prefilled in with the new name

You may want to check other payment methods, or type of purchases. You could also force a browser refresh on certain pages to make sure it doesn't make a difference.

Additional notes

I opted not to update the Redux selector to remap keys similarly to what the former assembler was doing because as you can see it here the only value we care is the card holder name. We use the keys provided by the API in any other places where we display credit cards. We can address that in a separate pull request though if most of us think it's worth it.

Reviews

  • Code
  • Product
  • Tests

@Automattic/sdev-feed

@stephanethomas stephanethomas added [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 Jul 13, 2016
@stephanethomas stephanethomas self-assigned this Jul 13, 2016
@stephanethomas stephanethomas force-pushed the update/reduxify-edit-card-details branch 2 times, most recently from 9964292 to c600b53 Compare July 13, 2016 17:10
! state.selectedPurchase.hasLoadedUserPurchasesFromServer ||
! state.hasLoadedSites
! state.hasLoadedSites ||
state.isFetchingStoredCards
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not super fan of referring here to a prop that is in fact set in the EditCardDetails component but managing it in this data component proved to be awkward (or maybe that's just me :) ).

@drewblaisdell
Copy link
Contributor

This looks good. I had one note about moving the logic to display the loading placeholder and query the stored cards into EditCardDetails itself, in order to remove EditCardDetailsData.

@drewblaisdell drewblaisdell added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 13, 2016
@stephanethomas stephanethomas force-pushed the update/reduxify-edit-card-details branch from c600b53 to 5434348 Compare July 14, 2016 09:43
@stephanethomas stephanethomas force-pushed the update/reduxify-edit-card-details branch from 5434348 to dd79703 Compare July 17, 2016 14:51
@stephanethomas
Copy link
Contributor Author

Thank you very much for the review @drewblaisdell. I updated this pull request per your suggestion. It is now ready for another review.

@stephanethomas stephanethomas 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 Jul 17, 2016
@fabianapsimoes
Copy link
Contributor

fabianapsimoes commented Jul 18, 2016

I'm unable to open Manage Purchase in this branch. I see this error in the console when I click any items in the list in /purchases:

TypeError: creditCard is undefined

Edit: Seems it doesn't happen to all purchases, but to some of them. I'm guessing the ones that do not have a payment method?

@fabianapsimoes fabianapsimoes added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 18, 2016
@stephanethomas stephanethomas force-pushed the update/reduxify-edit-card-details branch from dd79703 to b4444f3 Compare July 18, 2016 15:03
@stephanethomas
Copy link
Contributor Author

Thanks for catching this error @fabianapsimoes. I've fixed the issue, this is ready for review again.

@stephanethomas stephanethomas added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Jul 18, 2016
@fabianapsimoes
Copy link
Contributor

Product 👍

fields = this.mergeCard( this.props.card.data, fields );

if ( this.props.card ) {
fields.name = this.props.card.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Super minor, but fields should be a const now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@drewblaisdell
Copy link
Contributor

drewblaisdell commented Jul 18, 2016

I also tested this, and the code looks good to me. 👍 Not remapping keys seems like the right approach for this change, as well.

@drewblaisdell drewblaisdell added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jul 18, 2016
@stephanethomas stephanethomas force-pushed the update/reduxify-edit-card-details branch from b4444f3 to 18c7e60 Compare July 18, 2016 16:07
@stephanethomas stephanethomas merged commit ca92df0 into master Jul 18, 2016
@stephanethomas stephanethomas deleted the update/reduxify-edit-card-details branch July 18, 2016 16:11
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants