Created
September 14, 2023 14:53
-
-
Save xlplugins/c7969b42f70639d82f363146df6871db to your computer and use it in GitHub Desktop.
Allow stripe keys to dynamically change
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
| function is_CH_Country() { | |
| if ( is_null( WC() ) || is_null( WC()->customer ) ) { | |
| return false; | |
| } | |
| return WC()->customer->get_shipping_country() == "CH"; | |
| } | |
| add_filter( 'fkwcs_api_client_public_key', 'bbloomer_conditional_publishable_key_fkwcs', 9999 ); | |
| function bbloomer_conditional_publishable_key_fkwcs( $public_key ) { | |
| if ( ! is_CH_Country() ) { | |
| return $public_key; | |
| } | |
| return 'pk_live_xxxxxxxxxxxxxxxxxxxx'; | |
| } | |
| add_filter( 'fkwcs_api_client_secret', 'bbloomer_conditional_private_key_headers_fkwcs', 9999 ); | |
| function bbloomer_conditional_private_key_headers_fkwcs( $client_secret ) { | |
| if ( ! is_CH_Country() ) { | |
| return $client_secret; | |
| } | |
| // STRIPE Live Secret Key HERE | |
| return 'sk_live_xxxxxxxxxxxxxxxxxxx'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment