Skip to content

Fix: Browser back button error in Payment page#3

Open
zubair-ce07 wants to merge 13 commits into
masterfrom
zubair-back-button-fix
Open

Fix: Browser back button error in Payment page#3
zubair-ce07 wants to merge 13 commits into
masterfrom
zubair-back-button-fix

Conversation

@zubair-ce07

Copy link
Copy Markdown

Anyone merging to this repository is expected to promptly release and monitor their changes; if you are not able to do this DO NOT MERGE, please coordinate with someone who can to ensure that the changes are released.

Description

Supporting information

Testing instructions

Other information

Checklist

  • Consider PCI compliance impact and whether this PR changes how credit card information is handled.
  • Intend to release and monitor this PR promptly after merge.

@zubair-ce07
zubair-ce07 requested a review from a team as a code owner April 8, 2024 08:51

@christopappas christopappas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are there any tests that can be updated here to reflect this new behavior?

@zubair-ce07

Copy link
Copy Markdown
Author

Are there any tests that can be updated here to reflect this new behavior?

Let me look into it if we can add any. Thanks

Comment thread src/payment/data/reducers.js Outdated
case BASKET_DATA_RECEIVED: return { ...state, ...action.payload };
case BASKET_DATA_RECEIVED:
if (action.payload.products && action.payload.products.length > 0) {
localStorage.setItem('sku', action.payload.products[0].sku);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Noted you have new code to handle baskets with more than 1 product.

Apart from that, I don't think it's recommended to directly update localStorage within reducers, as they should be pure functions, without any side effects.
You can update it instead within the PaymentPage component or in actions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Alright 👍 I'll update the code accordingly. Thanks

} else {
this.props.fetchBasket();
sendPageEvent();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Have a couple of questions:

  1. Can you make this logic specific to PayPal? We don't want the window location to be set to another URL for Stripe purchases.
  2. Have you tested that regular credit card (Stripe) purchases work?
  3. Have you tested what happens on re-load of the page?

Also, continuing on the other comment I added, you could dispatch an action from this component to set localStorage

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Regarding point 1 I'll update the code so it is specific to PayPal only.
Point 2. Yes I've tested regular credit card purchases
Point 3. On page reload a new basket is created that contains courses/program user was about to purchase. Previously new empty basket was created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants