@@ -65,6 +65,12 @@ public function copyKeysToCentralSettings() {
6565 add_filter (
6666 'option_woocommerce_monei_settings ' ,
6767 function ( $ default_params ) {
68+ $ newCentralTestApiKey = get_option ( 'monei_test_apikey ' , '' );
69+ $ newCentralLiveApiKey = get_option ( 'monei_live_apikey ' , '' );
70+ //we already saved the new keys, so we don't need to do anything more here.'
71+ if (! empty ( $ newCentralTestApiKey ) ||! empty ( $ newCentralLiveApiKey ) ) {
72+ return $ default_params ;
73+ }
6874 $ centralApiKey = get_option ( 'monei_apikey ' , '' );
6975 $ centralAccountId = get_option ( 'monei_accountid ' , '' );
7076 $ ccApiKey = $ default_params ['apikey ' ] ?? '' ;
@@ -80,14 +86,10 @@ function ( $default_params ) {
8086 update_option ( 'monei_test_apikey ' , $ keyToUse );
8187 update_option ( 'monei_apikey_mode ' , 'test ' );
8288 update_option ( 'monei_test_accountid ' , $ accountId );
83- delete_option ( 'monei_apikey ' );
84- delete_option ( 'monei_accountid ' );
8589 } else if (strpos ( $ keyToUse , 'pk_live_ ' ) === 0 ) {
8690 update_option ( 'monei_live_apikey ' , $ keyToUse );
8791 update_option ( 'monei_apikey_mode ' , 'live ' );
8892 update_option ( 'monei_live_accountid ' , $ accountId );
89- delete_option ( 'monei_apikey ' );
90- delete_option ( 'monei_accountid ' );
9193 }
9294
9395 return $ default_params ;
0 commit comments