Skip to content

Commit

Permalink
Update chargily.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Developer authored Apr 3, 2024
1 parent 174da8a commit 3ff33d3
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions chargily.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*Description: The easiest and free way to integrate e-payment API through EDAHABIA of Algerie Poste and CIB of SATIM into your Wordpress/WooCommerce platform.
*Author: Chargily
Author URI: https://chargily.com
*Version: 2.1.8
*Version: 2.1.9
*Text Domain: chargilytextdomain
*Domain Path: /languages
*/
Expand Down Expand Up @@ -96,20 +96,27 @@ function chargilyv2_add_rewrite_rule() {
register_activation_hook(__FILE__, 'update_chargily_pay_settings_data');
add_action('upgrader_process_complete', 'update_chargily_pay_settings_data', 10, 2);
function update_chargily_pay_settings_data() {
$test_mode = 'yes' === get_option('woocommerce_chargily_pay_settings')['test_mode'];
$live_api_key_present = !empty(get_option('woocommerce_chargily_pay_settings')['Chargily_Gateway_api_key_v2_live']);
$live_api_secret_present = !empty(get_option('woocommerce_chargily_pay_settings')['Chargily_Gateway_api_secret_v2_live']);
$test_api_key_present = !empty(get_option('woocommerce_chargily_pay_settings')['Chargily_Gateway_api_key_v2_test']);
$test_api_secret_present = !empty(get_option('woocommerce_chargily_pay_settings')['Chargily_Gateway_api_secret_v2_test']);

$data = array(
'testMode' => $test_mode,
'liveApiKeyPresent' => $live_api_key_present,
'liveApiSecretPresent' => $live_api_secret_present,
'testApiKeyPresent' => $test_api_key_present,
'testApiSecretPresent' => $test_api_secret_present,

);
$file_path = plugin_dir_path(__FILE__) . '/templates/method-v2/chargily_data.json';
file_put_contents($file_path, json_encode($data));
$woocommerce_settings = get_option('woocommerce_chargily_pay_settings');
if (empty($woocommerce_settings)) {
$test_mode = false;
$live_api_key_present = false;
$live_api_secret_present = false;
$test_api_key_present = false;
$test_api_secret_present = false;
} else {
$test_mode = 'yes' === $woocommerce_settings['test_mode'];
$live_api_key_present = !empty($woocommerce_settings['Chargily_Gateway_api_key_v2_live']);
$live_api_secret_present = !empty($woocommerce_settings['Chargily_Gateway_api_secret_v2_live']);
$test_api_key_present = !empty($woocommerce_settings['Chargily_Gateway_api_key_v2_test']);
$test_api_secret_present = !empty($woocommerce_settings['Chargily_Gateway_api_secret_v2_test']);
}
$data = array(
'testMode' => $test_mode,
'liveApiKeyPresent' => $live_api_key_present,
'liveApiSecretPresent' => $live_api_secret_present,
'testApiKeyPresent' => $test_api_key_present,
'testApiSecretPresent' => $test_api_secret_present,
);
$file_path = plugin_dir_path(__FILE__) . '/templates/method-v2/chargily_data.json';
file_put_contents($file_path, json_encode($data));
}

0 comments on commit 3ff33d3

Please sign in to comment.