/** * Display fields below payment method in checkout */ public function payment_fields() { // Display description above issuers parent::payment_fields(); $test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled(); $ideal_issuers = Mollie_WC_Plugin::getDataHelper()->getIssuers($test_mode, $this->getMollieMethodId()); $selected_issuer = $this->getSelectedIssuer(); $html = '<select name="' . Mollie_WC_Plugin::PLUGIN_ID . '_issuer_' . $this->id . '">'; $html .= '<option value=""></option>'; foreach ($ideal_issuers as $issuer) { $html .= '<option value="' . esc_attr($issuer->id) . '"' . ($selected_issuer == $issuer->id ? ' selected=""' : '') . '>' . esc_html($issuer->name) . '</option>'; } $html .= '</select>'; echo wpautop(wptexturize($html)); }
/** * @throws Mollie_WC_Exception_CouldNotConnectToMollie */ public function getMollieApiStatus() { try { // Is test mode enabled? $test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled(); $api_helper = Mollie_WC_Plugin::getApiHelper(); $api_client = $api_helper->getApiClient($test_mode); // Try to load Mollie issuers $api_client->issuers->all(); } catch (Mollie_API_Exception $e) { throw new Mollie_WC_Exception_CouldNotConnectToMollie($e->getMessage(), 0, $e); } }
/** * @return bool */ protected function isValidApiKeyProvided() { $settings = Mollie_WC_Plugin::getSettingsHelper(); $test_mode = $settings->isTestModeEnabled(); $api_key = $settings->getApiKey($test_mode); return !empty($api_key) && preg_match('/^(live|test)_\\w+$/', $api_key); }
protected function getMollieMethods() { $content = ''; try { $data_helper = Mollie_WC_Plugin::getDataHelper(); $settings_helper = Mollie_WC_Plugin::getSettingsHelper(); // Is Test mode enabled? $test_mode = $settings_helper->isTestModeEnabled(); if (isset($_GET['refresh-methods']) && check_admin_referer('refresh-methods')) { /* Reload active Mollie methods */ $data_helper->getPaymentMethods($test_mode, $use_cache = false); } $icon_available = ' <span style="color: green; cursor: help;" title="' . __('Gateway enabled', 'mollie-payments-for-woocommerce') . '">' . strtolower(__('Enabled', 'mollie-payments-for-woocommerce')) . '</span>'; $icon_no_available = ' <span style="color: red; cursor: help;" title="' . __('Gateway disabled', 'mollie-payments-for-woocommerce') . '">' . strtolower(__('Disabled', 'mollie-payments-for-woocommerce')) . '</span>'; $content .= '<br /><br />'; if ($test_mode) { $content .= '<strong>' . __('Test mode enabled.', 'mollie-payments-for-woocommerce') . '</strong> '; } $content .= sprintf(__('The following payment methods are activated in your %sMollie profile%s:', 'mollie-payments-for-woocommerce'), '<a href="https://www.mollie.com/beheer/account/profielen/" target="_blank">', '</a>'); $refresh_methods_url = wp_nonce_url(add_query_arg(array('refresh-methods' => 1)), 'refresh-methods') . '#' . Mollie_WC_Plugin::PLUGIN_ID; $content .= ' (<a href="' . esc_attr($refresh_methods_url) . '">' . strtolower(__('Refresh', 'mollie-payments-for-woocommerce')) . '</a>)'; $content .= '<ul style="width: 1000px">'; foreach (Mollie_WC_Plugin::$GATEWAYS as $gateway_classname) { $gateway = new $gateway_classname(); if ($gateway instanceof Mollie_WC_Gateway_Abstract) { $content .= '<li style="float: left; width: 33%;">'; $content .= '<img src="' . esc_attr($gateway->getIconUrl()) . '" alt="' . esc_attr($gateway->getDefaultTitle()) . '" title="' . esc_attr($gateway->getDefaultTitle()) . '" style="width: 25px; vertical-align: bottom;" />'; $content .= ' ' . esc_html($gateway->getDefaultTitle()); if ($gateway->is_available()) { $content .= $icon_available; } else { $content .= $icon_no_available; } $content .= ' <a href="' . $this->getGatewaySettingsUrl($gateway_classname) . '">' . strtolower(__('Edit', 'mollie-payments-for-woocommerce')) . '</a>'; $content .= '</li>'; } } $content .= '</ul>'; $content .= '<div class="clear"></div>'; } catch (Mollie_WC_Exception_InvalidApiKey $e) { // Ignore } return $content; }