@@ -29,9 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 | along with this program. If not, see <http://www.gnu.org/licenses/>.  | 
                                                        
| 30 | 30 | */  | 
                                                        
| 31 | 31 | |
| 32 | -add_action( 'admin_init', function () { | 
                                                        |
| 33 | -	if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { | 
                                                        |
| 34 | -		add_action( 'admin_notices', function () { | 
                                                        |
| 32 | +add_action( 'admin_init', function() { | 
                                                        |
| 33 | +	if ( is_admin() && current_user_can( 'activate_plugins' ) && ( !is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && !is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { | 
                                                        |
| 34 | +		add_action( 'admin_notices', function() { | 
                                                        |
| 35 | 35 | ?>  | 
                                                        
| 36 | 36 | <div class="error">  | 
                                                        
| 37 | 37 | <p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-wp-klarna-checkout' ); ?></p>  | 
                                                        
@@ -45,14 +45,14 @@ discard block  | 
                                                    ||
| 45 | 45 | }  | 
                                                        
| 46 | 46 | } );  | 
                                                        
| 47 | 47 | |
| 48 | -if ( ! class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { | 
                                                        |
| 48 | +if ( !class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { | 
                                                        |
| 49 | 49 |  	final class EDU_KlarnaCheckout_Loader { | 
                                                        
| 50 | 50 |  		public function __construct() { | 
                                                        
| 51 | 51 | add_action( 'plugins_loaded', array( $this, 'init' ) );  | 
                                                        
| 52 | 52 | }  | 
                                                        
| 53 | 53 | |
| 54 | 54 |  		public function init() { | 
                                                        
| 55 | -			if ( ! class_exists( 'Klarna_Checkout_Connector' ) ) { | 
                                                        |
| 55 | +			if ( !class_exists( 'Klarna_Checkout_Connector' ) ) { | 
                                                        |
| 56 | 56 | require_once __DIR__ . '/klarna_kco_php_4.0.0/src/Klarna/Checkout.php';  | 
                                                        
| 57 | 57 | }  | 
                                                        
| 58 | 58 | |
@@ -29,9 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 | along with this program. If not, see <http://www.gnu.org/licenses/>.  | 
                                                        
| 30 | 30 | */  | 
                                                        
| 31 | 31 | |
| 32 | -add_action( 'admin_init', function () { | 
                                                        |
| 33 | -	if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { | 
                                                        |
| 34 | -		add_action( 'admin_notices', function () { | 
                                                        |
| 32 | +add_action( 'admin_init', function () {
 | 
                                                        |
| 33 | +	if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
 | 
                                                        |
| 34 | +		add_action( 'admin_notices', function () {
 | 
                                                        |
| 35 | 35 | ?>  | 
                                                        
| 36 | 36 | <div class="error">  | 
                                                        
| 37 | 37 | <p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-wp-klarna-checkout' ); ?></p>  | 
                                                        
@@ -39,24 +39,24 @@ discard block  | 
                                                    ||
| 39 | 39 | <?php  | 
                                                        
| 40 | 40 | } );  | 
                                                        
| 41 | 41 | deactivate_plugins( plugin_basename( __FILE__ ) );  | 
                                                        
| 42 | -		if ( isset( $_GET['activate'] ) ) { | 
                                                        |
| 42 | +		if ( isset( $_GET['activate'] ) ) {
 | 
                                                        |
| 43 | 43 | unset( $_GET['activate'] );  | 
                                                        
| 44 | 44 | }  | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | } );  | 
                                                        
| 47 | 47 | |
| 48 | -if ( ! class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { | 
                                                        |
| 49 | -	final class EDU_KlarnaCheckout_Loader { | 
                                                        |
| 50 | -		public function __construct() { | 
                                                        |
| 48 | +if ( ! class_exists( 'EDU_KlarnaCheckout_Loader' ) ) {
 | 
                                                        |
| 49 | +	final class EDU_KlarnaCheckout_Loader {
 | 
                                                        |
| 50 | +		public function __construct() {
 | 
                                                        |
| 51 | 51 | add_action( 'plugins_loaded', array( $this, 'init' ) );  | 
                                                        
| 52 | 52 | }  | 
                                                        
| 53 | 53 | |
| 54 | -		public function init() { | 
                                                        |
| 55 | -			if ( ! class_exists( 'Klarna_Checkout_Connector' ) ) { | 
                                                        |
| 54 | +		public function init() {
 | 
                                                        |
| 55 | +			if ( ! class_exists( 'Klarna_Checkout_Connector' ) ) {
 | 
                                                        |
| 56 | 56 | require_once __DIR__ . '/klarna_kco_php_4.0.0/src/Klarna/Checkout.php';  | 
                                                        
| 57 | 57 | }  | 
                                                        
| 58 | 58 | |
| 59 | -			if ( class_exists( 'EDU_Integration' ) ) { | 
                                                        |
| 59 | +			if ( class_exists( 'EDU_Integration' ) ) {
 | 
                                                        |
| 60 | 60 | |
| 61 | 61 | require_once __DIR__ . '/class-edu-klarnacheckout.php';  | 
                                                        
| 62 | 62 | |
@@ -64,7 +64,7 @@ discard block  | 
                                                    ||
| 64 | 64 | }  | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
| 67 | -		public function add_integration( $integrations ) { | 
                                                        |
| 67 | +		public function add_integration( $integrations ) {
 | 
                                                        |
| 68 | 68 | $integrations[] = 'EDU_KlarnaCheckout';  | 
                                                        
| 69 | 69 | |
| 70 | 70 | return $integrations;  | 
                                                        
@@ -1,7 +1,7 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' );  | 
                                                        
| 3 | 3 | |
| 4 | -if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) { | 
                                                        |
| 4 | +if ( !class_exists( 'EDU_KlarnaCheckout' ) ) { | 
                                                        |
| 5 | 5 |  	class EDU_KlarnaCheckout extends EDU_Integration { | 
                                                        
| 6 | 6 |  		public function __construct() { | 
                                                        
| 7 | 7 | $this->id = 'eduadmin-klarnacheckout';  | 
                                                        
@@ -65,7 +65,7 @@ discard block  | 
                                                    ||
| 65 | 65 | |
| 66 | 66 | $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact );  | 
                                                        
| 67 | 67 | |
| 68 | -			if ( ! empty( EDU()->session['klarna-order-id'] ) && ! empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 68 | +			if ( !empty( EDU()->session['klarna-order-id'] ) && !empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 69 | 69 | do_action( 'eduadmin-bookingcompleted', $ebi );  | 
                                                        
| 70 | 70 |  			} else { | 
                                                        
| 71 | 71 | do_action( 'eduadmin-processbooking', $ebi );  | 
                                                        
@@ -80,7 +80,7 @@ discard block  | 
                                                    ||
| 80 | 80 | return;  | 
                                                        
| 81 | 81 | }  | 
                                                        
| 82 | 82 | |
| 83 | -			if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { | 
                                                        |
| 83 | +			if ( !empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { | 
                                                        |
| 84 | 84 | $ebi->NoRedirect = true;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 | }  | 
                                                        
@@ -107,10 +107,10 @@ discard block  | 
                                                    ||
| 107 | 107 |  			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { | 
                                                        
| 108 | 108 | return;  | 
                                                        
| 109 | 109 | }  | 
                                                        
| 110 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 110 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 111 | 111 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
| 112 | 112 | |
| 113 | -			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 113 | +			if ( !empty( $_GET['klarna_order_id'] ) && !empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 114 | 114 |  				try { | 
                                                        
| 115 | 115 | $connector = Klarna_Checkout_Connector::create(  | 
                                                        
| 116 | 116 | $shared_secret,  | 
                                                        
@@ -176,7 +176,7 @@ discard block  | 
                                                    ||
| 176 | 176 | */  | 
                                                        
| 177 | 177 |  		public function create_checkout( $ebi = null ) { | 
                                                        
| 178 | 178 | |
| 179 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 179 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 180 | 180 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
| 181 | 181 | |
| 182 | 182 | $create = array();  | 
                                                        
@@ -194,11 +194,11 @@ discard block  | 
                                                    ||
| 194 | 194 | $booking_id = 0;  | 
                                                        
| 195 | 195 | $programme_booking_id = 0;  | 
                                                        
| 196 | 196 | |
| 197 | -			if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { | 
                                                        |
| 197 | +			if ( !empty( $ebi->EventBooking['BookingId'] ) ) { | 
                                                        |
| 198 | 198 | $booking_id = intval( $ebi->EventBooking['BookingId'] );  | 
                                                        
| 199 | 199 | }  | 
                                                        
| 200 | 200 | |
| 201 | -			if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { | 
                                                        |
| 201 | +			if ( !empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { | 
                                                        |
| 202 | 202 | $programme_booking_id = intval( $ebi->EventBooking['ProgrammeBookingId'] );  | 
                                                        
| 203 | 203 | }  | 
                                                        
| 204 | 204 | |
@@ -239,7 +239,7 @@ discard block  | 
                                                    ||
| 239 | 239 | $cart_item['name'] = $order_row['Description'];  | 
                                                        
| 240 | 240 | $cart_item['quantity'] = intval( $order_row['Quantity'] );  | 
                                                        
| 241 | 241 | |
| 242 | -				if ( ! $order_row['PriceIncVat'] ) { | 
                                                        |
| 242 | +				if ( !$order_row['PriceIncVat'] ) { | 
                                                        |
| 243 | 243 | $price_per_unit = $order_row['PricePerUnit'] * ( 1 + ( $order_row['VatPercent'] / 100 ) ) * 100;  | 
                                                        
| 244 | 244 |  				} else { | 
                                                        
| 245 | 245 | $price_per_unit = $order_row['PricePerUnit'] * 100;  | 
                                                        
@@ -276,8 +276,8 @@ discard block  | 
                                                    ||
| 276 | 276 | }  | 
                                                        
| 277 | 277 | |
| 278 | 278 |  		public function process_paymentstatus() { | 
                                                        
| 279 | -			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( $_GET['status'] ) ) { | 
                                                        |
| 280 | - $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 279 | +			if ( !empty( $_GET['klarna_order_id'] ) && !empty( $_GET['status'] ) ) { | 
                                                        |
| 280 | + $checkout_url = !checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        |
| 281 | 281 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
| 282 | 282 | |
| 283 | 283 |  				try { | 
                                                        
@@ -1,9 +1,9 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' );  | 
                                                        
| 3 | 3 | |
| 4 | -if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) { | 
                                                        |
| 5 | -	class EDU_KlarnaCheckout extends EDU_Integration { | 
                                                        |
| 6 | -		public function __construct() { | 
                                                        |
| 4 | +if ( ! class_exists( 'EDU_KlarnaCheckout' ) ) {
 | 
                                                        |
| 5 | +	class EDU_KlarnaCheckout extends EDU_Integration {
 | 
                                                        |
| 6 | +		public function __construct() {
 | 
                                                        |
| 7 | 7 | $this->id = 'eduadmin-klarnacheckout';  | 
                                                        
| 8 | 8 | $this->displayName = __( 'Klarna Checkout', 'eduadmin-wp-klarna-checkout' );  | 
                                                        
| 9 | 9 | $this->description = '';  | 
                                                        
@@ -22,7 +22,7 @@ discard block  | 
                                                    ||
| 22 | 22 | /**  | 
                                                        
| 23 | 23 | * @param $attributes  | 
                                                        
| 24 | 24 | */  | 
                                                        
| 25 | -		public function test_page( $attributes ) { | 
                                                        |
| 25 | +		public function test_page( $attributes ) {
 | 
                                                        |
| 26 | 26 | $attributes = shortcode_atts(  | 
                                                        
| 27 | 27 | array(  | 
                                                        
| 28 | 28 | 'bookingid' => 0,  | 
                                                        
@@ -32,14 +32,14 @@ discard block  | 
                                                    ||
| 32 | 32 | 'test_page'  | 
                                                        
| 33 | 33 | );  | 
                                                        
| 34 | 34 | |
| 35 | -			if ( $attributes['bookingid'] > 0 ) { | 
                                                        |
| 35 | +			if ( $attributes['bookingid'] > 0 ) {
 | 
                                                        |
| 36 | 36 | $event_booking = EDUAPI()->OData->Bookings->GetItem(  | 
                                                        
| 37 | 37 | $attributes['bookingid'],  | 
                                                        
| 38 | 38 | null,  | 
                                                        
| 39 | 39 | 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows',  | 
                                                        
| 40 | 40 | false  | 
                                                        
| 41 | 41 | );  | 
                                                        
| 42 | -			} elseif ( $attributes['programmebookingid'] > 0 ) { | 
                                                        |
| 42 | +			} elseif ( $attributes['programmebookingid'] > 0 ) {
 | 
                                                        |
| 43 | 43 | $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem(  | 
                                                        
| 44 | 44 | $attributes['programmebookingid'],  | 
                                                        
| 45 | 45 | null,  | 
                                                        
@@ -65,9 +65,9 @@ discard block  | 
                                                    ||
| 65 | 65 | |
| 66 | 66 | $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact );  | 
                                                        
| 67 | 67 | |
| 68 | -			if ( ! empty( EDU()->session['klarna-order-id'] ) && ! empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 68 | +			if ( ! empty( EDU()->session['klarna-order-id'] ) && ! empty( $_GET['klarna_order_id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) {
 | 
                                                        |
| 69 | 69 | do_action( 'eduadmin-bookingcompleted', $ebi );  | 
                                                        
| 70 | -			} else { | 
                                                        |
| 70 | +			} else {
 | 
                                                        |
| 71 | 71 | do_action( 'eduadmin-processbooking', $ebi );  | 
                                                        
| 72 | 72 | }  | 
                                                        
| 73 | 73 | }  | 
                                                        
@@ -75,12 +75,12 @@ discard block  | 
                                                    ||
| 75 | 75 | /**  | 
                                                        
| 76 | 76 | * @param EduAdmin_BookingInfo|null $ebi  | 
                                                        
| 77 | 77 | */  | 
                                                        
| 78 | -		public function intercept_booking( $ebi = null ) { | 
                                                        |
| 79 | -			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { | 
                                                        |
| 78 | +		public function intercept_booking( $ebi = null ) {
 | 
                                                        |
| 79 | +			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
 | 
                                                        |
| 80 | 80 | return;  | 
                                                        
| 81 | 81 | }  | 
                                                        
| 82 | 82 | |
| 83 | -			if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { | 
                                                        |
| 83 | +			if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) {
 | 
                                                        |
| 84 | 84 | $ebi->NoRedirect = true;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 | }  | 
                                                        
@@ -88,14 +88,14 @@ discard block  | 
                                                    ||
| 88 | 88 | /**  | 
                                                        
| 89 | 89 | * @param EduAdmin_BookingInfo|null $ebi  | 
                                                        
| 90 | 90 | */  | 
                                                        
| 91 | -		public function process_booking( $ebi = null ) { | 
                                                        |
| 92 | -			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { | 
                                                        |
| 91 | +		public function process_booking( $ebi = null ) {
 | 
                                                        |
| 92 | +			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
 | 
                                                        |
| 93 | 93 | return;  | 
                                                        
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
| 96 | 96 | $ebi->NoRedirect = true;  | 
                                                        
| 97 | 97 | |
| 98 | -			if ( empty( $_GET['klarna_order_id'] ) || empty( EDU()->session['klarna-order-id'] ) ) { | 
                                                        |
| 98 | +			if ( empty( $_GET['klarna_order_id'] ) || empty( EDU()->session['klarna-order-id'] ) ) {
 | 
                                                        |
| 99 | 99 | $checkout = $this->create_checkout( $ebi );  | 
                                                        
| 100 | 100 | |
| 101 | 101 | $snippet = $checkout['gui']['snippet'];  | 
                                                        
@@ -103,15 +103,15 @@ discard block  | 
                                                    ||
| 103 | 103 | }  | 
                                                        
| 104 | 104 | }  | 
                                                        
| 105 | 105 | |
| 106 | -		public function process_klarnaresponse() { | 
                                                        |
| 107 | -			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { | 
                                                        |
| 106 | +		public function process_klarnaresponse() {
 | 
                                                        |
| 107 | +			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
 | 
                                                        |
| 108 | 108 | return;  | 
                                                        
| 109 | 109 | }  | 
                                                        
| 110 | 110 | $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        
| 111 | 111 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
| 112 | 112 | |
| 113 | -			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) { | 
                                                        |
| 114 | -				try { | 
                                                        |
| 113 | +			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( EDU()->session['klarna-order-id'] ) && EDU()->session['klarna-order-id'] === $_GET['klarna_order_id'] ) {
 | 
                                                        |
| 114 | +				try {
 | 
                                                        |
| 115 | 115 | $connector = Klarna_Checkout_Connector::create(  | 
                                                        
| 116 | 116 | $shared_secret,  | 
                                                        
| 117 | 117 | $checkout_url  | 
                                                        
@@ -127,14 +127,15 @@ discard block  | 
                                                    ||
| 127 | 127 |  					echo "<div>{$snippet}</div>"; | 
                                                        
| 128 | 128 | EDU()->session['klarna-order-id'] = null;  | 
                                                        
| 129 | 129 | |
| 130 | -				} catch ( Klarna_Checkout_ApiErrorException $ex ) { | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | +				catch ( Klarna_Checkout_ApiErrorException $ex ) {
 | 
                                                        |
| 131 | 132 | EDU()->write_debug( $ex->getMessage() );  | 
                                                        
| 132 | 133 | EDU()->write_debug( $ex->getPayload() );  | 
                                                        
| 133 | 134 | }  | 
                                                        
| 134 | 135 | }  | 
                                                        
| 135 | 136 | }  | 
                                                        
| 136 | 137 | |
| 137 | -		public function init_form_fields() { | 
                                                        |
| 138 | +		public function init_form_fields() {
 | 
                                                        |
| 138 | 139 | $this->setting_fields = array(  | 
                                                        
| 139 | 140 | 'enabled' => array(  | 
                                                        
| 140 | 141 | 'title' => __( 'Enabled', 'edauadmin-wp-klarna-checkout' ),  | 
                                                        
@@ -174,7 +175,7 @@ discard block  | 
                                                    ||
| 174 | 175 | *  | 
                                                        
| 175 | 176 | * @return Klarna_Checkout_Order|null  | 
                                                        
| 176 | 177 | */  | 
                                                        
| 177 | -		public function create_checkout( $ebi = null ) { | 
                                                        |
| 178 | +		public function create_checkout( $ebi = null ) {
 | 
                                                        |
| 178 | 179 | |
| 179 | 180 | $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        
| 180 | 181 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
@@ -194,11 +195,11 @@ discard block  | 
                                                    ||
| 194 | 195 | $booking_id = 0;  | 
                                                        
| 195 | 196 | $programme_booking_id = 0;  | 
                                                        
| 196 | 197 | |
| 197 | -			if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { | 
                                                        |
| 198 | +			if ( ! empty( $ebi->EventBooking['BookingId'] ) ) {
 | 
                                                        |
| 198 | 199 | $booking_id = intval( $ebi->EventBooking['BookingId'] );  | 
                                                        
| 199 | 200 | }  | 
                                                        
| 200 | 201 | |
| 201 | -			if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { | 
                                                        |
| 202 | +			if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) {
 | 
                                                        |
| 202 | 203 | $programme_booking_id = intval( $ebi->EventBooking['ProgrammeBookingId'] );  | 
                                                        
| 203 | 204 | }  | 
                                                        
| 204 | 205 | |
@@ -232,16 +233,16 @@ discard block  | 
                                                    ||
| 232 | 233 | $create['cart'] = array();  | 
                                                        
| 233 | 234 | $create['cart']['items'] = array();  | 
                                                        
| 234 | 235 | |
| 235 | -			foreach ( $ebi->EventBooking['OrderRows'] as $order_row ) { | 
                                                        |
| 236 | +			foreach ( $ebi->EventBooking['OrderRows'] as $order_row ) {
 | 
                                                        |
| 236 | 237 | $cart_item = array();  | 
                                                        
| 237 | 238 | |
| 238 | 239 | $cart_item['reference'] = $order_row['ItemNumber'];  | 
                                                        
| 239 | 240 | $cart_item['name'] = $order_row['Description'];  | 
                                                        
| 240 | 241 | $cart_item['quantity'] = intval( $order_row['Quantity'] );  | 
                                                        
| 241 | 242 | |
| 242 | -				if ( ! $order_row['PriceIncVat'] ) { | 
                                                        |
| 243 | +				if ( ! $order_row['PriceIncVat'] ) {
 | 
                                                        |
| 243 | 244 | $price_per_unit = $order_row['PricePerUnit'] * ( 1 + ( $order_row['VatPercent'] / 100 ) ) * 100;  | 
                                                        
| 244 | -				} else { | 
                                                        |
| 245 | +				} else {
 | 
                                                        |
| 245 | 246 | $price_per_unit = $order_row['PricePerUnit'] * 100;  | 
                                                        
| 246 | 247 | }  | 
                                                        
| 247 | 248 | |
@@ -252,7 +253,7 @@ discard block  | 
                                                    ||
| 252 | 253 | $create['cart']['items'][] = $cart_item;  | 
                                                        
| 253 | 254 | }  | 
                                                        
| 254 | 255 | |
| 255 | -			try { | 
                                                        |
| 256 | +			try {
 | 
                                                        |
| 256 | 257 | $connector = Klarna_Checkout_Connector::create(  | 
                                                        
| 257 | 258 | $shared_secret,  | 
                                                        
| 258 | 259 | $checkout_url  | 
                                                        
@@ -267,7 +268,8 @@ discard block  | 
                                                    ||
| 267 | 268 | EDU()->session['klarna-order-id'] = $order_id;  | 
                                                        
| 268 | 269 | |
| 269 | 270 | return $order;  | 
                                                        
| 270 | -			} catch ( Klarna_Checkout_ApiErrorException $ex ) { | 
                                                        |
| 271 | + }  | 
                                                        |
| 272 | +			catch ( Klarna_Checkout_ApiErrorException $ex ) {
 | 
                                                        |
| 271 | 273 | EDU()->write_debug( $ex->getMessage() );  | 
                                                        
| 272 | 274 | EDU()->write_debug( $ex->getPayload() );  | 
                                                        
| 273 | 275 | |
@@ -275,12 +277,12 @@ discard block  | 
                                                    ||
| 275 | 277 | }  | 
                                                        
| 276 | 278 | }  | 
                                                        
| 277 | 279 | |
| 278 | -		public function process_paymentstatus() { | 
                                                        |
| 279 | -			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( $_GET['status'] ) ) { | 
                                                        |
| 280 | +		public function process_paymentstatus() {
 | 
                                                        |
| 281 | +			if ( ! empty( $_GET['klarna_order_id'] ) && ! empty( $_GET['status'] ) ) {
 | 
                                                        |
| 280 | 282 | $checkout_url = ! checked( $this->get_option( 'test_mode', 'no' ), '1', false ) ? Klarna_Checkout_Connector::BASE_URL : Klarna_Checkout_Connector::BASE_TEST_URL;  | 
                                                        
| 281 | 283 | $shared_secret = $this->get_option( 'shared_secret', '' );  | 
                                                        
| 282 | 284 | |
| 283 | -				try { | 
                                                        |
| 285 | +				try {
 | 
                                                        |
| 284 | 286 | $connector = Klarna_Checkout_Connector::create(  | 
                                                        
| 285 | 287 | $shared_secret,  | 
                                                        
| 286 | 288 | $checkout_url  | 
                                                        
@@ -296,7 +298,7 @@ discard block  | 
                                                    ||
| 296 | 298 | $programme_booking_id = intval( $_GET['programme_booking_id'] );  | 
                                                        
| 297 | 299 | |
| 298 | 300 | |
| 299 | -					if ( 'checkout_complete' === $order['status'] ) { | 
                                                        |
| 301 | +					if ( 'checkout_complete' === $order['status'] ) {
 | 
                                                        |
| 300 | 302 | |
| 301 | 303 | $patch_booking = new stdClass();  | 
                                                        
| 302 | 304 | $patch_booking->Paid = true;  | 
                                                        
@@ -304,14 +306,14 @@ discard block  | 
                                                    ||
| 304 | 306 | // We're setting this as a Card Payment, so that our service in the background will remove it if it doesn't get paid in time (15 minute slot)  | 
                                                        
| 305 | 307 | $patch_booking->PaymentMethodId = 2;  | 
                                                        
| 306 | 308 | |
| 307 | -						if ( $booking_id > 0 ) { | 
                                                        |
| 309 | +						if ( $booking_id > 0 ) {
 | 
                                                        |
| 308 | 310 | EDUAPI()->REST->Booking->PatchBooking(  | 
                                                        
| 309 | 311 | $booking_id,  | 
                                                        
| 310 | 312 | $patch_booking  | 
                                                        
| 311 | 313 | );  | 
                                                        
| 312 | 314 | }  | 
                                                        
| 313 | 315 | |
| 314 | -						if ( $programme_booking_id > 0 ) { | 
                                                        |
| 316 | +						if ( $programme_booking_id > 0 ) {
 | 
                                                        |
| 315 | 317 | EDUAPI()->REST->ProgrammeBooking->PatchBooking(  | 
                                                        
| 316 | 318 | $programme_booking_id,  | 
                                                        
| 317 | 319 | $patch_booking  | 
                                                        
@@ -323,7 +325,8 @@ discard block  | 
                                                    ||
| 323 | 325 | $order->update( $update );  | 
                                                        
| 324 | 326 | }  | 
                                                        
| 325 | 327 | exit( 0 );  | 
                                                        
| 326 | -				} catch ( Klarna_Checkout_ApiErrorException $ex ) { | 
                                                        |
| 328 | + }  | 
                                                        |
| 329 | +				catch ( Klarna_Checkout_ApiErrorException $ex ) {
 | 
                                                        |
| 327 | 330 | EDU()->write_debug( $ex->getMessage() );  | 
                                                        
| 328 | 331 | EDU()->write_debug( $ex->getPayload() );  | 
                                                        
| 329 | 332 | exit( 1 );  |