Last active
November 4, 2026 10:58
-
-
Save xlplugins/8907909488f2e043cbba16f606965aa5 to your computer and use it in GitHub Desktop.
/** * FunnelKit Stripe: don't save the card for Google Pay / Apple Pay payments. * * Wallet payments are sent as one-time payments (no setup_future_usage=off_session), so banks * ask for 3D Secure less often. Card payments and subscription orders still save the card. * A wallet order has no saved card to charge again, so its one-click upsell is …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * FunnelKit Stripe: don't save the card for Google Pay payments. | |
| * | |
| * Google Pay payments are sent as one-time payments (no setup_future_usage=off_session), so banks | |
| * ask for 3D Secure less often. Apple Pay, card payments and subscription orders still save the card. | |
| * A Google Pay order has no saved card to charge again, so its one-click upsell is skipped. | |
| */ | |
| function fk_wallet_no_save_is_wallet_order( $order ) { | |
| $wallet_gateways = array( 'fkwcs_stripe_google_pay' ); | |
| $request_type = isset( $_POST['payment_request_type'] ) ? sanitize_key( wp_unslash( $_POST['payment_request_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| return in_array( $request_type, array( 'google_pay' ), true ) || in_array( $order->get_payment_method(), $wallet_gateways, true ); | |
| } | |
| add_filter( 'fkwcs_should_save_card', function ( $save_card, $order ) { | |
| if ( ! $order instanceof WC_Order || ! fk_wallet_no_save_is_wallet_order( $order ) ) { | |
| return $save_card; | |
| } | |
| // Subscriptions need the saved card for renewals. | |
| if ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order ) || wcs_order_contains_renewal( $order ) ) ) { | |
| return $save_card; | |
| } | |
| $order->update_meta_data( '_fk_wallet_card_not_saved', 'yes' ); | |
| $order->save_meta_data(); | |
| return false; | |
| }, 20, 2 ); | |
| // No saved card means the upsell can't be charged, so skip it for these orders. | |
| add_filter( 'wfocu_front_skip_funnel', function ( $skip, $order ) { | |
| return ( $order instanceof WC_Order && 'yes' === $order->get_meta( '_fk_wallet_card_not_saved' ) ) ? true : $skip; | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment