Passed
Push — master ( f95e54...46e064 )
by Brian
04:43
created
includes/class-getpaid-checkout.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -12,168 +12,168 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Get the items and invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving( $invoice );
43
-
44
-		// Save the invoice.
45
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Get the items and invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving( $invoice );
43
+
44
+        // Save the invoice.
45
+        $invoice->recalculate_total();
46 46
         $invoice->save();
47 47
 
48
-		// Send to the gateway.
49
-		$this->post_process_submission( $invoice, $prepared );
50
-	}
48
+        // Send to the gateway.
49
+        $this->post_process_submission( $invoice, $prepared );
50
+    }
51 51
 
52
-	/**
53
-	 * Validates the submission.
54
-	 *
55
-	 */
56
-	protected function validate_submission() {
52
+    /**
53
+     * Validates the submission.
54
+     *
55
+     */
56
+    protected function validate_submission() {
57 57
 
58
-		$submission = $this->payment_form_submission;
59
-		$data       = $submission->get_data();
58
+        $submission = $this->payment_form_submission;
59
+        $data       = $submission->get_data();
60 60
 
61
-		// Do we have an error?
61
+        // Do we have an error?
62 62
         if ( ! empty( $submission->last_error ) ) {
63
-			wp_send_json_error( $submission->last_error );
63
+            wp_send_json_error( $submission->last_error );
64 64
         }
65 65
 
66
-		// We need a billing email.
66
+        // We need a billing email.
67 67
         if ( ! $submission->has_billing_email() || ! is_email( $submission->get_billing_email() ) ) {
68 68
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
69
-		}
69
+        }
70 70
 
71
-		// Non-recurring gateways should not be allowed to process recurring invoices.
72
-		if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
73
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
74
-		}
71
+        // Non-recurring gateways should not be allowed to process recurring invoices.
72
+        if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
73
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
74
+        }
75 75
 	
76
-		// Ensure the gateway is active.
77
-		if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
78
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
79
-		}
76
+        // Ensure the gateway is active.
77
+        if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
78
+            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
79
+        }
80 80
 
81
-		// Clear any existing errors.
82
-		wpinv_clear_errors();
81
+        // Clear any existing errors.
82
+        wpinv_clear_errors();
83 83
 		
84
-		// Allow themes and plugins to hook to errors
85
-		do_action( 'getpaid_checkout_error_checks', $submission );
84
+        // Allow themes and plugins to hook to errors
85
+        do_action( 'getpaid_checkout_error_checks', $submission );
86 86
 		
87
-		// Do we have any errors?
87
+        // Do we have any errors?
88 88
         if ( wpinv_get_errors() ) {
89 89
             wp_send_json_error( getpaid_get_errors_html() );
90
-		}
90
+        }
91 91
 
92
-	}
92
+    }
93 93
 
94
-	/**
95
-	 * Retrieves submission items.
96
-	 *
97
-	 * @return GetPaid_Form_Item[]
98
-	 */
99
-	protected function get_submission_items() {
94
+    /**
95
+     * Retrieves submission items.
96
+     *
97
+     * @return GetPaid_Form_Item[]
98
+     */
99
+    protected function get_submission_items() {
100 100
 
101
-		$items = $this->payment_form_submission->get_items();
101
+        $items = $this->payment_form_submission->get_items();
102 102
 
103 103
         // Ensure that we have items.
104 104
         if ( empty( $items ) && 0 == count( $this->payment_form_submission->get_fees() ) ) {
105 105
             wp_send_json_error( __( 'Please select at least one item.', 'invoicing' ) );
106
-		}
106
+        }
107 107
 
108
-		return $items;
109
-	}
108
+        return $items;
109
+    }
110 110
 
111
-	/**
112
-	 * Retrieves submission invoice.
113
-	 *
114
-	 * @return WPInv_Invoice
115
-	 */
116
-	protected function get_submission_invoice() {
117
-		$submission = $this->payment_form_submission;
111
+    /**
112
+     * Retrieves submission invoice.
113
+     *
114
+     * @return WPInv_Invoice
115
+     */
116
+    protected function get_submission_invoice() {
117
+        $submission = $this->payment_form_submission;
118 118
 
119
-		if ( ! $submission->has_invoice() ) {
120
-			return new WPInv_Invoice();
119
+        if ( ! $submission->has_invoice() ) {
120
+            return new WPInv_Invoice();
121 121
         }
122 122
 
123
-		$invoice = $submission->get_invoice();
123
+        $invoice = $submission->get_invoice();
124 124
 
125
-		// Make sure that it is neither paid or refunded.
126
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
127
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
128
-		}
125
+        // Make sure that it is neither paid or refunded.
126
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
127
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
128
+        }
129 129
 
130
-		return $invoice;
131
-	}
130
+        return $invoice;
131
+    }
132 132
 
133
-	/**
134
-	 * Processes the submission invoice.
135
-	 *
136
-	 * @param WPInv_Invoice $invoice
137
-	 * @param GetPaid_Form_Item[] $items
138
-	 * @return WPInv_Invoice
139
-	 */
140
-	protected function process_submission_invoice( $invoice, $items ) {
133
+    /**
134
+     * Processes the submission invoice.
135
+     *
136
+     * @param WPInv_Invoice $invoice
137
+     * @param GetPaid_Form_Item[] $items
138
+     * @return WPInv_Invoice
139
+     */
140
+    protected function process_submission_invoice( $invoice, $items ) {
141 141
 
142
-		$submission = $this->payment_form_submission;
143
-		$data       = $submission->get_data();
142
+        $submission = $this->payment_form_submission;
143
+        $data       = $submission->get_data();
144 144
 
145
-		// Set-up the invoice details.
146
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
147
-		$invoice->set_user_id( $this->get_submission_customer() );
148
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
145
+        // Set-up the invoice details.
146
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
147
+        $invoice->set_user_id( $this->get_submission_customer() );
148
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
149 149
         $invoice->set_items( $items );
150 150
         $invoice->set_fees( $submission->get_fees() );
151 151
         $invoice->set_taxes( $submission->get_taxes() );
152
-		$invoice->set_discounts( $submission->get_discounts() );
153
-		$invoice->set_gateway( $data['wpi-gateway'] );
152
+        $invoice->set_discounts( $submission->get_discounts() );
153
+        $invoice->set_gateway( $data['wpi-gateway'] );
154 154
 
155
-		if ( $submission->has_discount_code() ) {
155
+        if ( $submission->has_discount_code() ) {
156 156
             $invoice->set_discount_code( $submission->get_discount_code() );
157
-		}
158
-
159
-		getpaid_maybe_add_default_address( $invoice );
160
-		return $invoice;
161
-	}
162
-
163
-	/**
164
-	 * Retrieves the submission's customer.
165
-	 *
166
-	 * @return int The customer id.
167
-	 */
168
-	protected function get_submission_customer() {
169
-		$submission = $this->payment_form_submission;
170
-
171
-		// If this is an existing invoice...
172
-		if ( $submission->has_invoice() ) {
173
-			return $submission->get_invoice()->get_user_id();
174
-		}
175
-
176
-		// (Maybe) create the user.
157
+        }
158
+
159
+        getpaid_maybe_add_default_address( $invoice );
160
+        return $invoice;
161
+    }
162
+
163
+    /**
164
+     * Retrieves the submission's customer.
165
+     *
166
+     * @return int The customer id.
167
+     */
168
+    protected function get_submission_customer() {
169
+        $submission = $this->payment_form_submission;
170
+
171
+        // If this is an existing invoice...
172
+        if ( $submission->has_invoice() ) {
173
+            return $submission->get_invoice()->get_user_id();
174
+        }
175
+
176
+        // (Maybe) create the user.
177 177
         $user = get_current_user_id();
178 178
 
179 179
         if ( empty( $user ) ) {
@@ -190,31 +190,31 @@  discard block
 block discarded – undo
190 190
 
191 191
         if ( is_numeric( $user ) ) {
192 192
             return $user;
193
-		}
193
+        }
194 194
 
195
-		return $user->ID;
195
+        return $user->ID;
196 196
 
197
-	}
197
+    }
198 198
 
199
-	/**
199
+    /**
200 200
      * Prepares submission data for saving to the database.
201 201
      *
202
-	 * @param WPInv_Invoice $invoice
202
+     * @param WPInv_Invoice $invoice
203 203
      */
204 204
     public function prepare_submission_data_for_saving( &$invoice ) {
205 205
 
206
-		$submission = $this->payment_form_submission;
206
+        $submission = $this->payment_form_submission;
207 207
 
208
-		// Prepared submission details.
208
+        // Prepared submission details.
209 209
         $prepared = array();
210 210
 
211 211
         // Raw submission details.
212
-		$data = $submission->get_data();
212
+        $data = $submission->get_data();
213 213
 		
214
-		// Loop throught the submitted details.
214
+        // Loop throught the submitted details.
215 215
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
216 216
 
217
-			// Skip premade fields.
217
+            // Skip premade fields.
218 218
             if ( ! empty( $field['premade'] ) ) {
219 219
                 continue;
220 220
             }
@@ -257,26 +257,26 @@  discard block
 block discarded – undo
257 257
                 $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
258 258
             }
259 259
 
260
-		}
260
+        }
261 261
 		
262
-		return $prepared;
262
+        return $prepared;
263 263
 
264
-	}
264
+    }
265 265
 
266
-	/**
267
-	 * Confirms the submission is valid and send users to the gateway.
268
-	 *
269
-	 * @param WPInv_Invoice $invoice
270
-	 * @param array $prepared_payment_form_data
271
-	 */
272
-	protected function post_process_submission( $invoice, $prepared_payment_form_data ) {
266
+    /**
267
+     * Confirms the submission is valid and send users to the gateway.
268
+     *
269
+     * @param WPInv_Invoice $invoice
270
+     * @param array $prepared_payment_form_data
271
+     */
272
+    protected function post_process_submission( $invoice, $prepared_payment_form_data ) {
273 273
 
274
-		// Ensure the invoice exists.
274
+        // Ensure the invoice exists.
275 275
         if ( $invoice->get_id() == 0 ) {
276 276
             wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) );
277 277
         }
278 278
 
279
-		// Was this invoice created via the payment form?
279
+        // Was this invoice created via the payment form?
280 280
         if ( ! $this->payment_form_submission->has_invoice() ) {
281 281
             update_post_meta( $invoice->get_id(), 'wpinv_created_via', 'payment_form' );
282 282
         }
@@ -284,65 +284,65 @@  discard block
 block discarded – undo
284 284
         // Save payment form data.
285 285
         if ( ! empty( $prepared_payment_form_data ) ) {
286 286
             update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data );
287
-		}
287
+        }
288 288
 
289
-		// Backwards compatibility.
289
+        // Backwards compatibility.
290 290
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
291 291
 
292
-		$this->process_payment( $invoice );
292
+        $this->process_payment( $invoice );
293 293
 
294 294
         // If we are here, there was an error.
295
-		$this->checkout_error();
295
+        $this->checkout_error();
296 296
 
297
-	}
297
+    }
298 298
 
299
-	/**
300
-	 * Processes the actual payment.
301
-	 *
302
-	 * @param WPInv_Invoice $invoice
303
-	 */
304
-	protected function process_payment( $invoice ) {
299
+    /**
300
+     * Processes the actual payment.
301
+     *
302
+     * @param WPInv_Invoice $invoice
303
+     */
304
+    protected function process_payment( $invoice ) {
305 305
 
306
-		$submission = $this->payment_form_submission;
306
+        $submission = $this->payment_form_submission;
307 307
 
308
-		// No need to send free invoices to the gateway.
309
-		if ( $invoice->is_free() ) {
310
-			$invoice->set_gateway( 'none' );
311
-			$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
312
-			$invoice->mark_paid();
313
-			wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
314
-		}
308
+        // No need to send free invoices to the gateway.
309
+        if ( $invoice->is_free() ) {
310
+            $invoice->set_gateway( 'none' );
311
+            $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
312
+            $invoice->mark_paid();
313
+            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
314
+        }
315 315
 
316
-		// Clear any checkout errors.
317
-		wpinv_clear_errors();
316
+        // Clear any checkout errors.
317
+        wpinv_clear_errors();
318 318
 
319
-		// Fires before sending to the gateway.
320
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
319
+        // Fires before sending to the gateway.
320
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
321 321
 
322
-		// Allow the sumission data to be modified before it is sent to the gateway.
323
-		$submission_data    = $submission->get_data();
324
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
325
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
322
+        // Allow the sumission data to be modified before it is sent to the gateway.
323
+        $submission_data    = $submission->get_data();
324
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
325
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
326 326
 
327
-		// Validate the currency.
328
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
329
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
330
-		}
327
+        // Validate the currency.
328
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
329
+            wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
330
+        }
331 331
 
332
-		// Check to see if we have any errors.
333
-		if ( wpinv_get_errors() ) {
334
-			wpinv_send_back_to_checkout();
335
-		}
332
+        // Check to see if we have any errors.
333
+        if ( wpinv_get_errors() ) {
334
+            wpinv_send_back_to_checkout();
335
+        }
336 336
 
337
-		// Send info to the gateway for payment processing
338
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
337
+        // Send info to the gateway for payment processing
338
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
339 339
 
340
-		// Backwards compatibility.
341
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
340
+        // Backwards compatibility.
341
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
342 342
 
343
-	}
343
+    }
344 344
 
345
-	/**
345
+    /**
346 346
      * Sends a redrect response to payment details.
347 347
      *
348 348
      */
Please login to merge, or discard this patch.
includes/wpinv-payment-functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
  */
230 230
 function wpinv_send_back_to_checkout() {
231 231
 
232
-	// Do we have any errors?
232
+    // Do we have any errors?
233 233
     if ( wpinv_get_errors() ) {
234 234
         wp_send_json_error( getpaid_get_errors_html() );
235 235
     }
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34
-	$can_checkout = true; // Always true for now
34
+    $can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+    return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+    $page_id = wpinv_get_option( 'success_page', 0 );
41
+    $page_id = absint( $page_id );
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+    return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
44 44
 }
45 45
 
46 46
 function wpinv_get_history_page_uri() {
47
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
-	$page_id = absint( $page_id );
47
+    $page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
+    $page_id = absint( $page_id );
49 49
 
50
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50
+    return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
51 51
 }
52 52
 
53 53
 function wpinv_is_success_page() {
54
-	$is_success_page = wpinv_get_option( 'success_page', false );
55
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
54
+    $is_success_page = wpinv_get_option( 'success_page', false );
55
+    $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
56 56
 
57
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
57
+    return apply_filters( 'wpinv_is_success_page', $is_success_page );
58 58
 }
59 59
 
60 60
 function wpinv_is_invoice_history_page() {
61
-	$ret = wpinv_get_option( 'invoice_history_page', false );
62
-	$ret = $ret ? is_page( $ret ) : false;
63
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
61
+    $ret = wpinv_get_option( 'invoice_history_page', false );
62
+    $ret = $ret ? is_page( $ret ) : false;
63
+    return apply_filters( 'wpinv_is_invoice_history_page', $ret );
64 64
 }
65 65
 
66 66
 function wpinv_is_subscriptions_history_page() {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 }
84 84
 
85 85
 function wpinv_send_to_failed_page( $args = null ) {
86
-	$redirect = wpinv_get_failed_transaction_uri();
86
+    $redirect = wpinv_get_failed_transaction_uri();
87 87
     
88 88
     if ( !empty( $args ) ) {
89 89
         // Check for backward compatibility
@@ -103,55 +103,55 @@  discard block
 block discarded – undo
103 103
 }
104 104
 
105 105
 function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
106
+    $uri = wpinv_get_option( 'checkout_page', false );
107
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
110
-		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
109
+    if ( !empty( $args ) ) {
110
+        // Check for backward compatibility
111
+        if ( is_string( $args ) )
112
+            $args = str_replace( '?', '', $args );
113 113
 
114
-		$args = wp_parse_args( $args );
114
+        $args = wp_parse_args( $args );
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
117
-	}
116
+        $uri = add_query_arg( $args, $uri );
117
+    }
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
125
-	}
123
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
125
+    }
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
128 128
 }
129 129
 
130 130
 function wpinv_get_success_page_url( $query_string = null ) {
131
-	$success_page = wpinv_get_option( 'success_page', 0 );
132
-	$success_page = get_permalink( $success_page );
131
+    $success_page = wpinv_get_option( 'success_page', 0 );
132
+    $success_page = get_permalink( $success_page );
133 133
 
134
-	if ( $query_string )
135
-		$success_page .= $query_string;
134
+    if ( $query_string )
135
+        $success_page .= $query_string;
136 136
 
137
-	return apply_filters( 'wpinv_success_page_url', $success_page );
137
+    return apply_filters( 'wpinv_success_page_url', $success_page );
138 138
 }
139 139
 
140 140
 function wpinv_get_failed_transaction_uri( $extras = false ) {
141
-	$uri = wpinv_get_option( 'failure_page', '' );
142
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
141
+    $uri = wpinv_get_option( 'failure_page', '' );
142
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
143 143
 
144
-	if ( $extras )
145
-		$uri .= $extras;
144
+    if ( $extras )
145
+        $uri .= $extras;
146 146
 
147
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
147
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
148 148
 }
149 149
 
150 150
 function wpinv_is_failed_transaction_page() {
151
-	$ret = wpinv_get_option( 'failure_page', false );
152
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
151
+    $ret = wpinv_get_option( 'failure_page', false );
152
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
153 153
 
154
-	return apply_filters( 'wpinv_is_failure_page', $ret );
154
+    return apply_filters( 'wpinv_is_failure_page', $ret );
155 155
 }
156 156
 
157 157
 function wpinv_transaction_query( $type = 'start' ) {
@@ -226,36 +226,36 @@  discard block
 block discarded – undo
226 226
     $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
227 227
     
228 228
     if ( $require_billing_details ) {
229
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
230
-			$required_fields['first_name'] = array(
231
-				'error_id' => 'invalid_first_name',
232
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
233
-			);
234
-		}
235
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
236
-			$required_fields['address'] = array(
237
-				'error_id' => 'invalid_address',
238
-				'error_message' => __( 'Please enter your address', 'invoicing' )
239
-			);
240
-		}
241
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
242
-			$required_fields['city'] = array(
243
-				'error_id' => 'invalid_city',
244
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
245
-			);
246
-		}
247
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
248
-			$required_fields['state'] = array(
249
-				'error_id' => 'invalid_state',
250
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
251
-			);
252
-		}
253
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
254
-			$required_fields['country'] = array(
255
-				'error_id' => 'invalid_country',
256
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
257
-			);
258
-		}
229
+        if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
230
+            $required_fields['first_name'] = array(
231
+                'error_id' => 'invalid_first_name',
232
+                'error_message' => __( 'Please enter your first name', 'invoicing' )
233
+            );
234
+        }
235
+        if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
236
+            $required_fields['address'] = array(
237
+                'error_id' => 'invalid_address',
238
+                'error_message' => __( 'Please enter your address', 'invoicing' )
239
+            );
240
+        }
241
+        if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
242
+            $required_fields['city'] = array(
243
+                'error_id' => 'invalid_city',
244
+                'error_message' => __( 'Please enter your billing city', 'invoicing' )
245
+            );
246
+        }
247
+        if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
248
+            $required_fields['state'] = array(
249
+                'error_id' => 'invalid_state',
250
+                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
251
+            );
252
+        }
253
+        if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
254
+            $required_fields['country'] = array(
255
+                'error_id' => 'invalid_country',
256
+                'error_message' => __( 'Please select your billing country', 'invoicing' )
257
+            );
258
+        }
259 259
     }
260 260
 
261 261
     return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
Please login to merge, or discard this patch.