• Resolved beninabox

    (@beninabox)


    Hi all,

    I have a quick query about Apple Pay and Chrome Payment Requests through the Stripe plugin.
    Whenever I make a Apple Pay payment, I get the following payment method shown “Apple Pay (Stripe)”. Similarly, for Chrome Payment Requests, I get “Chrome Payment Request (Stripe)”.

    I’d like to remove the “(Stripe)” part so not to so obviously expose the credit card processor I am using. Is this possible? I don’t see any filters around that area, but if anyone knows of a solution, I’d love to get it implemented on my sites.

    Thanks

    • This topic was modified 5 years, 9 months ago by beninabox.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @beninabox

    I’d like to remove the “(Stripe)” part so not to so obviously expose the credit card processor I am using. Is this possible? I don’t see any filters around that area, but if anyone knows of a solution, I’d love to get it implemented on my sites.

    I’m taking a look at this and I’ve asked one of the developers for some input, I think it might be wc_stripe_description ($description, $payment_method_id) but I’m unsure.

    It’s all coming from here https://github.com/woocommerce/woocommerce-gateway-stripe/blob/99a4476c8397ccf57e2a98bbd2a6c9cc2c92e023/includes/payment-methods/class-wc-stripe-payment-request.php#L300

    I’ll get back to you with details to see if we can give some pointers.

    Thanks,

    Thread Starter beninabox

    (@beninabox)

    Hey @dougaitken

    Thanks for looking at this. I’ve had a quick look at that, but couldn’t get anywhere. If you do find some pointers, I’d greatly appreciate it ??

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    No problem @beninabox

    One of the developers has gotten back to me and suggested this:

    I think using the woocommerce_gateway_title filter is the easiest way. Set it at a lower priority so it runs after this: https://github.com/woocommerce/woocommerce-gateway-stripe/blob/38e947bac0fbb2a4f44e7587544f2c80c1d3450b/includes/payment-methods/class-wc-stripe-payment-request.php#L197
    And then replicate the logic on filter_gateway_title so it returns Apple Pay when the method title is Apple Pay (Stripe), and same for Chrome Pay

    Hope this helps!

    Thread Starter beninabox

    (@beninabox)

    Thanks @dougaitken – that’s a great help.

    I’m a developer in other languages, but not at all experienced in PHP, so please excuse my naivety ?? .

    I have the following code, but I wasn’t able to get it to work. Do you spot anything wrong?

    function replace_gateway_title( $title ){
    	if( $title == 'Apple Pay (Stripe)' ){
    		return 'Apple Pay';
    	} elseif ( $title == 'Chrome Payment Request (Stripe)' ){
    		return 'Chrome Payment Request';
    	}
    }
    
    add_filter( 'woocommerce_gateway_title', 'replace_gateway_title', 5, 1 );

    Thanks!

    [ Please do not bump. ]

    • This reply was modified 5 years, 8 months ago by Jan Dembowski.
    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Howdy!

    Can you try editing the filter to:

    add_filter( 'woocommerce_gateway_title', array( $this, 'filter_gateway_title' ), 10, 2 );

    Thanks!

    Thread Starter beninabox

    (@beninabox)

    Hi.

    Thanks for the response.

    I tried updating the filter, but didn’t see any change – I’m still getting ‘Apple Pay (Stripe) as the payment method.

    Thanks
    Ben

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi Ben,

    I checked in with one of our developers to review the snippet, and the filter should have a higher priority so it runs *after* the existing logic. Changing that 10 to an 11 should work- sorry about that!

    Also, that function should really have an else branch that just returns $title. Additionally, since the filter accepts 2 arguments, you may need to add the second parameter to the function ($id), but I would recommend testing first to be sure.

    Let me know if this helps!

    Thread Starter beninabox

    (@beninabox)

    Hi, @laceyrod

    Thanks for the response. I updated the priority, and made the other changes you suggested. I’m still not seeing the new text being applied. Any thoughts?

    Here is the full function I’m using now.

    function replace_gateway_title( $title, $id ) {
    	if( $title == 'Apple Pay (Stripe)' ) {
    		return 'Apple Pay';
    	} elseif ( $title == 'Chrome Payment Request (Stripe)' ) {
    		return 'Chrome Payment Request';
    	} else {
    		return $title;
    	}
    }
    
    add_filter( 'woocommerce_gateway_title', 'replace_gateway_title', 11, 2 );
    Plugin Support jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @beninabox If you are just looking to replace (Stripe) in the payment methods, this may be an easier solution:

    
    function replace_gateway_title( $title, $id ) {
    	// We remove (Stripe) from the gateway titles. 
    	return str_replace( '(Stripe)', '', $title );
    }
    add_filter( 'woocommerce_gateway_title', 'replace_gateway_title', 99, 2 );
    

    I have set the filter to run even later, and it worked to replace (Stripe) in the title for my Credit Card option on my checkout, so it should also work for the other two.

    • This reply was modified 5 years, 7 months ago by jessepearson. Reason: Code tags were broken
    Plugin Support melinda a11n

    (@melindahelt)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Apple Pay (Stripe) and Chrome Payment Request (Stripe) Title’ is closed to new replies.