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

fix(modal-checkout): add custom modal checkout validation #2008

Closed
wants to merge 4 commits into from

Conversation

chickenn00dle
Copy link
Contributor

@chickenn00dle chickenn00dle commented Dec 17, 2024

All Submissions:

Changes proposed in this Pull Request:

This PR moves the modal checkout validation request to newspack blocks. We still call WC_Checkout::process_checkout, but beforehand we override the needs payment flag so that step 1 of modal checkout doesn't validate payment method (not needed at this point).

How to test the changes in this Pull Request:

  1. Smoke test modal checkout using various supported payment methods, as a logged in and logged out reader:
  • Stripe
  • WCPay
  • PayPal Payments

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@laurelfulford laurelfulford left a comment

Choose a reason for hiding this comment

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

Thanks for tackling this, @chickenn00dle!

I worked through all the payment gateways you listed, and the only issue I ran into is PayPal Payments now shows a "Proceed to PayPal" button:

CleanShot 2024-12-18 at 18 35 14

When I switch back to trunk, the button goes away. The Yellow button works as expected; the Proceed to PayPal button technically works, but it's kind of weird - it loads the form inside of the checkout modal, and then redirects to a full screen to authenticate, then into a non-modal order confirmation.

Just let me know if this doesn't match what you're seeing and I'll see if I can recreate it elsewhere!

@chickenn00dle chickenn00dle force-pushed the fix/add-custom-validation branch from e05d6d7 to 93392a5 Compare December 19, 2024 19:31
@chickenn00dle
Copy link
Contributor Author

Thanks for the review @laurelfulford!

When I switch back to trunk, the button goes away. The Yellow button works as expected; the Proceed to PayPal button technically works, but it's kind of weird - it loads the form inside of the checkout modal, and then redirects to a full screen to authenticate, then into a non-modal order confirmation.

Good catch!

I was checking $wp_script->src when iterating through $wp_styles so the paypal css assets were missing 🤦 .

Fixed in 93392a5

/**
* Process modal checkout validation.
*/
public static function validate_checkout_request() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miguelpeixe, I'd love your opinion on this approach for "hijacking" the form validation from Woo. In particular, do you think its safe to rename the woocommerce-process-checkout-nonce on the front end, then reassign in the backend before triggering WC_Checkout::process_checkout?

@chickenn00dle
Copy link
Contributor Author

Seems this is no longer needed, so gonna close this one!

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

Successfully merging this pull request may close these issues.

2 participants