Last active
July 27, 2026 07:08
-
-
Save xlplugins/cb7d3b050cca2b74e8b56bec490497d7 to your computer and use it in GitHub Desktop.
Use Stripe "Link within card" integration instead of "Link as a payment method"
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
| /** | |
| * "Link within card" for the main Card gateway only. | |
| * Leaves the standalone Link gateway and the express button untouched. | |
| */ | |
| add_filter( 'fkwcs_stripe_payment_element_data', function ( $config, $gateway ) { | |
| if ( ! is_object( $gateway ) || 'fkwcs_stripe' !== $gateway->id ) { | |
| return $config; // don't touch Link gateway / others | |
| } | |
| // Drop 'link' so the payment saves as a card-type PaymentMethod (keeps brand/last4). | |
| if ( ! empty( $config['element_data']['payment_method_types'] ) && is_array( $config['element_data']['payment_method_types'] ) ) { | |
| $config['element_data']['payment_method_types'] = array_values( array_filter( | |
| $config['element_data']['payment_method_types'], | |
| static function ( $type ) { return 'link' !== $type; } | |
| ) ); | |
| } | |
| // Keep Link visible inside the card form a wallet is the display gate, not payme | |
| if ( empty( $config['element_options']['wallets'] ) || ! is_array( $config['element_options']['wallets'] ) ) { | |
| $config['element_options']['wallets'] = array(); | |
| } | |
| $config['element_options']['wallets']['link'] = 'auto'; | |
| return $config; | |
| }, 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment