public function process_admin_options() { $post_data = $this->get_post_data(); $mode = 'live'; if ($post_data['woocommerce_' . $this->id . '_sandbox'] == '1') { $mode = 'test'; } $this->merchant_id = $post_data['woocommerce_' . $this->id . '_' . $mode . '_merchant_id']; $this->private_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_private_key']; $this->publishable_key = $post_data['woocommerce_' . $this->id . '_' . $mode . '_publishable_key']; $env = $mode == 'live' ? 'Producton' : 'Sandbox'; if ($this->merchant_id == '' || $this->private_key == '' || $this->publishable_key == '') { $settings = new WC_Admin_Settings(); $settings->add_error('You need to enter "' . $env . '" credentials if you want to use this plugin in this mode.'); } else { $this->createWebhook(); } return parent::process_admin_options(); }
/** * Save the admin options, ask the loader to clone to siblings */ public function process_admin_options() { if (parent::process_admin_options()) { WC_PayPal_Braintree_Loader::getInstance()->clone_fields_from_id($this->id); } }
function process_admin_options() { if (!parent::process_admin_options()) { return false; } require_once plugin_dir_path(__FILE__) . 'coinbase-php' . DIRECTORY_SEPARATOR . 'Coinbase.php'; $api_key = $this->get_option('apiKey'); $api_secret = $this->get_option('apiSecret'); // Validate merchant API key try { $coinbase = Coinbase::withApiKey($api_key, $api_secret); $user = $coinbase->getUser(); update_option("coinbase_account_email", $user->email); update_option("coinbase_error_message", false); } catch (Exception $e) { $error_message = $e->getMessage(); update_option("coinbase_account_email", false); update_option("coinbase_error_message", $error_message); return; } }
public function process_admin_options() { // Call parent parent::process_admin_options(); if (isset($_POST) && is_array($_POST)) { $bwwc_settings = BWWC__get_settings(); if (!isset($bwwc_settings['gateway_settings']) || !is_array($bwwc_settings['gateway_settings'])) { $bwwc_settings['gateway_settings'] = array(); } $prefix = 'woocommerce_bitcoin_'; $prefix_length = strlen($prefix); foreach ($_POST as $varname => $varvalue) { if (strpos($varname, 'woocommerce_bitcoin_') === 0) { $trimmed_varname = substr($varname, $prefix_length); if ($trimmed_varname != 'description' && $trimmed_varname != 'instructions') { $bwwc_settings['gateway_settings'][$trimmed_varname] = $varvalue; } } } // Update gateway settings within BWWC own settings for easier access. BWWC__update_settings($bwwc_settings); } }
/** * Do some additonal validation before saving options via the API. */ public function process_admin_options() { // Validate logo $logo_image_url = wc_clean($_POST['woocommerce_ppec_paypal_logo_image_url']); if (!empty($logo_image_url) && !preg_match('/https?:\\/\\/[a-zA-Z0-9][a-zA-Z0-9.-]+[a-zA-Z0-9](\\/[a-zA-Z0-9.\\/?&%#]*)?/', $logo_image_url)) { WC_Admin_Settings::add_error(__('Error: The logo image URL you provided is not valid and cannot be used.', 'woocommerce-gateway-paypal-express-checkout')); unset($_POST['woocommerce_ppec_paypal_logo_image_url']); } // If a certificate has been uploaded, read the contents and save that string instead. if (array_key_exists('woocommerce_ppec_paypal_api_certificate', $_FILES) && array_key_exists('tmp_name', $_FILES['woocommerce_ppec_paypal_api_certificate']) && array_key_exists('size', $_FILES['woocommerce_ppec_paypal_api_certificate']) && $_FILES['woocommerce_ppec_paypal_api_certificate']['size']) { $_POST['woocommerce_ppec_paypal_api_certificate'] = base64_encode(file_get_contents($_FILES['woocommerce_ppec_paypal_api_certificate']['tmp_name'])); unlink($_FILES['woocommerce_ppec_paypal_api_certificate']['tmp_name']); unset($_FILES['woocommerce_ppec_paypal_api_certificate']); } else { $_POST['woocommerce_ppec_paypal_api_certificate'] = $this->get_option('api_certificate'); } if (array_key_exists('woocommerce_ppec_paypal_sandbox_api_certificate', $_FILES) && array_key_exists('tmp_name', $_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']) && array_key_exists('size', $_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']) && $_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']['size']) { $_POST['woocommerce_ppec_paypal_sandbox_api_certificate'] = base64_encode(file_get_contents($_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']['tmp_name'])); unlink($_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']['tmp_name']); unset($_FILES['woocommerce_ppec_paypal_sandbox_api_certificate']); } else { $_POST['woocommerce_ppec_paypal_sandbox_api_certificate'] = $this->get_option('sandbox_api_certificate'); } parent::process_admin_options(); // Validate credentials $this->validate_active_credentials(); }
/** * Procesamos los datos enviados en el panel de configuración. * Conversión de los certificados en texto a fichero. * */ public function process_admin_options() { if (!is_dir(__DIR__ . '/certificados')) { $res = mkdir(__DIR__ . '/certificados', 0755, true); if (!$res) { throw new Exception(__('The directory is not writeable, check permisions', 'woocriptopay')); } } $finfo = new finfo(FILEINFO_MIME_TYPE); foreach ($_FILES as $key => $file) { if (!empty($file['name']) && substr($file['name'], 0, 10) == "CriptoPay_") { if ($finfo->file($file['tmp_name']) == "text/plain" && (substr($file['name'], -3) == "crt" || substr($file['name'], -3) == "key")) { $move = move_uploaded_file($file['tmp_name'], __DIR__ . '/certificados/' . $file['name']); } else { throw new Exception(__("File " . $file['name'] . " incorrect format " . $finfo->file($file['tmp_name'], 'woocriptopay'))); } } } parent::process_admin_options(); }
public function process_admin_options() { $target_dir = IMAGE_FOLDER_URL; $target_file = $target_dir . basename($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]); if ($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["name"]) { try { move_uploaded_file($_FILES["woocommerce_Pwacheckout_pwa_btn_img"]["tmp_name"], $target_file); chmod($target_file, 0777); } catch (Exception $e) { echo 'error in uploading file'; } } $value = isset($_POST['woocommerce_Pwacheckout_pwa_delete_img']) ? $_POST['woocommerce_Pwacheckout_pwa_delete_img'] : 0; if (!$value && $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name']) { $_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = IMAGE_FOLDER_HTTPURL . $_FILES['woocommerce_Pwacheckout_pwa_btn_img']['name']; } elseif ($value) { $_POST['woocommerce_Pwacheckout_pwa_btn_img_hidden'] = ''; } $_POST['woocommerce_Pwacheckout_pwa_delete_img'] = 0; parent::process_admin_options(); }