/** * Class constructor. * * @since 1.0.0 */ public function __construct() { global $woocommerce; parent::__construct(); $this->id = 'klarna_invoice'; $this->method_title = __('Klarna Invoice', 'woocommerce-gateway-klarna'); $this->method_description = sprintf(__('With Klarna your customers can pay by invoice. Klarna works by adding extra personal information fields and then sending the details to Klarna for verification. Documentation <a href="%s" target="_blank">can be found here</a>.', 'woocommerce-gateway-klarna'), 'https://docs.woothemes.com/document/klarna/'); $this->has_fields = true; $this->order_button_text = apply_filters('klarna_order_button_text', __('Place order', 'woocommerce')); $this->pclass_type = array(2); // Load the form fields. $this->init_form_fields(); // Load the settings. $this->init_settings(); // Define user set variables include KLARNA_DIR . 'includes/variables-invoice.php'; // Load shortcodes. // This is used so that the merchant easily can modify the displayed monthly // cost text (on single product and shop page) via the settings page. include_once KLARNA_DIR . 'classes/class-klarna-shortcodes.php'; // Klarna PClasses handling. include_once KLARNA_DIR . 'classes/class-klarna-pclasses.php'; // Helper class include_once KLARNA_DIR . 'classes/class-klarna-helper.php'; $this->klarna_helper = new WC_Gateway_Klarna_Helper($this); // Test mode or Live mode if ($this->testmode == 'yes') { // Disable SSL if in testmode $this->klarna_ssl = 'false'; $this->klarna_mode = Klarna::BETA; } else { // Set SSL if used in webshop if (is_ssl()) { $this->klarna_ssl = 'true'; } else { $this->klarna_ssl = 'false'; } $this->klarna_mode = Klarna::LIVE; } // Apply filters to Country and language $this->klarna_invoice_info = apply_filters('klarna_invoice_info', ''); $this->icon = apply_filters('klarna_invoice_icon', $this->klarna_helper->get_account_icon()); $this->icon_basic = apply_filters('klarna_basic_icon', ''); // Apply filters to Klarna warning banners (NL only) $klarna_wb = $this->get_klarna_wb(); $this->klarna_wb_img_checkout = apply_filters('klarna_wb_img_checkout', $klarna_wb['img_checkout']); $this->klarna_wb_img_single_product = apply_filters('klarna_wb_img_single_product', $klarna_wb['img_single_product']); $this->klarna_wb_img_product_list = apply_filters('klarna_wb_img_product_list', $klarna_wb['img_product_list']); // Refunds support $this->supports = array('products', 'refunds'); // Actions add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_receipt_klarna_invoice', array($this, 'receipt_page')); add_action('wp_print_footer_scripts', array($this, 'footer_scripts')); // Check Klarna pending order add_action('check_klarna_pending', array($this, 'check_klarna_pending_callback')); // Add Klarna shipping info to order confirmation page and email add_filter('woocommerce_thankyou_order_received_text', array($this, 'output_klarna_details_confirmation'), 20, 2); // add_action( 'woocommerce_email_after_order_table', array( $this, 'output_klarna_details_confirmation_email' ), 10, 3 ); }
/** * Get a link to the transaction on the 3rd party gateway size (if applicable). * * @param WC_Order $order the order object. * * @return string transaction URL, or empty string. */ public function get_transaction_url($order) { // Check if order is completed if (get_post_meta($order->id, '_klarna_order_activated', true)) { if ($this->testmode == 'yes') { $this->view_transaction_url = 'https://testdrive.klarna.com/invoices/%s.pdf'; } else { $this->view_transaction_url = 'https://online.klarna.com/invoices/%s.pdf'; } } return parent::get_transaction_url($order); }