Completed
Push — master ( c7919b...503a39 )
by Chris
03:49
created
class/class-edu-sveawebpay.php 1 patch
Braces   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway
15 15
 	 */
16
-	class EDU_SveaWebPay extends EDU_Integration {
16
+	class EDU_SveaWebPay extends EDU_Integration {
17 17
 		/**
18 18
 		 * Constructor
19 19
 		 */
20
-		public function __construct() {
20
+		public function __construct() {
21 21
 			$this->id          = 'eduadmin-sveawebpay';
22 22
 			$this->displayName = __( 'Svea Webpay', 'eduadmin-sveawebpay' );
23 23
 			$this->description = '';
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		/**
34 34
 		 * Initializes the settingsfields
35 35
 		 */
36
-		public function init_form_fields() {
36
+		public function init_form_fields() {
37 37
 			$this->setting_fields = array(
38 38
 				'enabled'         => array(
39 39
 					'title'       => __( 'Enabled', 'eduadmin-sveawebpay' ),
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 *
67 67
 		 */
68
-		public function process_svearesponse() {
69
-			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
68
+		public function process_svearesponse() {
69
+			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
70 70
 				return;
71 71
 			}
72
-			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
72
+			if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
73 73
 				$filter = new XFiltering();
74 74
 				$f      = new XFilter( 'EventCustomerLnkID', '=', $_REQUEST['edu-thankyou'] );
75 75
 				$filter->AddItem( $f );
@@ -95,29 +95,29 @@  discard block
 block discarded – undo
95 95
 				$selectedCountry = 'SE';
96 96
 
97 97
 				$invoiceCountry = $ebi->Customer->InvoiceCountry;
98
-				if ( empty( $invoiceCountry ) ) {
98
+				if ( empty( $invoiceCountry ) ) {
99 99
 					$invoiceCountry = $ebi->Customer->Country;
100 100
 				}
101 101
 
102
-				foreach ( $countries as $country ) {
103
-					if ( $invoiceCountry == $country->CountryName ) {
102
+				foreach ( $countries as $country ) {
103
+					if ( $invoiceCountry == $country->CountryName ) {
104 104
 						$selectedCountry = $country->CountryCode;
105 105
 						break;
106 106
 					}
107 107
 				}
108 108
 
109
-				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
109
+				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
110 110
 					//$wpConfig = ConfigurationService::getDefaultConfig();
111 111
 					$wpConfig = new EduSveaWebPayTestConfig( $this );
112
-				} else {
112
+				} else {
113 113
 					$wpConfig = new EduSveaWebPayProductionConfig( $this );
114 114
 				}
115 115
 
116 116
 				$response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse();
117 117
 
118
-				if ( $response->accepted ) {
118
+				if ( $response->accepted ) {
119 119
 					EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
120
-				} else {
120
+				} else {
121 121
 					EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
122 122
 				}
123 123
 
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 		/**
134 134
 		 * @param $bookingInfo EduAdminBookingInfo
135 135
 		 */
136
-		public function process_booking( $bookingInfo = null ) {
137
-			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
136
+		public function process_booking( $bookingInfo = null ) {
137
+			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
138 138
 				return;
139 139
 			}
140
-			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
140
+			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
141 141
 				$bookingInfo->NoRedirect = true;
142 142
 
143 143
 				$countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' );
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 				$selectedLocale  = 'sv-SE';
147 147
 
148 148
 				$invoiceCountry = $bookingInfo->Customer->InvoiceCountry;
149
-				if ( empty( $invoiceCountry ) ) {
149
+				if ( empty( $invoiceCountry ) ) {
150 150
 					$invoiceCountry = $bookingInfo->Customer->Country;
151 151
 				}
152 152
 
153
-				foreach ( $countries as $country ) {
154
-					if ( $invoiceCountry == $country->CountryName ) {
153
+				foreach ( $countries as $country ) {
154
+					if ( $invoiceCountry == $country->CountryName ) {
155 155
 						$selectedCountry = $country->CountryCode;
156
-						if ( ! empty( $country->CultureName ) ) {
156
+						if ( ! empty( $country->CultureName ) ) {
157 157
 							$selectedLocale = $country->CultureName;
158 158
 						}
159 159
 						break;
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 
165 165
 				$currency = get_option( 'eduadmin-currency', 'SEK' );
166 166
 
167
-				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
167
+				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
168 168
 					//$wpConfig = ConfigurationService::getDefaultConfig();
169 169
 					$wpConfig = new EduSveaWebPayTestConfig( $this );
170
-				} else {
170
+				} else {
171 171
 					$wpConfig = new EduSveaWebPayProductionConfig( $this );
172 172
 				}
173 173
 				$wpOrder = WebPay::createOrder( $wpConfig );
@@ -182,37 +182,37 @@  discard block
 block discarded – undo
182 182
 
183 183
 				$customer = WebPayItem::companyCustomer();
184 184
 
185
-				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
185
+				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
186 186
 					$customer->setCompanyName( $bookingInfo->Customer->InvoiceName );
187
-				} else {
187
+				} else {
188 188
 					$customer->setCompanyName( $bookingInfo->Customer->CustomerName );
189 189
 				}
190 190
 
191
-				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
191
+				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
192 192
 					$customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 );
193
-				} else {
193
+				} else {
194 194
 					$customer->setStreetAddress( $bookingInfo->Customer->Address1 );
195 195
 				}
196 196
 
197
-				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
197
+				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
198 198
 					$customer->setZipCode( $bookingInfo->Customer->InvoiceZip );
199
-				} else {
199
+				} else {
200 200
 					$customer->setZipCode( $bookingInfo->Customer->Zip );
201 201
 				}
202 202
 
203
-				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
203
+				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
204 204
 					$customer->setLocality( $bookingInfo->Customer->InvoiceCity );
205
-				} else {
205
+				} else {
206 206
 					$customer->setLocality( $bookingInfo->Customer->City );
207 207
 				}
208 208
 
209
-				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
209
+				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
210 210
 					$customer->setPhoneNumber( $bookingInfo->Customer->Phone );
211 211
 				}
212 212
 
213
-				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
213
+				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
214 214
 					$customer->setEmail( $bookingInfo->Customer->InvoiceEmail );
215
-				} else {
215
+				} else {
216 216
 					$customer->setEmail( $bookingInfo->Customer->Email );
217 217
 				}
218 218
 
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 					->setCancelUrl( apply_filters( 'eduadmin-cancel-url', $defaultCancel ) )
239 239
 					->getPaymentUrl();
240 240
 
241
-				if ( $wpForm->accepted ) {
242
-					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
241
+				if ( $wpForm->accepted ) {
242
+					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
243 243
 						echo '<script type="text/javascript">location.href = "' . $wpForm->url . '";</script>';
244
-					} else {
244
+					} else {
245 245
 						echo '<script type="text/javascript">location.href = "' . $wpForm->testurl . '";</script>';
246 246
 					}
247
-				} else {
248
-					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
247
+				} else {
248
+					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
249 249
 						$errors[] = $wpForm->errormessage;
250 250
 					} );
251 251
 				}
Please login to merge, or discard this patch.
class/class-edu-sveawebpay-config.php 1 patch
Braces   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class EduSveaWebPayProductionConfig implements \Svea\WebPay\Config\ConfigurationProvider {
3
+class EduSveaWebPayProductionConfig implements \Svea\WebPay\Config\ConfigurationProvider {
4 4
 
5 5
 	/**
6 6
 	 * @var EDU_SveaWebPay
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 *
13 13
 	 * @param EDU_SveaWebPay $_plugin
14 14
 	 */
15
-	public function __construct( $_plugin ) {
15
+	public function __construct( $_plugin ) {
16 16
 		$this->plugin = $_plugin;
17 17
 	}
18 18
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
28 28
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
29 29
 	 */
30
-	public function getUsername( $type, $country ) {
30
+	public function getUsername( $type, $country ) {
31 31
 	}
32 32
 
33 33
 	/**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
42 42
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
43 43
 	 */
44
-	public function getPassword( $type, $country ) {
44
+	public function getPassword( $type, $country ) {
45 45
 	}
46 46
 
47 47
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
56 56
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
57 57
 	 */
58
-	public function getClientNumber( $type, $country ) {
58
+	public function getClientNumber( $type, $country ) {
59 59
 	}
60 60
 
61 61
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
67 67
 	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
68 68
 	 */
69
-	public function getMerchantId( $type, $country ) {
69
+	public function getMerchantId( $type, $country ) {
70 70
 		return $this->plugin->get_option( 'merchant_key', '' );
71 71
 	}
72 72
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
79 79
 	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
80 80
 	 */
81
-	public function getSecret( $type, $country ) {
81
+	public function getSecret( $type, $country ) {
82 82
 		return $this->plugin->get_option( 'merchant_secret', '' );
83 83
 	}
84 84
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @throws Exception
92 92
 	 */
93 93
 
94
-	public function getEndPoint( $type ) {
95
-		switch ( strtoupper( $type ) ) {
94
+	public function getEndPoint( $type ) {
95
+		switch ( strtoupper( $type ) ) {
96 96
 			case "HOSTED":
97 97
 				return Svea\WebPay\Config\ConfigurationService::SWP_PROD_URL;
98 98
 				break;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @return string
119 119
 	 */
120
-	public function getCheckoutMerchantId() {
120
+	public function getCheckoutMerchantId() {
121 121
 		// TODO: Implement getCheckoutMerchantId() method.
122 122
 	}
123 123
 
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return string
128 128
 	 */
129
-	public function getCheckoutSecret() {
129
+	public function getCheckoutSecret() {
130 130
 		// TODO: Implement getCheckoutSecret() method.
131 131
 	}
132 132
 }
133 133
 
134
-class EduSveaWebPayTestConfig implements \Svea\WebPay\Config\ConfigurationProvider {
134
+class EduSveaWebPayTestConfig implements \Svea\WebPay\Config\ConfigurationProvider {
135 135
 
136 136
 	/**
137 137
 	 * @var EDU_SveaWebPay
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 * @param EDU_SveaWebPay $_plugin
145 145
 	 */
146
-	public function __construct( $_plugin ) {
146
+	public function __construct( $_plugin ) {
147 147
 		$this->plugin = $_plugin;
148 148
 	}
149 149
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
159 159
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
160 160
 	 */
161
-	public function getUsername( $type, $country ) {
161
+	public function getUsername( $type, $country ) {
162 162
 	}
163 163
 
164 164
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
173 173
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
174 174
 	 */
175
-	public function getPassword( $type, $country ) {
175
+	public function getPassword( $type, $country ) {
176 176
 	}
177 177
 
178 178
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException  in case of unsupported $type
187 187
 	 * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException  in case of unsupported $country
188 188
 	 */
189
-	public function getClientNumber( $type, $country ) {
189
+	public function getClientNumber( $type, $country ) {
190 190
 	}
191 191
 
192 192
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
198 198
 	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
199 199
 	 */
200
-	public function getMerchantId( $type, $country ) {
200
+	public function getMerchantId( $type, $country ) {
201 201
 		return $this->plugin->get_option( 'merchant_key', '' );
202 202
 	}
203 203
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param string $type    Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings
210 210
 	 * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE
211 211
 	 */
212
-	public function getSecret( $type, $country ) {
212
+	public function getSecret( $type, $country ) {
213 213
 		return $this->plugin->get_option( 'merchant_secret', '' );
214 214
 	}
215 215
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @throws Exception
223 223
 	 */
224
-	public function getEndPoint( $type ) {
225
-		switch ( strtoupper( $type ) ) {
224
+	public function getEndPoint( $type ) {
225
+		switch ( strtoupper( $type ) ) {
226 226
 			case "HOSTED":
227 227
 				return Svea\WebPay\Config\ConfigurationService::SWP_TEST_URL;
228 228
 				break;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return string
249 249
 	 */
250
-	public function getCheckoutMerchantId() {
250
+	public function getCheckoutMerchantId() {
251 251
 		// TODO: Implement getCheckoutMerchantId() method.
252 252
 	}
253 253
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string
258 258
 	 */
259
-	public function getCheckoutSecret() {
259
+	public function getCheckoutSecret() {
260 260
 		// TODO: Implement getCheckoutSecret() method.
261 261
 	}
262 262
 }
263 263
\ No newline at end of file
Please login to merge, or discard this patch.