Changeset 3321331
- Timestamp:
- 07/02/2025 03:06:54 PM (9 months ago)
- Location:
- monei
- Files:
-
- 14 edited
- 1 copied
-
tags/6.3.7 (copied) (copied from monei/trunk)
-
tags/6.3.7/changelog.txt (modified) (1 diff)
-
tags/6.3.7/class-woocommerce-gateway-monei.php (modified) (2 diffs)
-
tags/6.3.7/readme.txt (modified) (2 diffs)
-
tags/6.3.7/src/Services/ApiKeyService.php (modified) (1 diff)
-
tags/6.3.7/src/Services/sdk/MoneiSdkClientFactory.php (modified) (1 diff)
-
tags/6.3.7/vendor/composer/installed.php (modified) (2 diffs)
-
tags/6.3.7/woocommerce-gateway-monei.php (modified) (1 diff)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/class-woocommerce-gateway-monei.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Services/ApiKeyService.php (modified) (1 diff)
-
trunk/src/Services/sdk/MoneiSdkClientFactory.php (modified) (1 diff)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/woocommerce-gateway-monei.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
monei/tags/6.3.7/changelog.txt
r3307208 r3321331 1 1 *** MONEI Payments for WooCommerce *** 2 3 2025-07-02 - version 6.3.7 4 * Fix - Send correct useragent version 5 * Fix - plugin crashes when updating from older version 2 6 3 7 2025-06-05 - version 6.3.6 -
monei/tags/6.3.7/class-woocommerce-gateway-monei.php
r3307208 r3321331 6 6 * @category Core 7 7 * @package Woocommerce_Gateway_Monei 8 * @version 6.3. 68 * @version 6.3.7 9 9 */ 10 10 … … 26 26 * @var string 27 27 */ 28 public $version = '6.3. 6';28 public $version = '6.3.7'; 29 29 30 30 /** -
monei/tags/6.3.7/readme.txt
r3307208 r3321331 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 6.3. 66 Stable tag: 6.3.7 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 104 104 == Changelog == 105 105 106 2025-06-05 - version 6.3.6 106 2025-07-02 - version 6.3.7 107 * Fix - Send correct useragent version 108 * Fix - plugin crashes when updating from older version 109 110 2025-06-05 - version 6.3.7 107 111 * Fix - Remove old _payment_method transients on activation and update 108 112 -
monei/tags/6.3.7/src/Services/ApiKeyService.php
r3293325 r3321331 62 62 } 63 63 64 public function copyKeysToCentralSettings() { 65 add_filter( 66 'option_woocommerce_monei_settings', 67 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 } 74 $centralApiKey = get_option( 'monei_apikey', '' ); 75 $centralAccountId = get_option( 'monei_accountid', '' ); 76 $ccApiKey = $default_params['apikey'] ?? ''; 77 $ccAccountId = $default_params['accountid'] ?? ''; 78 79 if ( empty( $centralApiKey ) && empty( $ccApiKey ) ) { 80 return $default_params; 81 } 82 $keyToUse = ! empty( $centralApiKey ) ? $centralApiKey : $ccApiKey; 83 $accountId = ! empty( $centralAccountId ) ? $centralAccountId : $ccAccountId; 84 85 $settings = get_option( 'woocommerce_monei_settings', array() ); 86 if ( strpos( $keyToUse, 'pk_test_' ) === 0 ) { 87 update_option( 'monei_test_apikey', $keyToUse ); 88 update_option( 'monei_apikey_mode', 'test' ); 89 update_option( 'monei_test_accountid', $accountId ); 90 91 } elseif ( strpos( $keyToUse, 'pk_live_' ) === 0 ) { 92 update_option( 'monei_live_apikey', $keyToUse ); 93 update_option( 'monei_apikey_mode', 'live' ); 94 update_option( 'monei_live_accountid', $accountId ); 95 } 96 delete_option( 'monei_apikey' ); 97 delete_option( 'monei_accountid' ); 98 unset( $settings['accountid'] ); 99 unset( $settings['apikey'] ); 100 update_option( 'woocommerce_monei_settings', $settings ); 101 return $default_params; 102 }, 103 1 104 ); 105 } 64 public function copyKeysToCentralSettings() { 65 // Get the current state once 66 $keyState = $this->getCurrentKeyState(); 67 68 // First, check if we need any migration at all 69 if ($this->needsMigration($keyState)) { 70 // Try standalone migration first (has priority) 71 $standaloneSuccess = $this->migrateStandaloneKeys($keyState); 72 73 // Only bother with settings if standalone migration didn't complete everything 74 if (!$standaloneSuccess) { 75 add_filter('option_woocommerce_monei_settings', array($this, 'processCentralSettings'), 10, 1); 76 } 77 } 78 } 79 80 /** 81 * Get current state of all keys 82 * 83 * @return array Current key state 84 */ 85 private function getCurrentKeyState() { 86 return array( 87 'test_api_key' => get_option('monei_test_apikey', ''), 88 'live_api_key' => get_option('monei_live_apikey', ''), 89 'test_account_id' => get_option('monei_test_accountid', ''), 90 'live_account_id' => get_option('monei_live_accountid', ''), 91 'current_mode' => get_option('monei_apikey_mode', ''), 92 ); 93 } 94 95 /** 96 * Check if any migration is needed 97 * 98 * @param array $keyState Current key state 99 * @return bool True if migration is needed 100 */ 101 private function needsMigration($keyState) { 102 // Get legacy keys 103 $legacyApiKey = get_option('monei_apikey', ''); 104 $legacyAccountId = get_option('monei_accountid', ''); 105 $existingSettings = get_option('woocommerce_monei_settings', array()); 106 $settingsApiKey = $existingSettings['apikey'] ?? ''; 107 $settingsAccountId = $existingSettings['accountid'] ?? ''; 108 109 // Check if both new key sets are complete 110 $testKeysComplete = !empty($keyState['test_api_key']) && !empty($keyState['test_account_id']); 111 $liveKeysComplete = !empty($keyState['live_api_key']) && !empty($keyState['live_account_id']); 112 113 // If both are complete, no migration needed 114 if ($testKeysComplete && $liveKeysComplete) { 115 return false; 116 } 117 118 // If we have any legacy keys or incomplete new keys, migration is needed 119 return !empty($legacyApiKey) || !empty($legacyAccountId) || 120 !empty($settingsApiKey) || !empty($settingsAccountId) || 121 (!empty($keyState['test_api_key']) && empty($keyState['test_account_id'])) || 122 (!empty($keyState['live_api_key']) && empty($keyState['live_account_id'])); 123 } 124 125 /** 126 * Migrate standalone legacy keys (works regardless of settings existence) 127 * 128 * @param array $keyState Current key state 129 * @return bool True if migration was successful and complete, false if settings migration is still needed 130 */ 131 private function migrateStandaloneKeys($keyState) { 132 // Get legacy standalone keys 133 $legacyApiKey = get_option('monei_apikey', ''); 134 $legacyAccountId = get_option('monei_accountid', ''); 135 136 $needsCleanup = false; 137 $migratedFromStandalone = false; 138 139 // Complete partial new keys using legacy standalone keys 140 if (!empty($keyState['test_api_key']) && empty($keyState['test_account_id']) && !empty($legacyAccountId)) { 141 update_option('monei_test_accountid', $legacyAccountId); 142 $needsCleanup = true; 143 $migratedFromStandalone = true; 144 } 145 146 if (!empty($keyState['live_api_key']) && empty($keyState['live_account_id']) && !empty($legacyAccountId)) { 147 update_option('monei_live_accountid', $legacyAccountId); 148 $needsCleanup = true; 149 $migratedFromStandalone = true; 150 } 151 152 // Set mode based on existing new keys if mode is not set 153 if (empty($keyState['current_mode'])) { 154 if (!empty($keyState['test_api_key'])) { 155 update_option('monei_apikey_mode', 'test'); 156 } elseif (!empty($keyState['live_api_key'])) { 157 update_option('monei_apikey_mode', 'live'); 158 } 159 } 160 161 // Full migration from legacy standalone keys if no new keys exist 162 if (empty($keyState['test_api_key']) && empty($keyState['live_api_key']) && !empty($legacyApiKey)) { 163 if ($this->migrateSingleKeySet($legacyApiKey, $legacyAccountId, $keyState['current_mode'])) { 164 $needsCleanup = true; 165 $migratedFromStandalone = true; 166 } 167 } 168 169 // Clean up legacy standalone keys if we migrated 170 if ($needsCleanup) { 171 delete_option('monei_apikey'); 172 delete_option('monei_accountid'); 173 } 174 175 // Return true if we migrated anything from standalone (has priority over settings) 176 // or if we already had complete key sets 177 $initialTestKeysComplete = !empty($keyState['test_api_key']) && !empty($keyState['test_account_id']); 178 $initialLiveKeysComplete = !empty($keyState['live_api_key']) && !empty($keyState['live_account_id']); 179 180 return $migratedFromStandalone || ($initialTestKeysComplete || $initialLiveKeysComplete); 181 } 182 183 /** 184 * Process and migrate API keys from settings (only called via filter) 185 * 186 * @param array $default_params The settings array from the filter 187 * @return array The processed settings array 188 */ 189 public function processCentralSettings($default_params) { 190 $newTestApiKey = get_option('monei_test_apikey', ''); 191 $newLiveApiKey = get_option('monei_live_apikey', ''); 192 $newTestAccountId = get_option('monei_test_accountid', ''); 193 $newLiveAccountId = get_option('monei_live_accountid', ''); 194 $currentMode = get_option('monei_apikey_mode', ''); 195 196 // Get keys from settings 197 $settingsApiKey = $default_params['apikey'] ?? ''; 198 $settingsAccountId = $default_params['accountid'] ?? ''; 199 200 $needsCleanup = false; 201 $testKeysComplete = !empty($newTestApiKey) && !empty($newTestAccountId); 202 $liveKeysComplete = !empty($newLiveApiKey) && !empty($newLiveAccountId); 203 204 // If both sets are complete, just clean up settings and return 205 if ($testKeysComplete && $liveKeysComplete) { 206 if (empty($currentMode)) { 207 update_option('monei_apikey_mode', 'test'); 208 } 209 return $this->cleanup_legacy_keys($default_params); 210 } 211 212 // Complete partial new keys using settings keys 213 if (!empty($newTestApiKey) && empty($newTestAccountId) && !empty($settingsAccountId)) { 214 update_option('monei_test_accountid', $settingsAccountId); 215 $needsCleanup = true; 216 } 217 218 if (!empty($newLiveApiKey) && empty($newLiveAccountId) && !empty($settingsAccountId)) { 219 update_option('monei_live_accountid', $settingsAccountId); 220 $needsCleanup = true; 221 } 222 223 // Set mode based on existing new keys if mode is not set 224 if (empty($currentMode)) { 225 if (!empty($newTestApiKey)) { 226 update_option('monei_apikey_mode', 'test'); 227 } elseif (!empty($newLiveApiKey)) { 228 update_option('monei_apikey_mode', 'live'); 229 } 230 } 231 232 // Full migration from settings keys if no new keys exist 233 if (empty($newTestApiKey) && empty($newLiveApiKey) && !empty($settingsApiKey)) { 234 if ($this->migrateSingleKeySet($settingsApiKey, $settingsAccountId, $currentMode)) { 235 $needsCleanup = true; 236 } 237 } 238 239 // Clean up legacy keys from settings if we did any migration 240 if ($needsCleanup) { 241 $default_params = $this->cleanup_legacy_keys($default_params); 242 } 243 244 return $default_params; 245 } 246 247 /** 248 * Migrate a single key set based on key prefix 249 * 250 * @param string $apiKey The API key to migrate 251 * @param string $accountId The account ID to migrate 252 * @param string $currentMode Current mode setting 253 * @return bool True if migration occurred 254 */ 255 private function migrateSingleKeySet($apiKey, $accountId, $currentMode) { 256 if (strpos($apiKey, 'pk_test_') === 0) { 257 update_option('monei_test_apikey', $apiKey); 258 if (!empty($accountId)) { 259 update_option('monei_test_accountid', $accountId); 260 } 261 if (empty($currentMode)) { 262 update_option('monei_apikey_mode', 'test'); 263 } 264 return true; 265 } elseif (strpos($apiKey, 'pk_live_') === 0) { 266 update_option('monei_live_apikey', $apiKey); 267 if (!empty($accountId)) { 268 update_option('monei_live_accountid', $accountId); 269 } 270 if (empty($currentMode)) { 271 update_option('monei_apikey_mode', 'live'); 272 } 273 return true; 274 } 275 return false; 276 } 277 278 /** 279 * Clean up legacy keys from settings array 280 * 281 * @param array $settings_array The settings array 282 * @return array The cleaned settings array 283 */ 284 private function cleanup_legacy_keys($settings_array) { 285 if (isset($settings_array['apikey'])) { 286 unset($settings_array['apikey']); 287 } 288 if (isset($settings_array['accountid'])) { 289 unset($settings_array['accountid']); 290 } 291 292 return $settings_array; 293 } 106 294 } -
monei/tags/6.3.7/src/Services/sdk/MoneiSdkClientFactory.php
r3306462 r3321331 23 23 include_once WC_Monei()->plugin_path() . '/vendor/autoload.php'; 24 24 $config = Configuration::getDefaultConfiguration(); 25 $config->setUserAgent( 'MONEI/WooCommerce/' . WC_Monei()->version );26 25 $this->client = new MoneiClient( $this->apiKeyService->get_api_key(), $config ); 26 $this->client->setUserAgent( 'MONEI/WooCommerce/'. WC_Monei()->version ); 27 27 } 28 28 return $this->client; -
monei/tags/6.3.7/vendor/composer/installed.php
r3307208 r3321331 2 2 'root' => array( 3 3 'name' => '__root__', 4 'pretty_version' => ' dev-master',5 'version' => ' dev-master',6 'reference' => ' 04806721f8aace5b73ee0c3aab0bf1c06f99ee40',4 'pretty_version' => '6.3.7', 5 'version' => '6.3.7.0', 6 'reference' => '2b0afda9ccb188baf158c358ddd28bf2fe2c669f', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 '__root__' => array( 14 'pretty_version' => ' dev-master',15 'version' => ' dev-master',16 'reference' => ' 04806721f8aace5b73ee0c3aab0bf1c06f99ee40',14 'pretty_version' => '6.3.7', 15 'version' => '6.3.7.0', 16 'reference' => '2b0afda9ccb188baf158c358ddd28bf2fe2c669f', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
monei/tags/6.3.7/woocommerce-gateway-monei.php
r3307208 r3321331 11 11 * Plugin URI: https://wordpress.org/plugins/monei/ 12 12 * Description: Accept Card, Apple Pay, Google Pay, Bizum, PayPal and many more payment methods in your store. 13 * Version: 6.3. 613 * Version: 6.3.7 14 14 * Author: MONEI 15 15 * Author URI: https://www.monei.com/ -
monei/trunk/changelog.txt
r3307208 r3321331 1 1 *** MONEI Payments for WooCommerce *** 2 3 2025-07-02 - version 6.3.7 4 * Fix - Send correct useragent version 5 * Fix - plugin crashes when updating from older version 2 6 3 7 2025-06-05 - version 6.3.6 -
monei/trunk/class-woocommerce-gateway-monei.php
r3307208 r3321331 6 6 * @category Core 7 7 * @package Woocommerce_Gateway_Monei 8 * @version 6.3. 68 * @version 6.3.7 9 9 */ 10 10 … … 26 26 * @var string 27 27 */ 28 public $version = '6.3. 6';28 public $version = '6.3.7'; 29 29 30 30 /** -
monei/trunk/readme.txt
r3307208 r3321331 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 6.3. 66 Stable tag: 6.3.7 7 7 Requires PHP: 7.2 8 8 License: GPLv2 or later … … 104 104 == Changelog == 105 105 106 2025-06-05 - version 6.3.6 106 2025-07-02 - version 6.3.7 107 * Fix - Send correct useragent version 108 * Fix - plugin crashes when updating from older version 109 110 2025-06-05 - version 6.3.7 107 111 * Fix - Remove old _payment_method transients on activation and update 108 112 -
monei/trunk/src/Services/ApiKeyService.php
r3293325 r3321331 62 62 } 63 63 64 public function copyKeysToCentralSettings() { 65 add_filter( 66 'option_woocommerce_monei_settings', 67 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 } 74 $centralApiKey = get_option( 'monei_apikey', '' ); 75 $centralAccountId = get_option( 'monei_accountid', '' ); 76 $ccApiKey = $default_params['apikey'] ?? ''; 77 $ccAccountId = $default_params['accountid'] ?? ''; 78 79 if ( empty( $centralApiKey ) && empty( $ccApiKey ) ) { 80 return $default_params; 81 } 82 $keyToUse = ! empty( $centralApiKey ) ? $centralApiKey : $ccApiKey; 83 $accountId = ! empty( $centralAccountId ) ? $centralAccountId : $ccAccountId; 84 85 $settings = get_option( 'woocommerce_monei_settings', array() ); 86 if ( strpos( $keyToUse, 'pk_test_' ) === 0 ) { 87 update_option( 'monei_test_apikey', $keyToUse ); 88 update_option( 'monei_apikey_mode', 'test' ); 89 update_option( 'monei_test_accountid', $accountId ); 90 91 } elseif ( strpos( $keyToUse, 'pk_live_' ) === 0 ) { 92 update_option( 'monei_live_apikey', $keyToUse ); 93 update_option( 'monei_apikey_mode', 'live' ); 94 update_option( 'monei_live_accountid', $accountId ); 95 } 96 delete_option( 'monei_apikey' ); 97 delete_option( 'monei_accountid' ); 98 unset( $settings['accountid'] ); 99 unset( $settings['apikey'] ); 100 update_option( 'woocommerce_monei_settings', $settings ); 101 return $default_params; 102 }, 103 1 104 ); 105 } 64 public function copyKeysToCentralSettings() { 65 // Get the current state once 66 $keyState = $this->getCurrentKeyState(); 67 68 // First, check if we need any migration at all 69 if ($this->needsMigration($keyState)) { 70 // Try standalone migration first (has priority) 71 $standaloneSuccess = $this->migrateStandaloneKeys($keyState); 72 73 // Only bother with settings if standalone migration didn't complete everything 74 if (!$standaloneSuccess) { 75 add_filter('option_woocommerce_monei_settings', array($this, 'processCentralSettings'), 10, 1); 76 } 77 } 78 } 79 80 /** 81 * Get current state of all keys 82 * 83 * @return array Current key state 84 */ 85 private function getCurrentKeyState() { 86 return array( 87 'test_api_key' => get_option('monei_test_apikey', ''), 88 'live_api_key' => get_option('monei_live_apikey', ''), 89 'test_account_id' => get_option('monei_test_accountid', ''), 90 'live_account_id' => get_option('monei_live_accountid', ''), 91 'current_mode' => get_option('monei_apikey_mode', ''), 92 ); 93 } 94 95 /** 96 * Check if any migration is needed 97 * 98 * @param array $keyState Current key state 99 * @return bool True if migration is needed 100 */ 101 private function needsMigration($keyState) { 102 // Get legacy keys 103 $legacyApiKey = get_option('monei_apikey', ''); 104 $legacyAccountId = get_option('monei_accountid', ''); 105 $existingSettings = get_option('woocommerce_monei_settings', array()); 106 $settingsApiKey = $existingSettings['apikey'] ?? ''; 107 $settingsAccountId = $existingSettings['accountid'] ?? ''; 108 109 // Check if both new key sets are complete 110 $testKeysComplete = !empty($keyState['test_api_key']) && !empty($keyState['test_account_id']); 111 $liveKeysComplete = !empty($keyState['live_api_key']) && !empty($keyState['live_account_id']); 112 113 // If both are complete, no migration needed 114 if ($testKeysComplete && $liveKeysComplete) { 115 return false; 116 } 117 118 // If we have any legacy keys or incomplete new keys, migration is needed 119 return !empty($legacyApiKey) || !empty($legacyAccountId) || 120 !empty($settingsApiKey) || !empty($settingsAccountId) || 121 (!empty($keyState['test_api_key']) && empty($keyState['test_account_id'])) || 122 (!empty($keyState['live_api_key']) && empty($keyState['live_account_id'])); 123 } 124 125 /** 126 * Migrate standalone legacy keys (works regardless of settings existence) 127 * 128 * @param array $keyState Current key state 129 * @return bool True if migration was successful and complete, false if settings migration is still needed 130 */ 131 private function migrateStandaloneKeys($keyState) { 132 // Get legacy standalone keys 133 $legacyApiKey = get_option('monei_apikey', ''); 134 $legacyAccountId = get_option('monei_accountid', ''); 135 136 $needsCleanup = false; 137 $migratedFromStandalone = false; 138 139 // Complete partial new keys using legacy standalone keys 140 if (!empty($keyState['test_api_key']) && empty($keyState['test_account_id']) && !empty($legacyAccountId)) { 141 update_option('monei_test_accountid', $legacyAccountId); 142 $needsCleanup = true; 143 $migratedFromStandalone = true; 144 } 145 146 if (!empty($keyState['live_api_key']) && empty($keyState['live_account_id']) && !empty($legacyAccountId)) { 147 update_option('monei_live_accountid', $legacyAccountId); 148 $needsCleanup = true; 149 $migratedFromStandalone = true; 150 } 151 152 // Set mode based on existing new keys if mode is not set 153 if (empty($keyState['current_mode'])) { 154 if (!empty($keyState['test_api_key'])) { 155 update_option('monei_apikey_mode', 'test'); 156 } elseif (!empty($keyState['live_api_key'])) { 157 update_option('monei_apikey_mode', 'live'); 158 } 159 } 160 161 // Full migration from legacy standalone keys if no new keys exist 162 if (empty($keyState['test_api_key']) && empty($keyState['live_api_key']) && !empty($legacyApiKey)) { 163 if ($this->migrateSingleKeySet($legacyApiKey, $legacyAccountId, $keyState['current_mode'])) { 164 $needsCleanup = true; 165 $migratedFromStandalone = true; 166 } 167 } 168 169 // Clean up legacy standalone keys if we migrated 170 if ($needsCleanup) { 171 delete_option('monei_apikey'); 172 delete_option('monei_accountid'); 173 } 174 175 // Return true if we migrated anything from standalone (has priority over settings) 176 // or if we already had complete key sets 177 $initialTestKeysComplete = !empty($keyState['test_api_key']) && !empty($keyState['test_account_id']); 178 $initialLiveKeysComplete = !empty($keyState['live_api_key']) && !empty($keyState['live_account_id']); 179 180 return $migratedFromStandalone || ($initialTestKeysComplete || $initialLiveKeysComplete); 181 } 182 183 /** 184 * Process and migrate API keys from settings (only called via filter) 185 * 186 * @param array $default_params The settings array from the filter 187 * @return array The processed settings array 188 */ 189 public function processCentralSettings($default_params) { 190 $newTestApiKey = get_option('monei_test_apikey', ''); 191 $newLiveApiKey = get_option('monei_live_apikey', ''); 192 $newTestAccountId = get_option('monei_test_accountid', ''); 193 $newLiveAccountId = get_option('monei_live_accountid', ''); 194 $currentMode = get_option('monei_apikey_mode', ''); 195 196 // Get keys from settings 197 $settingsApiKey = $default_params['apikey'] ?? ''; 198 $settingsAccountId = $default_params['accountid'] ?? ''; 199 200 $needsCleanup = false; 201 $testKeysComplete = !empty($newTestApiKey) && !empty($newTestAccountId); 202 $liveKeysComplete = !empty($newLiveApiKey) && !empty($newLiveAccountId); 203 204 // If both sets are complete, just clean up settings and return 205 if ($testKeysComplete && $liveKeysComplete) { 206 if (empty($currentMode)) { 207 update_option('monei_apikey_mode', 'test'); 208 } 209 return $this->cleanup_legacy_keys($default_params); 210 } 211 212 // Complete partial new keys using settings keys 213 if (!empty($newTestApiKey) && empty($newTestAccountId) && !empty($settingsAccountId)) { 214 update_option('monei_test_accountid', $settingsAccountId); 215 $needsCleanup = true; 216 } 217 218 if (!empty($newLiveApiKey) && empty($newLiveAccountId) && !empty($settingsAccountId)) { 219 update_option('monei_live_accountid', $settingsAccountId); 220 $needsCleanup = true; 221 } 222 223 // Set mode based on existing new keys if mode is not set 224 if (empty($currentMode)) { 225 if (!empty($newTestApiKey)) { 226 update_option('monei_apikey_mode', 'test'); 227 } elseif (!empty($newLiveApiKey)) { 228 update_option('monei_apikey_mode', 'live'); 229 } 230 } 231 232 // Full migration from settings keys if no new keys exist 233 if (empty($newTestApiKey) && empty($newLiveApiKey) && !empty($settingsApiKey)) { 234 if ($this->migrateSingleKeySet($settingsApiKey, $settingsAccountId, $currentMode)) { 235 $needsCleanup = true; 236 } 237 } 238 239 // Clean up legacy keys from settings if we did any migration 240 if ($needsCleanup) { 241 $default_params = $this->cleanup_legacy_keys($default_params); 242 } 243 244 return $default_params; 245 } 246 247 /** 248 * Migrate a single key set based on key prefix 249 * 250 * @param string $apiKey The API key to migrate 251 * @param string $accountId The account ID to migrate 252 * @param string $currentMode Current mode setting 253 * @return bool True if migration occurred 254 */ 255 private function migrateSingleKeySet($apiKey, $accountId, $currentMode) { 256 if (strpos($apiKey, 'pk_test_') === 0) { 257 update_option('monei_test_apikey', $apiKey); 258 if (!empty($accountId)) { 259 update_option('monei_test_accountid', $accountId); 260 } 261 if (empty($currentMode)) { 262 update_option('monei_apikey_mode', 'test'); 263 } 264 return true; 265 } elseif (strpos($apiKey, 'pk_live_') === 0) { 266 update_option('monei_live_apikey', $apiKey); 267 if (!empty($accountId)) { 268 update_option('monei_live_accountid', $accountId); 269 } 270 if (empty($currentMode)) { 271 update_option('monei_apikey_mode', 'live'); 272 } 273 return true; 274 } 275 return false; 276 } 277 278 /** 279 * Clean up legacy keys from settings array 280 * 281 * @param array $settings_array The settings array 282 * @return array The cleaned settings array 283 */ 284 private function cleanup_legacy_keys($settings_array) { 285 if (isset($settings_array['apikey'])) { 286 unset($settings_array['apikey']); 287 } 288 if (isset($settings_array['accountid'])) { 289 unset($settings_array['accountid']); 290 } 291 292 return $settings_array; 293 } 106 294 } -
monei/trunk/src/Services/sdk/MoneiSdkClientFactory.php
r3306462 r3321331 23 23 include_once WC_Monei()->plugin_path() . '/vendor/autoload.php'; 24 24 $config = Configuration::getDefaultConfiguration(); 25 $config->setUserAgent( 'MONEI/WooCommerce/' . WC_Monei()->version );26 25 $this->client = new MoneiClient( $this->apiKeyService->get_api_key(), $config ); 26 $this->client->setUserAgent( 'MONEI/WooCommerce/'. WC_Monei()->version ); 27 27 } 28 28 return $this->client; -
monei/trunk/vendor/composer/installed.php
r3307208 r3321331 2 2 'root' => array( 3 3 'name' => '__root__', 4 'pretty_version' => ' dev-master',5 'version' => ' dev-master',6 'reference' => ' 04806721f8aace5b73ee0c3aab0bf1c06f99ee40',4 'pretty_version' => '6.3.7', 5 'version' => '6.3.7.0', 6 'reference' => '2b0afda9ccb188baf158c358ddd28bf2fe2c669f', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 '__root__' => array( 14 'pretty_version' => ' dev-master',15 'version' => ' dev-master',16 'reference' => ' 04806721f8aace5b73ee0c3aab0bf1c06f99ee40',14 'pretty_version' => '6.3.7', 15 'version' => '6.3.7.0', 16 'reference' => '2b0afda9ccb188baf158c358ddd28bf2fe2c669f', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
monei/trunk/woocommerce-gateway-monei.php
r3307208 r3321331 11 11 * Plugin URI: https://wordpress.org/plugins/monei/ 12 12 * Description: Accept Card, Apple Pay, Google Pay, Bizum, PayPal and many more payment methods in your store. 13 * Version: 6.3. 613 * Version: 6.3.7 14 14 * Author: MONEI 15 15 * Author URI: https://www.monei.com/
Note: See TracChangeset
for help on using the changeset viewer.