/** * 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)); }
/** * @param WC_Order $order * @param Mollie_API_Object_Payment $payment * @param bool $admin_instructions * @param bool $plain_text * @return string|null */ protected function getInstructions(WC_Order $order, Mollie_API_Object_Payment $payment, $admin_instructions, $plain_text) { $instructions = ''; if (!$payment->details) { return null; } $data_helper = Mollie_WC_Plugin::getDataHelper(); if ($payment->isPaid()) { $instructions .= sprintf(__('Payment completed by <strong>%s</strong> (IBAN: %s, BIC: %s)', 'mollie-payments-for-woocommerce'), $payment->details->consumerName, implode(' ', str_split($payment->details->consumerAccount, 4)), $payment->details->consumerBic); } elseif ($data_helper->hasOrderStatus($order, 'on-hold')) { if (!$admin_instructions) { $instructions .= __('Please complete your payment by transferring the total amount to the following bank account:', 'mollie-payments-for-woocommerce') . "\n\n\n"; } /* translators: Placeholder 1: 'Stichting Mollie Payments' */ $instructions .= sprintf(__('Beneficiary: %s', 'mollie-payments-for-woocommerce'), $payment->details->bankName) . "\n"; $instructions .= sprintf(__('IBAN: <strong>%s</strong>', 'mollie-payments-for-woocommerce'), implode(' ', str_split($payment->details->bankAccount, 4))) . "\n"; $instructions .= sprintf(__('BIC: %s', 'mollie-payments-for-woocommerce'), $payment->details->bankBic) . "\n"; if ($admin_instructions) { /* translators: Placeholder 1: Payment reference e.g. RF49-0000-4716-6216 (SEPA) or +++513/7587/59959+++ (Belgium) */ $instructions .= sprintf(__('Payment reference: %s', 'mollie-payments-for-woocommerce'), $payment->details->transferReference) . "\n"; } else { /* translators: Placeholder 1: Payment reference e.g. RF49-0000-4716-6216 (SEPA) or +++513/7587/59959+++ (Belgium) */ $instructions .= sprintf(__('Please provide the payment reference <strong>%s</strong>', 'mollie-payments-for-woocommerce'), $payment->details->transferReference) . "\n"; } if (!empty($payment->expiryPeriod) && class_exists('DateTime') && class_exists('DateInterval')) { $expiry_date = DateTime::createFromFormat('U', time()); $expiry_date->add(new DateInterval($payment->expiryPeriod)); if ($admin_instructions) { $instructions .= "\n" . sprintf(__('The payment will expire on <strong>%s</strong>.', 'mollie-payments-for-woocommerce'), $expiry_date->format(wc_date_format())) . "\n"; } else { $instructions .= "\n" . sprintf(__('The payment will expire on <strong>%s</strong>. Please make sure you transfer the total amount before this date.', 'mollie-payments-for-woocommerce'), $expiry_date->format(wc_date_format())) . "\n"; } } } return $instructions; }
/** * @return Mollie_API_Object_Method|null */ public function getMollieMethod() { try { $test_mode = Mollie_WC_Plugin::getSettingsHelper()->isTestModeEnabled(); return Mollie_WC_Plugin::getDataHelper()->getPaymentMethod($test_mode, $this->getMollieMethodId()); } catch (Mollie_WC_Exception_InvalidApiKey $e) { } return null; }
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; }
/** * @param WC_Order $order */ public static function onOrderDetails(WC_Order $order) { if (is_order_received_page()) { /** * Do not show instruction again below details on order received page * Instructions already displayed on top of order received page by $gateway->thankyou_page() * * @see Mollie_WC_Gateway_Abstract::thankyou_page */ return; } $gateway = Mollie_WC_Plugin::getDataHelper()->getWcPaymentGatewayByOrder($order); if (!$gateway || !$gateway instanceof Mollie_WC_Gateway_Abstract) { return; } /** @var Mollie_WC_Gateway_Abstract $gateway */ $gateway->displayInstructions($order); }