woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
235 stars 206 forks source link

Stripe is unintentionally renaming other payment gateways with WooCommerce Subscriptions (sometimes) #2699

Open billrobbins opened 1 year ago

billrobbins commented 1 year ago

Describe the bug The Stripe gateway is unintentionally renaming itself and other gateways via the woocommerce_gateway_title filter when used with WooCommerce Subscriptions. There are a few conditions that have to be met to experience this:

My suspicion is that WC_Stripe_Payment_Request()->filter_gateway_title() should return the $title that's passed into the filter unless the _payment_method_title meta value equals one of the values that are specifically mentioned. That's what WooPayments does here.

Maybe we could remove the last return $method_title;?

    /**
     * Filters the gateway title to reflect Payment Request type
     */
    public function filter_gateway_title( $title, $id ) {
        global $post;

        if ( ! is_object( $post ) ) {
            return $title;
        }

        $order        = wc_get_order( $post->ID );
        $method_title = is_object( $order ) ? $order->get_payment_method_title() : '';

        if ( 'stripe' === $id && ! empty( $method_title ) ) {
            if ( 'Apple Pay (Stripe)' === $method_title
                || 'Google Pay (Stripe)' === $method_title
                || 'Payment Request (Stripe)' === $method_title
            ) {
                return $method_title;
            }

            // We renamed 'Chrome Payment Request' to just 'Payment Request' since Payment Requests
            // are supported by other browsers besides Chrome. As such, we need to check for the
            // old title to make sure older orders still reflect that they were paid via Payment
            // Request Buttons.
            if ( 'Chrome Payment Request (Stripe)' === $method_title ) {
                return 'Payment Request (Stripe)';
            }

            return $method_title;
        }

        return $title;
    }

Similar to this issue: https://github.com/woocommerce/woocommerce-gateway-stripe/issues/213

To Reproduce Steps to reproduce the behavior:

  1. Set up WooCommerce Subscriptions, Stripe and at least one additional payment gateway that supports Subscriptions. WooPayments uses the woocommerce_gateway_title filter so don't use that or comment it out.
  2. Purchase a subscription using the other payment method.
  3. Edit the subscription and click on the "pencil" icon in the billing section. Click on the payment method drop-down and you should see the gateway used to make the purchase listed twice.

Expected behavior I expected Stripe to not load the payment method title for other gateways.

Screenshots duplicate-name

Environment (please complete the following information):

Additional context Add any other context about the problem here.

github-actions[bot] commented 1 month ago

Hi, This issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] commented 2 weeks ago

This issue has gone 180 days (6 months) without any activity.