Completed
Push — master ( 2cfcca...1b95e2 )
by Chris
03:25
created
eduadmin-wordpress-sveawebpay.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -35,44 +35,44 @@
 block discarded – undo
35 35
     along with this program. If not, see <http://www.gnu.org/licenses/>.
36 36
  */
37 37
 
38
- add_action('admin_init', 'checkForEduAdminPlugin');
38
+ add_action( 'admin_init', 'checkForEduAdminPlugin' );
39 39
  function checkForEduAdminPlugin() {
40
-	 if(is_admin() && current_user_can('activate_plugins') && !is_plugin_active('eduadmin/eduadmin.php'))
40
+	 if ( is_admin() && current_user_can( 'activate_plugins' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) )
41 41
 	 {
42
-		 add_action('admin_notices', function() {
43
-			 ?><div class="error"><p><?php _e('This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-sveawebpay'); ?></p></div><?php
42
+		 add_action( 'admin_notices', function() {
43
+			 ?><div class="error"><p><?php _e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-sveawebpay' ); ?></p></div><?php
44 44
 		 });
45
-		 deactivate_plugins(plugin_basename( __FILE__ ));
45
+		 deactivate_plugins( plugin_basename( __FILE__ ) );
46 46
 
47
-		 if(isset($_GET['activate'])) {
48
-			 unset($_GET['activate']);
47
+		 if ( isset( $_GET['activate'] ) ) {
48
+			 unset( $_GET['activate'] );
49 49
 		 }
50 50
 	 }
51 51
  }
52 52
 
53
-if(!class_exists('EDU_SveaWebPay_Loader')):
53
+if ( ! class_exists( 'EDU_SveaWebPay_Loader' ) ):
54 54
 
55 55
 final class EDU_SveaWebPay_Loader {
56 56
 	public function __construct() {
57
-		add_action('plugins_loaded', array($this, 'init'));
57
+		add_action( 'plugins_loaded', array ( $this, 'init' ) );
58 58
 	}
59 59
 
60 60
 	public function init() {
61
-		if(class_exists('EDU_Integration'))
61
+		if ( class_exists( 'EDU_Integration' ) )
62 62
 		{
63
-			require_once(__DIR__ . '/vendor/autoload.php'); // Load dependencies
64
-			require_once(__DIR__ . '/class/class-edu-sveawebpay.php');
63
+			require_once( __DIR__ . '/vendor/autoload.php' ); // Load dependencies
64
+			require_once( __DIR__ . '/class/class-edu-sveawebpay.php' );
65 65
 
66
-			add_filter('edu_integrations', array($this, 'add_integration'));
66
+			add_filter( 'edu_integrations', array ( $this, 'add_integration' ) );
67 67
 		}
68 68
 	}
69 69
 
70
-	public function add_integration($integrations)
70
+	public function add_integration( $integrations )
71 71
 	{
72 72
 		$integrations[] = 'EDU_SveaWebPay';
73 73
 		return $integrations;
74 74
 	}
75 75
 }
76 76
 
77
-$edu_sveawebpay_loader = new EDU_SveaWebPay_Loader(__FILE__);
77
+$edu_sveawebpay_loader = new EDU_SveaWebPay_Loader( __FILE__ );
78 78
 endif;
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,15 +36,14 @@  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
-	 {
42
-		 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() {
43 42
 			 ?><div class="error"><p><?php _e('This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-sveawebpay'); ?></p></div><?php
44 43
 		 });
45 44
 		 deactivate_plugins(plugin_basename( __FILE__ ));
46 45
 
47
-		 if(isset($_GET['activate'])) {
46
+		 if(isset($_GET['activate'])) {
48 47
 			 unset($_GET['activate']);
49 48
 		 }
50 49
 	 }
@@ -52,14 +51,13 @@  discard block
 block discarded – undo
52 51
 
53 52
 if(!class_exists('EDU_SveaWebPay_Loader')):
54 53
 
55
-final class EDU_SveaWebPay_Loader {
56
-	public function __construct() {
54
+final class EDU_SveaWebPay_Loader {
55
+	public function __construct() {
57 56
 		add_action('plugins_loaded', array($this, 'init'));
58 57
 	}
59 58
 
60
-	public function init() {
61
-		if(class_exists('EDU_Integration'))
62
-		{
59
+	public function init() {
60
+		if(class_exists('EDU_Integration')) {
63 61
 			require_once(__DIR__ . '/vendor/autoload.php'); // Load dependencies
64 62
 			require_once(__DIR__ . '/class/class-edu-sveawebpay.php');
65 63
 
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
 		}
68 66
 	}
69 67
 
70
-	public function add_integration($integrations)
71
-	{
68
+	public function add_integration($integrations) {
72 69
 		$integrations[] = 'EDU_SveaWebPay';
73 70
 		return $integrations;
74 71
 	}
Please login to merge, or discard this patch.
class/class-edu-sveawebpay.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,35 +23,35 @@
 block discarded – undo
23 23
 			$this->init_form_fields();
24 24
 			$this->init_settings();
25 25
 
26
-			add_action( 'eduadmin-processbooking', array( $this, 'process_booking' ) );
26
+			add_action( 'eduadmin-processbooking', array ( $this, 'process_booking' ) );
27 27
 
28
-			add_action( 'wp_loaded', array( $this, 'process_svearesponse' ) );
28
+			add_action( 'wp_loaded', array ( $this, 'process_svearesponse' ) );
29 29
 		}
30 30
 
31 31
 		/**
32 32
 		 * Initializes the settingsfields
33 33
 		 */
34 34
 		public function init_form_fields() {
35
-			$this->setting_fields = array(
36
-				'enabled'         => array(
35
+			$this->setting_fields = array (
36
+				'enabled'         => array (
37 37
 					'title'       => __( 'Enabled', 'eduadmin-sveawebpay' ),
38 38
 					'type'        => 'checkbox',
39 39
 					'description' => __( 'Enables/Disables the integration with Svea WebPay', 'eduadmin-sveawebpay' ),
40 40
 					'default'     => 'no',
41 41
 				),
42
-				'testrun'         => array(
42
+				'testrun'         => array (
43 43
 					'title'       => __( 'Sandbox mode', 'eduadmin-sveawebpay' ),
44 44
 					'type'        => 'checkbox',
45 45
 					'description' => __( 'Activate sandbox mode', 'eduadmin-sveawebpay' ),
46 46
 					'default'     => 'no',
47 47
 				),
48
-				'merchant_key'    => array(
48
+				'merchant_key'    => array (
49 49
 					'title'       => __( 'Merchant key', 'eduadmin-sveawebpay' ),
50 50
 					'type'        => 'text',
51 51
 					'description' => __( 'Please enter your merchant key from Svea WebPay.', 'eduadmin-sveawebpay' ),
52 52
 					'placeholder' => __( 'Merchant key', 'eduadmin-sveawebpay' ),
53 53
 				),
54
-				'merchant_secret' => array(
54
+				'merchant_secret' => array (
55 55
 					'title'       => __( 'Merchant secret', 'eduadmin-sveawebpay' ),
56 56
 					'type'        => 'password',
57 57
 					'description' => __( 'Please enter your merchant secret from Svea WebPay', 'eduadmin-sveawebpay' ),
Please login to merge, or discard this patch.
Braces   +32 added lines, -32 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,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 *
65 65
 		 */
66
-		public function process_svearesponse() {
67
-			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
66
+		public function process_svearesponse() {
67
+			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
68 68
 				$filter = new XFiltering();
69 69
 				$f      = new XFilter( 'EventCustomerLnkID', '=', $_REQUEST['edu-thankyou'] );
70 70
 				$filter->AddItem( $f );
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 				$selectedCountry = 'SE';
91 91
 
92 92
 				$invoiceCountry = $ebi->Customer->InvoiceCountry;
93
-				if ( empty( $invoiceCountry ) ) {
93
+				if ( empty( $invoiceCountry ) ) {
94 94
 					$invoiceCountry = $ebi->Customer->Country;
95 95
 				}
96 96
 
97
-				foreach ( $countries as $country ) {
98
-					if ( $invoiceCountry == $country->CountryName ) {
97
+				foreach ( $countries as $country ) {
98
+					if ( $invoiceCountry == $country->CountryName ) {
99 99
 						$selectedCountry = $country->CountryCode;
100 100
 						break;
101 101
 					}
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
 				$response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse();
107 107
 
108
-				if ( $response->accepted ) {
108
+				if ( $response->accepted ) {
109 109
 					EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
110
-				} else {
110
+				} else {
111 111
 					EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
112 112
 				}
113 113
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 		/**
124 124
 		 * @param $bookingInfo EduAdminBookingInfo
125 125
 		 */
126
-		public function process_booking( $bookingInfo = null ) {
127
-			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
126
+		public function process_booking( $bookingInfo = null ) {
127
+			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
128 128
 				$bookingInfo->NoRedirect = true;
129 129
 
130 130
 				$countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' );
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
 				$selectedLocale  = 'sv-SE';
134 134
 
135 135
 				$invoiceCountry = $bookingInfo->Customer->InvoiceCountry;
136
-				if ( empty( $invoiceCountry ) ) {
136
+				if ( empty( $invoiceCountry ) ) {
137 137
 					$invoiceCountry = $bookingInfo->Customer->Country;
138 138
 				}
139 139
 
140
-				foreach ( $countries as $country ) {
141
-					if ( $invoiceCountry == $country->CountryName ) {
140
+				foreach ( $countries as $country ) {
141
+					if ( $invoiceCountry == $country->CountryName ) {
142 142
 						$selectedCountry = $country->CountryCode;
143
-						if ( ! empty( $country->CultureName ) ) {
143
+						if ( ! empty( $country->CultureName ) ) {
144 144
 							$selectedLocale = $country->CultureName;
145 145
 						}
146 146
 						break;
@@ -164,37 +164,37 @@  discard block
 block discarded – undo
164 164
 
165 165
 				$customer = WebPayItem::companyCustomer();
166 166
 
167
-				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
167
+				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
168 168
 					$customer->setCompanyName( $bookingInfo->Customer->InvoiceName );
169
-				} else {
169
+				} else {
170 170
 					$customer->setCompanyName( $bookingInfo->Customer->CustomerName );
171 171
 				}
172 172
 
173
-				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
173
+				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
174 174
 					$customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 );
175
-				} else {
175
+				} else {
176 176
 					$customer->setStreetAddress( $bookingInfo->Customer->Address1 );
177 177
 				}
178 178
 
179
-				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
179
+				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
180 180
 					$customer->setZipCode( $bookingInfo->Customer->InvoiceZip );
181
-				} else {
181
+				} else {
182 182
 					$customer->setZipCode( $bookingInfo->Customer->Zip );
183 183
 				}
184 184
 
185
-				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
185
+				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
186 186
 					$customer->setLocality( $bookingInfo->Customer->InvoiceCity );
187
-				} else {
187
+				} else {
188 188
 					$customer->setLocality( $bookingInfo->Customer->City );
189 189
 				}
190 190
 
191
-				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
191
+				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
192 192
 					$customer->setPhoneNumber( $bookingInfo->Customer->Phone );
193 193
 				}
194 194
 
195
-				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
195
+				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
196 196
 					$customer->setEmail( $bookingInfo->Customer->InvoiceEmail );
197
-				} else {
197
+				} else {
198 198
 					$customer->setEmail( $bookingInfo->Customer->Email );
199 199
 				}
200 200
 
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
 					->setCancelUrl( apply_filters( 'eduadmin-cancel-url', $defaultCancel ) )
221 221
 					->getPaymentUrl();
222 222
 
223
-				if ( $wpForm->accepted ) {
224
-					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
223
+				if ( $wpForm->accepted ) {
224
+					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
225 225
 						echo '<script type="text/javascript">location.href = "' . $wpForm->url . '";</script>';
226
-					} else {
226
+					} else {
227 227
 						echo '<script type="text/javascript">location.href = "' . $wpForm->testurl . '";</script>';
228 228
 					}
229
-				} else {
230
-					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
229
+				} else {
230
+					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
231 231
 						$errors[] = $wpForm->errormessage;
232 232
 					} );
233 233
 				}
Please login to merge, or discard this patch.