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

Improving the handling of express method titles #3844

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Feb 5, 2025

Changes proposed in this Pull Request:

This PR improves how we handle express payment method titles by introducing new constants and methods to replace duplicate code.

Testing instructions

Code review should be enough. Check if tests are still passing.


  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@wjrosa wjrosa self-assigned this Feb 5, 2025
@wjrosa wjrosa marked this pull request as ready for review February 6, 2025 12:51
@wjrosa wjrosa requested review from a team and diegocurbelo and removed request for a team February 6, 2025 12:59
*/
public static function get_payment_method_titles( $include_link = false ) {
$titles = [
'apple_pay' => WC_Stripe_Express_Payment_Titles::APPLE_PAY,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another implementation option would be translated names, like:

'apple_pay' => __( 'Apple Pay', 'woocommerce-gateway-stripe' ),

But not sure if it is worth since those are brands, which I think are immutable.

Base automatically changed from tweak/hiding-actions-for-pending-amazon-pay-orders to develop February 11, 2025 18:27
@diegocurbelo diegocurbelo requested a review from Mayisha February 17, 2025 19:35
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.

Hi @wjrosa

Thanks for the effort in this PR. After reviewing this, I think that the changes might not add significant value in improving the codebase. It is a bit overengineering to have a new class for the express method titles and also reduces the readability of the code.
We have implemented constants for the payment methods in #3449. I think that was a good refactor and we should use that constant class to store the express method titles as well instead of making it complex with more new classes.

It would be better to hold off on merging this one. Let me know what you think and if you have a strong opinion in favor of these changes 👀

$order->save();
} elseif ( 'payment_request_api' === $payment_request_type ) {
$order->set_payment_method_title( 'Payment Request (Stripe)' );
$payment_method_title = '';
Copy link
Contributor Author

@wjrosa wjrosa Feb 26, 2025

Choose a reason for hiding this comment

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

Just making it easier to read. And fixing the suffix part (it is dynamic).

@@ -41,7 +41,11 @@ public function __construct() {
* @return string
*/
public function get_title( $payment_details = false ) {
$wallet_type = WC_Stripe_Payment_Methods::AMAZON_PAY === ( $payment_details->type ?? null ) ? WC_Stripe_Payment_Methods::AMAZON_PAY : ( $payment_details->card->wallet->type ?? null );
if ( WC_Stripe_Payment_Methods::AMAZON_PAY === ( $payment_details->type ?? null ) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just making it easier to read.

@wjrosa
Copy link
Contributor Author

wjrosa commented Feb 26, 2025

Hi @wjrosa

Thanks for the effort in this PR. After reviewing this, I think that the changes might not add significant value in improving the codebase. It is a bit overengineering to have a new class for the express method titles and also reduces the readability of the code. We have implemented constants for the payment methods in #3449. I think that was a good refactor and we should use that constant class to store the express method titles as well instead of making it complex with more new classes.

It would be better to hold off on merging this one. Let me know what you think and if you have a strong opinion in favor of these changes 👀

Thanks, Mayisha! Oh OK, I have refactored it now just to follow the current implementation of the payment method labels (using the existing constant instead of adding the new one). I have also fixed all the title suffix calls (which were not checking for the filter value). Let me know what you think of this simpler approach 👀

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