Completed
Push — master ( ab5c01...83f596 )
by Chris
02:57
created

EDU_SveaWebPay::process_svearesponse()   C

Complexity

Conditions 14
Paths 98

Size

Total Lines 79
Code Lines 46

Duplication

Lines 6
Ratio 7.59 %

Importance

Changes 0
Metric Value
cc 14
eloc 46
nc 98
nop 0
dl 6
loc 79
rs 5.1058
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
defined( 'ABSPATH' ) or die( 'This plugin must be run within the scope of WordPress.' );
3
4
require_once( __DIR__ . '/class-edu-sveawebpay-config.php' );
5
6
use Svea\WebPay\WebPay;
7
use Svea\WebPay\WebPayItem;
8
use Svea\WebPay\Config\ConfigurationService;
9
use Svea\WebPay\Response\SveaResponse;
10
11
if ( ! class_exists( 'EDU_SveaWebPay' ) ):
12
13
	/**
14
	 * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway
15
	 */
16
	class EDU_SveaWebPay extends EDU_Integration {
17
		/**
18
		 * Constructor
19
		 */
20
		public function __construct() {
21
			$this->id          = 'eduadmin-sveawebpay';
22
			$this->displayName = __( 'Svea Webpay (Checkout)', 'eduadmin-sveawebpay' );
23
			$this->description = '';
24
25
			$this->init_form_fields();
26
			$this->init_settings();
27
28
			add_action( 'eduadmin-checkpaymentplugins', array( $this, 'intercept_booking' ) );
29
30
			add_action( 'eduadmin-processbooking', array( $this, 'process_booking' ) );
31
32
			add_action( 'wp_loaded', array( $this, 'process_svearesponse' ) );
33
		}
34
35
		/**
36
		 * @param $bookingInfo EduAdminBookingInfo
37
		 */
38
		public function intercept_booking( $bookingInfo = null ) {
39
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
40
				return;
41
			}
42
			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
43
				$bookingInfo->NoRedirect = true;
44
			}
45
		}
46
47
		/**
48
		 * Initializes the settingsfields
49
		 */
50
		public function init_form_fields() {
51
			$this->setting_fields = array(
52
				'enabled'         => array(
53
					'title'       => __( 'Enabled', 'eduadmin-sveawebpay' ),
54
					'type'        => 'checkbox',
55
					'description' => __( 'Enables/Disables the integration with Svea WebPay', 'eduadmin-sveawebpay' ),
56
					'default'     => 'no',
57
				),
58
				'testrun'         => array(
59
					'title'       => __( 'Sandbox mode', 'eduadmin-sveawebpay' ),
60
					'type'        => 'checkbox',
61
					'description' => __( 'Activate sandbox mode', 'eduadmin-sveawebpay' ),
62
					'default'     => 'no',
63
				),
64
				'merchant_key'    => array(
65
					'title'       => __( 'Merchant key', 'eduadmin-sveawebpay' ),
66
					'type'        => 'text',
67
					'description' => __( 'Please enter your merchant key from Svea WebPay.', 'eduadmin-sveawebpay' ),
68
					'placeholder' => __( 'Merchant key', 'eduadmin-sveawebpay' ),
69
				),
70
				'merchant_secret' => array(
71
					'title'       => __( 'Merchant secret', 'eduadmin-sveawebpay' ),
72
					'type'        => 'password',
73
					'description' => __( 'Please enter your merchant secret from Svea WebPay', 'eduadmin-sveawebpay' ),
74
					'placeholder' => __( 'Merchant secret', 'eduadmin-sveawebpay' ),
75
				),
76
			);
77
		}
78
79
		/**
80
		 *
81
		 */
82
		public function process_svearesponse() {
83
84
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
85
				return;
86
			}
87
			if ( ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) || ( isset( $_REQUEST['edu-cancel'] ) && isset( $_REQUEST['svea'] ) ) ) {
88
89
				$eclId = ( isset( $_REQUEST['edu-thankyou'] ) ? $_REQUEST['edu-thankyou'] : $_REQUEST['edu-cancel'] );
0 ignored issues
show
introduced by
Detected access of super global var $_REQUEST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_REQUEST
Loading history...
90
91
				$filter = new XFiltering();
92
				$f      = new XFilter( 'EventCustomerLnkID', '=', $eclId );
93
				$filter->AddItem( $f );
94
95
				$eventBooking = EDU()->api->GetEventBookingV2( EDU()->get_token(), '', $filter->ToString() )[0];
96
97
				$filter = new XFiltering();
98
				$f      = new XFilter( 'CustomerID', '=', $eventBooking->CustomerID );
99
				$filter->AddItem( $f );
100
101
				$_customer = EDU()->api->GetCustomerV3( EDU()->get_token(), '', $filter->ToString(), false )[0];
102
103
				$filter = new XFiltering();
104
				$f      = new XFilter( 'CustomerContactID', '=', $eventBooking->CustomerContactID );
105
				$filter->AddItem( $f );
106
107
				$_contact = EDU()->api->GetCustomerContactV2( EDU()->get_token(), '', $filter->ToString(), false )[0];
108
109
				$ebi = new EduAdminBookingInfo( $eventBooking, $_customer, $_contact );
110
111
				$countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' );
112
113
				$selectedCountry = 'SE';
0 ignored issues
show
Unused Code introduced by
$selectedCountry is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
114
115
				$invoiceCountry = $ebi->Customer->InvoiceCountry;
116
				if ( empty( $invoiceCountry ) ) {
117
					$invoiceCountry = $ebi->Customer->Country;
118
				}
119
120
				foreach ( $countries as $country ) {
121
					if ( $invoiceCountry == $country->CountryName ) {
122
						$selectedCountry = $country->CountryCode;
0 ignored issues
show
Unused Code introduced by
$selectedCountry is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
123
						break;
124
					}
125
				}
126
127 View Code Duplication
				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
128
					$wpConfig = new EduSveaWebPayTestConfig( $this );
129
				} else {
130
					$wpConfig = new EduSveaWebPayProductionConfig( $this );
131
				}
132
133
				//$response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse();
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
134
135
				$sveaOrderId = get_transient( 'eduadmin-sveaorderid-' . $ebi->EventBooking->EventCustomerLnkID, - 1 );
136
137
				if ( $sveaOrderId > 0 ) {
138
					$wpOrder = WebPay::checkout( $wpConfig );
139
140
					$wpOrder->setCheckoutOrderId( $sveaOrderId );
141
142
					$order = $wpOrder->getOrder();
143
				}
144
145
				if ( 'Cancelled' !== $order['Status'] ) {
0 ignored issues
show
Bug introduced by
The variable $order does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
146
					EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
147
				} else {
148
					EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID );
149
				}
150
151
				$surl    = get_home_url();
152
				$cat     = get_option( 'eduadmin-rewriteBaseUrl' );
153
				$baseUrl = $surl . '/' . $cat;
154
155
				delete_transient( 'eduadmin-sveaorderid-' . $ebi->EventBooking->EventCustomerLnkID );
156
157
				wp_redirect( $baseUrl . '/profile/myprofile?payment=' . ( 'Cancelled' !== $order['Status'] ? '1' : '0' ) );
158
				exit();
159
			}
160
		}
161
162
		/**
163
		 * @param $bookingInfo EduAdminBookingInfo
164
		 */
165
		public function process_booking( $bookingInfo = null ) {
166
			if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
167
				return;
168
			}
169
			if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
170
				$bookingInfo->NoRedirect = true;
171
172
				$countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' );
173
174
				$selectedCountry = 'SE';
175
				$selectedLocale  = 'sv-SE';
176
177
				$invoiceCountry = $bookingInfo->Customer->InvoiceCountry;
178
				if ( empty( $invoiceCountry ) ) {
179
					$invoiceCountry = $bookingInfo->Customer->Country;
180
				}
181
182
				foreach ( $countries as $country ) {
183
					if ( $invoiceCountry == $country->CountryName ) {
184
						$selectedCountry = $country->CountryCode;
185
						if ( ! empty( $country->CultureName ) ) {
186
							$selectedLocale = $country->CultureName;
187
						}
188
						break;
189
					}
190
				}
191
192
				//$selectedLocale = explode( '-', $selectedLocale )[0];
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
193
194
				$currency = get_option( 'eduadmin-currency', 'SEK' );
195
196 View Code Duplication
				if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
					$wpConfig = new EduSveaWebPayTestConfig( $this );
198
				} else {
199
					$wpConfig = new EduSveaWebPayProductionConfig( $this );
200
				}
201
				#$wpOrder = WebPay::createOrder( $wpConfig );
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
202
				$wpOrder = WebPay::checkout( $wpConfig );
203
204
				$orderRow = WebPayItem::orderRow();
205
				$orderRow->setName( $bookingInfo->EventBooking->EventDescription );
206
				$orderRow->setQuantity( 1 );
207
208
				$vatPercent = ( $bookingInfo->EventBooking->VatSum / $bookingInfo->EventBooking->TotalPriceExVat ) * 100;
209
				$orderRow->setVatPercent( $vatPercent );
210
				$orderRow->setAmountIncVat( (float) $bookingInfo->EventBooking->TotalPriceIncVat );
211
212
				$customer = WebPayItem::companyCustomer();
213
214
				if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
215
					$customer->setCompanyName( $bookingInfo->Customer->InvoiceName );
216
				} else {
217
					$customer->setCompanyName( $bookingInfo->Customer->CustomerName );
218
				}
219
220
				if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
221
					$customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 );
222
				} else {
223
					$customer->setStreetAddress( $bookingInfo->Customer->Address1 );
224
				}
225
226
				if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
227
					$customer->setZipCode( $bookingInfo->Customer->InvoiceZip );
228
				} else {
229
					$customer->setZipCode( $bookingInfo->Customer->Zip );
230
				}
231
232
				$zipPreset = WebPayItem::presetValue()
233
				                       ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::POSTAL_CODE )
234
				                       ->setValue( ! empty( $bookingInfo->Customer->InvoiceZip ) ? $bookingInfo->Customer->InvoiceZip : $bookingInfo->Customer->Zip )
235
				                       ->setIsReadonly( false );
236
				$wpOrder->addPresetValue( $zipPreset );
237
238
				if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
239
					$customer->setLocality( $bookingInfo->Customer->InvoiceCity );
240
				} else {
241
					$customer->setLocality( $bookingInfo->Customer->City );
242
				}
243
244
				if ( ! empty( $bookingInfo->Customer->Phone ) ) {
245
					$customer->setPhoneNumber( $bookingInfo->Customer->Phone );
246
					$phonePreset = WebPayItem::presetValue()
247
					                         ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER )
248
					                         ->setValue( $bookingInfo->Customer->Phone )
249
					                         ->setIsReadonly( false );
250
					$wpOrder->addPresetValue( $phonePreset );
251
				}
252
253
				if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
254
					$customer->setEmail( $bookingInfo->Customer->InvoiceEmail );
255
				} else {
256
					$customer->setEmail( $bookingInfo->Customer->Email );
257
				}
258
259
				$emailPreset = WebPayItem::presetValue()
260
				                         ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::EMAIL_ADDRESS )
261
				                         ->setValue( ! empty( $bookingInfo->Customer->InvoiceEmail ) ? $bookingInfo->Customer->InvoiceEmail : $bookingInfo->Customer->Email )
262
				                         ->setIsReadonly( false );
263
				$wpOrder->addPresetValue( $emailPreset );
264
265
				$customer->setIpAddress( EDU()->get_ip_adress() );
266
267
				$surl    = get_home_url();
268
				$cat     = get_option( 'eduadmin-rewriteBaseUrl' );
269
				$baseUrl = $surl . '/' . $cat;
270
271
				$defaultThankYou = @get_page_link( get_option( 'eduadmin-thankYouPage', '/' ) ) . "?edu-thankyou=" . $bookingInfo->EventBooking->EventCustomerLnkID . '&svea=1&svea_order_id={checkout.order.uri}';
0 ignored issues
show
Coding Style introduced by
Silencing errors is discouraged
Loading history...
Coding Style Comprehensibility introduced by
The string literal ?edu-thankyou= does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
272
				$defaultCancel   = $baseUrl . "?edu-cancel=" . $bookingInfo->EventBooking->EventCustomerLnkID . '&svea=1&svea_order_id={checkout.order.uri}';
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ?edu-cancel= does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
273
274
				$defaultPushUrl = $baseUrl . '?edu-thankyou=' . $bookingInfo->EventBooking->EventCustomerLnkID . '&svea=1&svea_order_id={checkout.order.uri}';
275
276
				$defaultTermsUrl = get_option( 'eduadmin-bookingTermsLink' );
277
278
				//$defaultCheckoutUrl = $surl . $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
279
280
				$wpBuild = $wpOrder
281
					->setCurrency( $currency )
282
					->setCountryCode( $selectedCountry )
283
					//->setOrderDate( date( 'c' ) )
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
284
					->setClientOrderNumber( $bookingInfo->EventBooking->EventCustomerLnkID )
285
					->addOrderRow( $orderRow )
286
					//->addCustomerDetails( $customer )
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
287
					//->usePayPage()
288
					//->setPayPageLanguage( $selectedLocale )
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
289
					->setLocale( $selectedLocale )
290
					//->setReturnUrl( apply_filters( 'eduadmin-thankyou-url', $defaultThankYou ) )
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
291
					//->setCancelUrl( apply_filters( 'eduadmin-cancel-url', $defaultCancel ) );
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
292
					->setTermsUri( $defaultTermsUrl )
293
					->setConfirmationUri( $defaultThankYou )
294
					->setPushUri( $defaultPushUrl )
295
					->setCheckoutUri( $defaultCancel ); // We have no "checkout"-url.. So we just cancel the booking instead.
296
				//$wpForm  = $wpBuild->getPaymentUrl();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
297
				$wpForm = $wpBuild->createOrder();
298
299
				set_transient( 'eduadmin-sveaorderid-' . $bookingInfo->EventBooking->EventCustomerLnkID, $wpForm['OrderId'], HOUR_IN_SECONDS );
300
301
				if ( array_key_exists( 'Gui', $wpForm ) ) {
302
					echo $wpForm['Gui']['Snippet'];
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$wpForm'
Loading history...
303
				}
304
				/*if ( $wpForm->accepted ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
305
					if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
306
						echo '<script type="text/javascript">location.href = "' . $wpForm->url . '";</script>';
307
					} else {
308
						echo '<script type="text/javascript">location.href = "' . $wpForm->testurl . '";</script>';
309
					}
310
				} else {
311
					add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
312
						$errors[] = $wpForm->errormessage;
313
					} );
314
				}*/
315
			}
316
		}
317
	}
318
319
endif;