|
| 1 | +<?php |
| 2 | +defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' ); |
| 3 | + |
| 4 | +if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) { |
| 5 | + class EDU_KlarnaCheckout extends EDU_Integration { |
| 6 | + public function __construct() { |
| 7 | + $this->id = 'eduadmin-klarnacheckout'; |
| 8 | + $this->displayName = __( 'Klarna Checkout', 'eduadmin-wp-klarna-checkout' ); |
| 9 | + $this->description = ''; |
| 10 | + |
| 11 | + $this->init_form_fields(); |
| 12 | + $this->init_settings(); |
| 13 | + |
| 14 | + add_action( 'eduadmin-checkpaymentplugins', array( $this, 'intercept_booking' ) ); |
| 15 | + add_action( 'eduadmin-processbooking', array( $this, 'process_booking' ) ); |
| 16 | + add_action( 'wp_loaded', array( $this, 'process_klarnaresponse' ) ); |
| 17 | + } |
| 18 | + |
| 19 | + public function intercept_booking() { |
| 20 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
| 21 | + return; |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + public function process_booking() { |
| 26 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
| 27 | + return; |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + public function process_klarnaresponse() { |
| 32 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
| 33 | + return; |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + public function init_form_fields() { |
| 38 | + $this->setting_fields = array( |
| 39 | + 'enabled' => array( |
| 40 | + 'title' => __( 'Enabled', 'edauadmin-wp-klarna-checkout' ), |
| 41 | + 'type' => 'checkbox', |
| 42 | + 'description' => __( 'Enables/Disabled the integration with Klarna Checkout', 'eduadmin-wp-klarna-checkout' ), |
| 43 | + 'default' => 'no', |
| 44 | + ), |
| 45 | + 'username' => array( |
| 46 | + 'title' => __( 'Username (UID)', 'eduadmin-wp-klarna-checkout' ), |
| 47 | + 'type' => 'text', |
| 48 | + 'description' => __( 'The API credential username from Klarna', 'eduadmin-wp-klarna-checkout' ), |
| 49 | + 'default' => '', |
| 50 | + ), |
| 51 | + 'password' => array( |
| 52 | + 'title' => __( 'Password', 'eduadmin-wp-klarna-checkout' ), |
| 53 | + 'type' => 'password', |
| 54 | + 'description' => __( 'Password for the API credentials from Klarna', 'eduadmin-wp-klarna-checkout' ), |
| 55 | + 'default' => '', |
| 56 | + ), |
| 57 | + ); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments