Completed
Push — master ( 0aeb50...c7919b )
by Chris
02:47
created
eduadmin-wordpress-sveawebpay.php 1 patch
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  */
37 37
 
38 38
 add_action( 'admin_init', 'checkForEduAdminPlugin' );
39
-function checkForEduAdminPlugin() {
40
-	if ( is_admin() && current_user_can( 'activate_plugins' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) {
41
-		add_action( 'admin_notices', function() {
39
+function checkForEduAdminPlugin() {
40
+	if ( is_admin() && current_user_can( 'activate_plugins' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) {
41
+		add_action( 'admin_notices', function() {
42 42
 			?>
43 43
 			<div class="error">
44 44
 			<p><?php _e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-sveawebpay' ); ?></p>
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		} );
47 47
 		deactivate_plugins( plugin_basename( __FILE__ ) );
48 48
 
49
-		if ( isset( $_GET['activate'] ) ) {
49
+		if ( isset( $_GET['activate'] ) ) {
50 50
 			unset( $_GET['activate'] );
51 51
 		}
52 52
 	}
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 
55 55
 if ( ! class_exists( 'EDU_SveaWebPay_Loader' ) ):
56 56
 
57
-	final class EDU_SveaWebPay_Loader {
58
-		public function __construct() {
57
+	final class EDU_SveaWebPay_Loader {
58
+		public function __construct() {
59 59
 			add_action( 'plugins_loaded', array( $this, 'init' ) );
60 60
 		}
61 61
 
62
-		public function init() {
63
-			if ( class_exists( 'EDU_Integration' ) ) {
62
+		public function init() {
63
+			if ( class_exists( 'EDU_Integration' ) ) {
64 64
 				require_once( __DIR__ . '/vendor/autoload.php' ); // Load dependencies
65 65
 				require_once( __DIR__ . '/class/class-edu-sveawebpay.php' );
66 66
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			}
69 69
 		}
70 70
 
71
-		public function add_integration( $integrations ) {
71
+		public function add_integration( $integrations ) {
72 72
 			$integrations[] = 'EDU_SveaWebPay';
73 73
 
74 74
 			return $integrations;
Please login to merge, or discard this patch.
class/class-edu-sveawebpay.php 1 patch
Braces   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway
13 13
 	 */
14
-	class EDU_SveaWebPay extends EDU_Integration {
14
+	class EDU_SveaWebPay extends EDU_Integration {
15 15
 		/**
16 16
 		 * Constructor
17 17
 		 */
18
-		public function __construct() {
18
+		public function __construct() {
19 19
 			$this->id          = 'eduadmin-sveawebpay';
20 20
 			$this->displayName = __( 'Svea Webpay', 'eduadmin-sveawebpay' );
21 21
 			$this->description = '';
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		/**
32 32
 		 * Initializes the settingsfields
33 33
 		 */
34
-		public function init_form_fields() {
34
+		public function init_form_fields() {
35 35
 			$this->setting_fields = array(
36 36
 				'enabled'         => array(
37 37
 					'title'       => __( 'Enabled', 'eduadmin-sveawebpay' ),
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 *
65 65
 		 */
66
-		public function process_svearesponse() {
67
-			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
66
+		public function process_svearesponse() {
67
+			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
68 68
 				return;
69 69
 			}
70
-			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
70
+			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
71 71
 				$filter = new XFiltering();
72 72
 				$f      = new XFilter( 'EventCustomerLnkID', '=', $_REQUEST['edu-thankyou'] );
73 73
 				$filter->AddItem( $f );
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 				$selectedCountry = 'SE';
94 94
 
95 95
 				$invoiceCountry = $ebi->Customer->InvoiceCountry;
96
-				if ( empty( $invoiceCountry ) ) {
96
+				if ( empty( $invoiceCountry ) ) {
97 97
 					$invoiceCountry = $ebi->Customer->Country;
98 98
 				}
99 99
 
100
-				foreach ( $countries as $country ) {
101
-					if ( $invoiceCountry == $country->CountryName ) {
100
+				foreach ( $countries as $country ) {
101
+					if ( $invoiceCountry == $country->CountryName ) {
102 102
 						$selectedCountry = $country->CountryCode;
103 103
 						break;
104 104
 					}
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
 				$response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse();
110 110
 
111
-				if ( $response->accepted ) {
111
+				if ( $response->accepted ) {
112 112
 					EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
113
-				} else {
113
+				} else {
114 114
 					EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
115 115
 				}
116 116
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 		/**
127 127
 		 * @param $bookingInfo EduAdminBookingInfo
128 128
 		 */
129
-		public function process_booking( $bookingInfo = null ) {
130
-			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
129
+		public function process_booking( $bookingInfo = null ) {
130
+			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
131 131
 				return;
132 132
 			}
133
-			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
133
+			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
134 134
 				$bookingInfo->NoRedirect = true;
135 135
 
136 136
 				$countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' );
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 				$selectedLocale  = 'sv-SE';
140 140
 
141 141
 				$invoiceCountry = $bookingInfo->Customer->InvoiceCountry;
142
-				if ( empty( $invoiceCountry ) ) {
142
+				if ( empty( $invoiceCountry ) ) {
143 143
 					$invoiceCountry = $bookingInfo->Customer->Country;
144 144
 				}
145 145
 
146
-				foreach ( $countries as $country ) {
147
-					if ( $invoiceCountry == $country->CountryName ) {
146
+				foreach ( $countries as $country ) {
147
+					if ( $invoiceCountry == $country->CountryName ) {
148 148
 						$selectedCountry = $country->CountryCode;
149
-						if ( ! empty( $country->CultureName ) ) {
149
+						if ( ! empty( $country->CultureName ) ) {
150 150
 							$selectedLocale = $country->CultureName;
151 151
 						}
152 152
 						break;
@@ -170,37 +170,37 @@  discard block
 block discarded – undo
170 170
 
171 171
 				$customer = WebPayItem::companyCustomer();
172 172
 
173
-				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
173
+				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
174 174
 					$customer->setCompanyName( $bookingInfo->Customer->InvoiceName );
175
-				} else {
175
+				} else {
176 176
 					$customer->setCompanyName( $bookingInfo->Customer->CustomerName );
177 177
 				}
178 178
 
179
-				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
179
+				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
180 180
 					$customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 );
181
-				} else {
181
+				} else {
182 182
 					$customer->setStreetAddress( $bookingInfo->Customer->Address1 );
183 183
 				}
184 184
 
185
-				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
185
+				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
186 186
 					$customer->setZipCode( $bookingInfo->Customer->InvoiceZip );
187
-				} else {
187
+				} else {
188 188
 					$customer->setZipCode( $bookingInfo->Customer->Zip );
189 189
 				}
190 190
 
191
-				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
191
+				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
192 192
 					$customer->setLocality( $bookingInfo->Customer->InvoiceCity );
193
-				} else {
193
+				} else {
194 194
 					$customer->setLocality( $bookingInfo->Customer->City );
195 195
 				}
196 196
 
197
-				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
197
+				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
198 198
 					$customer->setPhoneNumber( $bookingInfo->Customer->Phone );
199 199
 				}
200 200
 
201
-				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
201
+				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
202 202
 					$customer->setEmail( $bookingInfo->Customer->InvoiceEmail );
203
-				} else {
203
+				} else {
204 204
 					$customer->setEmail( $bookingInfo->Customer->Email );
205 205
 				}
206 206
 
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 					->setCancelUrl( apply_filters( 'eduadmin-cancel-url', $defaultCancel ) )
227 227
 					->getPaymentUrl();
228 228
 
229
-				if ( $wpForm->accepted ) {
230
-					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
229
+				if ( $wpForm->accepted ) {
230
+					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
231 231
 						echo '<script type="text/javascript">location.href = "' . $wpForm->url . '";</script>';
232
-					} else {
232
+					} else {
233 233
 						echo '<script type="text/javascript">location.href = "' . $wpForm->testurl . '";</script>';
234 234
 					}
235
-				} else {
236
-					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
235
+				} else {
236
+					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
237 237
 						$errors[] = $wpForm->errormessage;
238 238
 					} );
239 239
 				}
Please login to merge, or discard this patch.