@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use Svea\WebPay\Config\ConfigurationService; |
9 | 9 | use Svea\WebPay\Response\SveaResponse; |
10 | 10 | |
11 | -if ( ! class_exists( 'EDU_SveaWebPay' ) ): |
|
11 | +if ( !class_exists( 'EDU_SveaWebPay' ) ): |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact ); |
81 | 81 | |
82 | - if ( ! empty( EDU()->session['svea-order-id'] ) && ! empty( $_GET['svea_order_id'] ) && EDU()->session['svea-order-id'] === $_GET['svea_order_id'] ) { |
|
82 | + if ( !empty( EDU()->session['svea-order-id'] ) && !empty( $_GET['svea_order_id'] ) && EDU()->session['svea-order-id'] === $_GET['svea_order_id'] ) { |
|
83 | 83 | do_action( 'eduadmin-bookingcompleted', $ebi ); |
84 | 84 | } else { |
85 | 85 | do_action( 'eduadmin-processbooking', $ebi ); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
98 | + if ( !empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
99 | 99 | $ebi->NoRedirect = true; |
100 | 100 | } |
101 | 101 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | foreach ( $countries as $country ) { |
192 | 192 | if ( $invoiceCountry == $country['CountryName'] ) { |
193 | 193 | $selectedCountry = $country['CountryCode']; |
194 | - if ( ! empty( $country['CultureName'] ) ) { |
|
194 | + if ( !empty( $country['CultureName'] ) ) { |
|
195 | 195 | $selectedLocale = $country['CultureName']; |
196 | 196 | } |
197 | 197 | break; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $eventName = ''; |
209 | 209 | |
210 | - if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { |
|
210 | + if ( !empty( $ebi->EventBooking['BookingId'] ) ) { |
|
211 | 211 | $booking_id = intval( $ebi->EventBooking['BookingId'] ); |
212 | 212 | $reference_id = $booking_id; |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $eventName = $_event['EventName']; |
217 | 217 | } |
218 | 218 | |
219 | - if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
219 | + if ( !empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
220 | 220 | $programme_booking_id = intval( $ebi->EventBooking['ProgrammeBookingId'] ); |
221 | 221 | $reference_id = $programme_booking_id; |
222 | 222 | |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | |
246 | 246 | $customer = WebPayItem::companyCustomer(); |
247 | 247 | |
248 | - $customerName = ! empty( $ebi->Customer['BillingInfo']['InvoiceName'] ) ? $ebi->Customer['BillingInfo']['InvoiceName'] : $ebi->Customer['CustomerName']; |
|
249 | - $streetAddress = ! empty( $ebi->Customer['BillingInfo']['Address'] ) ? $ebi->Customer['BillingInfo']['Address'] : $ebi->Customer['Address']; |
|
250 | - $zipCode = ! empty( $ebi->Customer['BillingInfo']['Zip'] ) ? $ebi->Customer['BillingInfo']['Zip'] : $ebi->Customer['Zip']; |
|
248 | + $customerName = !empty( $ebi->Customer['BillingInfo']['InvoiceName'] ) ? $ebi->Customer['BillingInfo']['InvoiceName'] : $ebi->Customer['CustomerName']; |
|
249 | + $streetAddress = !empty( $ebi->Customer['BillingInfo']['Address'] ) ? $ebi->Customer['BillingInfo']['Address'] : $ebi->Customer['Address']; |
|
250 | + $zipCode = !empty( $ebi->Customer['BillingInfo']['Zip'] ) ? $ebi->Customer['BillingInfo']['Zip'] : $ebi->Customer['Zip']; |
|
251 | 251 | $city = $ebi->Customer['BillingInfo']['City'] ? $ebi->Customer['BillingInfo']['City'] : $ebi->Customer['City']; |
252 | 252 | $phone = $ebi->Customer['Phone']; |
253 | - $email = ! empty( $ebi->Customer['BillingInfo']['Email'] ) ? $ebi->Customer['BillingInfo']['Email'] : $ebi->Customer['Email']; |
|
253 | + $email = !empty( $ebi->Customer['BillingInfo']['Email'] ) ? $ebi->Customer['BillingInfo']['Email'] : $ebi->Customer['Email']; |
|
254 | 254 | |
255 | 255 | $customer->setCompanyName( $customerName ); |
256 | 256 | $customer->setStreetAddress( $streetAddress ); |
257 | 257 | $customer->setZipCode( $zipCode ); |
258 | 258 | $customer->setLocality( $city ); |
259 | 259 | |
260 | - if ( ! empty( $phone ) ) { |
|
260 | + if ( !empty( $phone ) ) { |
|
261 | 261 | $customer->setPhoneNumber( $phone ); |
262 | 262 | $phonePreset = WebPayItem::presetValue() |
263 | 263 | ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | ->setConfirmationUri( $defaultThankYou ) |
329 | 329 | ->setPushUri( $defaultPushUrl ) |
330 | 330 | ->setCheckoutUri( $defaultCancel ); // We have no "checkout"-url.. So we just cancel the booking instead. |
331 | - $wpForm = $wpBuild->createOrder(); |
|
331 | + $wpForm = $wpBuild->createOrder(); |
|
332 | 332 | |
333 | 333 | EDU()->session['svea-order-id'] = $wpForm['OrderId']; |
334 | 334 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | public function process_paymentstatus() { |
339 | - if ( ! empty( $_GET['svea_order_id'] ) && intval( $_GET['svea_order_id'] ) != 0 && ! empty( $_GET['status'] ) ) { |
|
339 | + if ( !empty( $_GET['svea_order_id'] ) && intval( $_GET['svea_order_id'] ) != 0 && !empty( $_GET['status'] ) ) { |
|
340 | 340 | |
341 | 341 | $booking_id = intval( $_GET['booking_id'] ); |
342 | 342 | $programme_booking_id = intval( $_GET['programme_booking_id'] ); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | exit( 0 ); |
347 | 347 | } |
348 | 348 | |
349 | - if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && ! empty( $_GET['status'] ) ) { |
|
349 | + if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && !empty( $_GET['status'] ) ) { |
|
350 | 350 | $booking_id = intval( $_GET['booking_id'] ); |
351 | 351 | $programme_booking_id = intval( $_GET['programme_booking_id'] ); |
352 | 352 |
@@ -13,11 +13,11 @@ discard block |
||
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 (Checkout)', 'eduadmin-sveawebpay' ); |
23 | 23 | $this->description = ''; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @param $attributes |
39 | 39 | */ |
40 | - public function test_page( $attributes ) { |
|
40 | + public function test_page( $attributes ) { |
|
41 | 41 | $attributes = shortcode_atts( |
42 | 42 | array( |
43 | 43 | 'bookingid' => 0, |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | 'test_page' |
48 | 48 | ); |
49 | 49 | |
50 | - if ( $attributes['bookingid'] > 0 ) { |
|
50 | + if ( $attributes['bookingid'] > 0 ) { |
|
51 | 51 | $event_booking = EDUAPI()->OData->Bookings->GetItem( |
52 | 52 | $attributes['bookingid'], |
53 | 53 | null, |
54 | 54 | 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows', |
55 | 55 | false |
56 | 56 | ); |
57 | - } elseif ( $attributes['programmebookingid'] > 0 ) { |
|
57 | + } elseif ( $attributes['programmebookingid'] > 0 ) { |
|
58 | 58 | $event_booking = EDUAPI()->OData->ProgrammeBookings->GetItem( |
59 | 59 | $attributes['programmebookingid'], |
60 | 60 | null, |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | |
80 | 80 | $ebi = new EduAdmin_BookingInfo( $event_booking, $_customer, $_contact ); |
81 | 81 | |
82 | - if ( ! empty( EDU()->session['svea-order-id'] ) && ! empty( $_GET['svea_order_id'] ) && EDU()->session['svea-order-id'] === $_GET['svea_order_id'] ) { |
|
82 | + if ( ! empty( EDU()->session['svea-order-id'] ) && ! empty( $_GET['svea_order_id'] ) && EDU()->session['svea-order-id'] === $_GET['svea_order_id'] ) { |
|
83 | 83 | do_action( 'eduadmin-bookingcompleted', $ebi ); |
84 | - } else { |
|
84 | + } else { |
|
85 | 85 | do_action( 'eduadmin-processbooking', $ebi ); |
86 | 86 | } |
87 | 87 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @param EduAdmin_BookingInfo|null $ebi |
92 | 92 | */ |
93 | - public function intercept_booking( $ebi = null ) { |
|
94 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
93 | + public function intercept_booking( $ebi = null ) { |
|
94 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
98 | + if ( ! empty( $_POST['act'] ) && ( 'bookCourse' === $_POST['act'] || 'bookProgramme' === $_POST['act'] ) ) { |
|
99 | 99 | $ebi->NoRedirect = true; |
100 | 100 | } |
101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * Initializes the settingsfields |
105 | 105 | */ |
106 | - public function init_form_fields() { |
|
106 | + public function init_form_fields() { |
|
107 | 107 | $this->setting_fields = array( |
108 | 108 | 'enabled' => array( |
109 | 109 | 'title' => __( 'Enabled', 'eduadmin-sveawebpay' ), |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * |
137 | 137 | */ |
138 | - public function process_svearesponse() { |
|
139 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
138 | + public function process_svearesponse() { |
|
139 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | |
143 | - if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) { |
|
143 | + if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) { |
|
144 | 144 | $booking_id = intval( $_GET['booking_id'] ); |
145 | 145 | $programme_booking_id = intval( $_GET['programme_booking_id'] ); |
146 | 146 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | EDU()->session['svea-order-id'] = null; |
150 | 150 | |
151 | - if ( $deleted ) { |
|
151 | + if ( $deleted ) { |
|
152 | 152 | $this->handle_cancelled_payment(); |
153 | 153 | } |
154 | 154 | } |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | /** |
158 | 158 | * @param $ebi EduAdmin_BookingInfo|null $bookingInfo |
159 | 159 | */ |
160 | - public function process_booking( $ebi = null ) { |
|
161 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
160 | + public function process_booking( $ebi = null ) { |
|
161 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $ebi->NoRedirect = true; |
166 | 166 | |
167 | - if ( empty( $_GET['svea_order_id'] ) || empty( EDU()->session['svea-order-id'] ) ) { |
|
167 | + if ( empty( $_GET['svea_order_id'] ) || empty( EDU()->session['svea-order-id'] ) ) { |
|
168 | 168 | $checkout = $this->create_checkout( $ebi ); |
169 | 169 | |
170 | 170 | $snippet = $checkout['Gui']['Snippet']; |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @returns array |
179 | 179 | */ |
180 | - public function create_checkout( $ebi ) { |
|
180 | + public function create_checkout( $ebi ) { |
|
181 | 181 | $countries = EDUAPI()->OData->Countries->Search()['value']; |
182 | 182 | |
183 | 183 | $selectedCountry = 'SE'; |
184 | 184 | $selectedLocale = 'sv-SE'; |
185 | 185 | |
186 | 186 | $invoiceCountry = $ebi->Customer['BillingInfo']['Country']; |
187 | - if ( empty( $invoiceCountry ) ) { |
|
187 | + if ( empty( $invoiceCountry ) ) { |
|
188 | 188 | $invoiceCountry = $ebi->Customer['Country']; |
189 | 189 | } |
190 | 190 | |
191 | - foreach ( $countries as $country ) { |
|
192 | - if ( $invoiceCountry == $country['CountryName'] ) { |
|
191 | + foreach ( $countries as $country ) { |
|
192 | + if ( $invoiceCountry == $country['CountryName'] ) { |
|
193 | 193 | $selectedCountry = $country['CountryCode']; |
194 | - if ( ! empty( $country['CultureName'] ) ) { |
|
194 | + if ( ! empty( $country['CultureName'] ) ) { |
|
195 | 195 | $selectedLocale = $country['CultureName']; |
196 | 196 | } |
197 | 197 | break; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $eventName = ''; |
209 | 209 | |
210 | - if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { |
|
210 | + if ( ! empty( $ebi->EventBooking['BookingId'] ) ) { |
|
211 | 211 | $booking_id = intval( $ebi->EventBooking['BookingId'] ); |
212 | 212 | $reference_id = $booking_id; |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $eventName = $_event['EventName']; |
217 | 217 | } |
218 | 218 | |
219 | - if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
219 | + if ( ! empty( $ebi->EventBooking['ProgrammeBookingId'] ) ) { |
|
220 | 220 | $programme_booking_id = intval( $ebi->EventBooking['ProgrammeBookingId'] ); |
221 | 221 | $reference_id = $programme_booking_id; |
222 | 222 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | |
228 | 228 | $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' ); |
229 | 229 | |
230 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
230 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
231 | 231 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
232 | - } else { |
|
232 | + } else { |
|
233 | 233 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
234 | 234 | } |
235 | 235 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | $customer->setZipCode( $zipCode ); |
258 | 258 | $customer->setLocality( $city ); |
259 | 259 | |
260 | - if ( ! empty( $phone ) ) { |
|
260 | + if ( ! empty( $phone ) ) { |
|
261 | 261 | $customer->setPhoneNumber( $phone ); |
262 | 262 | $phonePreset = WebPayItem::presetValue() |
263 | 263 | ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | return $wpForm; |
336 | 336 | } |
337 | 337 | |
338 | - public function process_paymentstatus() { |
|
339 | - if ( ! empty( $_GET['svea_order_id'] ) && intval( $_GET['svea_order_id'] ) != 0 && ! empty( $_GET['status'] ) ) { |
|
338 | + public function process_paymentstatus() { |
|
339 | + if ( ! empty( $_GET['svea_order_id'] ) && intval( $_GET['svea_order_id'] ) != 0 && ! empty( $_GET['status'] ) ) { |
|
340 | 340 | |
341 | 341 | $booking_id = intval( $_GET['booking_id'] ); |
342 | 342 | $programme_booking_id = intval( $_GET['programme_booking_id'] ); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | exit( 0 ); |
347 | 347 | } |
348 | 348 | |
349 | - if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && ! empty( $_GET['status'] ) ) { |
|
349 | + if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && ! empty( $_GET['status'] ) ) { |
|
350 | 350 | $booking_id = intval( $_GET['booking_id'] ); |
351 | 351 | $programme_booking_id = intval( $_GET['programme_booking_id'] ); |
352 | 352 | |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | |
355 | 355 | EDU()->session['svea-order-id'] = null; |
356 | 356 | |
357 | - if ( $deleted ) { |
|
357 | + if ( $deleted ) { |
|
358 | 358 | $this->handle_cancelled_payment(); |
359 | 359 | } |
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | - private function handle_cancelled_payment() { |
|
363 | + private function handle_cancelled_payment() { |
|
364 | 364 | @wp_redirect( get_home_url() ); |
365 | 365 | wp_add_inline_script( 'edu-svea-redirecthome', "location.href = '" . esc_js( get_home_url() ) . "';" ); |
366 | 366 | wp_enqueue_script( 'edu-svea-redirecthome', false, array( 'jquery' ) ); |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | * @return bool If the booking was deleted, due to cancellation |
376 | 376 | * @throws \Svea\WebPay\BuildOrder\Validator\ValidationException |
377 | 377 | */ |
378 | - private function update_booking( $order_id, $booking_id, $programme_booking_id ) { |
|
379 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
378 | + private function update_booking( $order_id, $booking_id, $programme_booking_id ) { |
|
379 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
380 | 380 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
381 | - } else { |
|
381 | + } else { |
|
382 | 382 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
383 | 383 | } |
384 | 384 | |
@@ -392,39 +392,39 @@ discard block |
||
392 | 392 | $patch_booking = new stdClass(); |
393 | 393 | $patch_booking->PaymentMethodId = 2; |
394 | 394 | |
395 | - if ( 'Cancelled' === $order['Status'] ) { |
|
395 | + if ( 'Cancelled' === $order['Status'] ) { |
|
396 | 396 | $patch_booking->Paid = false; |
397 | 397 | $delete_booking = true; |
398 | - } else if ( 'Final' === $order['Status'] ) { |
|
398 | + } else if ( 'Final' === $order['Status'] ) { |
|
399 | 399 | $patch_booking->Paid = true; |
400 | - } else if ( 'Created' === $order['Status'] ) { |
|
400 | + } else if ( 'Created' === $order['Status'] ) { |
|
401 | 401 | $patch_booking->Paid = false; |
402 | 402 | } |
403 | 403 | |
404 | - if ( isset( $_GET['status'] ) && 'cancel' === $_GET['status'] ) { |
|
404 | + if ( isset( $_GET['status'] ) && 'cancel' === $_GET['status'] ) { |
|
405 | 405 | $patch_booking->Paid = false; |
406 | 406 | $delete_booking = true; |
407 | 407 | } |
408 | 408 | |
409 | - if ( $booking_id > 0 ) { |
|
409 | + if ( $booking_id > 0 ) { |
|
410 | 410 | EDUAPI()->REST->Booking->PatchBooking( |
411 | 411 | $booking_id, |
412 | 412 | $patch_booking |
413 | 413 | ); |
414 | 414 | |
415 | - if ( $delete_booking ) { |
|
415 | + if ( $delete_booking ) { |
|
416 | 416 | EDUAPI()->REST->Booking->DeleteBooking( $booking_id ); |
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | - if ( $programme_booking_id > 0 ) { |
|
420 | + if ( $programme_booking_id > 0 ) { |
|
421 | 421 | |
422 | 422 | EDUAPI()->REST->ProgrammeBooking->PatchBooking( |
423 | 423 | $programme_booking_id, |
424 | 424 | $patch_booking |
425 | 425 | ); |
426 | 426 | |
427 | - if ( $delete_booking ) { |
|
427 | + if ( $delete_booking ) { |
|
428 | 428 | EDUAPI()->REST->ProgrammeBooking->DeleteBooking( $programme_booking_id ); |
429 | 429 | } |
430 | 430 | } |