Skip to content

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Aug 12, 2025

Fixes STRIPE-667

Changes proposed in this Pull Request:

This PR moves all the specific Optimized Checkout logic of the card payment method to a new payment method class. The goal is to improve the code's organization and properly separate its concerns.

Testing instructions

  • Checkout to this branch on your test environment (dev/moving-oc-card-method-logic-to-single-method-class)
  • Connect your Stripe account
  • Enable the Optimized Checkout
  • Enable some payment methods
  • As a shopper, add any product to your cart
  • Go to the block checkout page
  • Confirm the Stripe (single) payment element is displayed and you are able to complete the purchase
  • Confirm the same for the classic checkout
  • Confirm that you can also add payment methods

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@wjrosa wjrosa self-assigned this Aug 13, 2025
@wjrosa wjrosa marked this pull request as ready for review August 13, 2025 12:37
@wjrosa wjrosa requested a review from Mayisha August 21, 2025 18:10
@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 21, 2025

@wjrosa card payment is working on both block and shortcode checkout pages but I can not pay with any other redirect methods. I have tested with EPS and iDeal. Checkout fails for both with the following error-

Good catch! That was a new validation we recently added for the payment intent. I was able to reproduce it here and fixed it in ce4817a.

@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 21, 2025

The payment element loads with an error.

Thanks for the steps to reproduce the issue! I haved fixed it in c28b903

The Link button is present in the express payment section (this is not present when OC is disabled)

This specific behavior will be handled in STRIPE-678

@wjrosa wjrosa added this to the 9.9.0 milestone Aug 21, 2025
Copy link
Contributor

@Mayisha Mayisha 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 the updates @wjrosa. The result of functional testing with OC enabled is as following-

✅ Settings looks good.
✅ Enabled methods are rendered correctly on shortcode checkout page.
✅ Enabled methods are rendered correctly on block checkout page
✅ Card payment is working on both checkout pages.
✅ Redirect payment is working on both checkout pages.
🔴 When all the payment methods are disabled I see an error on shortcode checkout page. Block checkout looks good.
Screenshot 2025-08-25 at 6 20 45 PM
🔴 Payment method name is wrong when I pay with Google Pay

page develop this branch
Order received page Screenshot 2025-08-25 at 7 22 35 PM Screenshot 2025-08-25 at 7 25 01 PM
Order edit page Screenshot 2025-08-25 at 7 25 40 PM Screenshot 2025-08-25 at 7 25 45 PM

@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 25, 2025

Thanks for the great review once again, @Mayisha! And for the patience here.

🔴 When all the payment methods are disabled I see an error on shortcode checkout page. Block checkout looks good.

Fixed it in 7feb8d9

🔴 Payment method name is wrong when I pay with Google Pay

Fixed it in 4d60f51

@wjrosa wjrosa requested a review from Mayisha August 25, 2025 21:48
Copy link
Contributor

@Mayisha Mayisha left a comment

Choose a reason for hiding this comment

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

Thanks @wjrosa for the fixes. Confirming that I don't see any of the errors/issues I mentioned in my previous comments.

Settings
✅ OC option is rendered correctly irrespective of the enabled payment methods.

Block checkout
✅ OC element is rendered when there are enabled payment methods.
✅ OC element is not rendered when there are no enabled payment methods. The express methods are also hidden.
✅ Checkout with card is successful.
✅ Checkout with Google Pay is successful and the payment method title is correct.
✅ Checkout with redirect payment method (iDeal/EPS) is successful.

Shortcode checkout
✅ OC element is rendered when there are enabled payment methods.
✅ OC element is not rendered when there are no enabled payment methods. The express methods are also hidden.
✅ Checkout with card is successful.
✅ Checkout with Google Pay is successful and the payment method title is correct.
✅ Checkout with redirect payment method (iDeal/EPS) is successful.

⚠️ Noting one observation with Link as I see STRIPE-678 is merged. When I have no payment methods enabled, I now see the Link button is available in the settings. But I don't see the Link button on checkout page in this branch.

Screenshot 2025-08-26 at 12 06 25 PM

@wjrosa
Copy link
Contributor Author

wjrosa commented Aug 26, 2025

Thanks, Mayisha! I have fixed the availability for the block checkout and created STRIPE-687 to address the same for the shortcode checkout.

Copy link
Contributor

@malithsen malithsen left a comment

Choose a reason for hiding this comment

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

Looks good to me. I left some comments, but they are not merge blockers.

@@ -33,6 +33,7 @@ class WC_Stripe_Payment_Methods {
const SEPA_DEBIT = 'sepa_debit';
const SOFORT = 'sofort';
const WECHAT_PAY = 'wechat_pay';
const OC = 'card'; // This is a special case for the Optimized Checkout
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: To avoid any ambiguity, should we set this to its own ID (eg: oc_container) and then map it to card where frontend/Stripe expects it?

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 tried that, but it caused a lot of bugs (tried it again now and still couldn't do it). We still need some stuff from the card payment method class (even when inactive). That was the way I could make it as independent as possible. We can revisit this later

* @inheritDoc
*/
public function is_available() {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do something like

Suggested change
return true;
if ( ! parent::is_available() ) return false;
return true;

I see the is_available method in WC_Payment_Gateway (which was in the previous inheritance chain) has some additional checks that might be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Added it in f58a3fe. I didn't apply your suggestion directly due to linting.

@wjrosa wjrosa enabled auto-merge (squash) August 26, 2025 15:17
@wjrosa wjrosa merged commit a931019 into develop Aug 26, 2025
39 of 40 checks passed
@wjrosa wjrosa deleted the dev/moving-oc-card-method-logic-to-single-method-class branch August 26, 2025 15:34
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