Passed
Push — master ( edf7ac...1b48ee )
by Brian
09:08
created
includes/libraries/wp-all-import/class-getpaid-wp-all-import.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -14,133 +14,133 @@
 block discarded – undo
14 14
  */
15 15
 class GetPaid_WP_All_Import {
16 16
 
17
-	/**
18
-	 * @var RapidAddon[]
19
-	 */
20
-	protected $add_ons;
21
-
22
-	/**
23
-	 * @var array
24
-	 */
25
-	protected $datastores = array(
26
-		'item'     =>'WPInv_Item',
27
-		'invoice'  =>'WPInv_Invoice',
28
-		'discount' =>'WPInv_Discount',
29
-	);
17
+    /**
18
+     * @var RapidAddon[]
19
+     */
20
+    protected $add_ons;
21
+
22
+    /**
23
+     * @var array
24
+     */
25
+    protected $datastores = array(
26
+        'item'     =>'WPInv_Item',
27
+        'invoice'  =>'WPInv_Invoice',
28
+        'discount' =>'WPInv_Discount',
29
+    );
30 30
 
31 31
     /**
32
-	 * Class constructor.
33
-	 */
32
+     * Class constructor.
33
+     */
34 34
     public function __construct() {
35 35
 
36
-		// Init each store separately.
37
-		foreach ( array_keys( $this->datastores ) as $key ) {
38
-			$this->init_store( $key );
39
-		}
36
+        // Init each store separately.
37
+        foreach ( array_keys( $this->datastores ) as $key ) {
38
+            $this->init_store( $key );
39
+        }
40 40
 
41
-	}
41
+    }
42 42
 
43
-	/**
44
-	 * Inits a store.
45
-	 */
43
+    /**
44
+     * Inits a store.
45
+     */
46 46
     public function init_store( $key ) {
47 47
 
48
-		// Register the add-on.
49
-		$this->add_ons[ $key ] = new RapidAddon( 'GetPaid', 'getpaid_wp_al_import_' . $key );
48
+        // Register the add-on.
49
+        $this->add_ons[ $key ] = new RapidAddon( 'GetPaid', 'getpaid_wp_al_import_' . $key );
50 50
 
51
-		// Create import function.
52
-		$import_function = function ( $post_id, $data, $import_options, $_post ) use ( $key ) {
53
-			$this->import_store( $key, $post_id, $data, $import_options, $_post );
51
+        // Create import function.
52
+        $import_function = function ( $post_id, $data, $import_options, $_post ) use ( $key ) {
53
+            $this->import_store( $key, $post_id, $data, $import_options, $_post );
54 54
         };
55 55
 
56
-		$this->add_ons[ $key ]->set_import_function( $import_function );
56
+        $this->add_ons[ $key ]->set_import_function( $import_function );
57 57
 
58
-		// Register store fields.
59
-		$this->add_store_fields( $key );
58
+        // Register store fields.
59
+        $this->add_store_fields( $key );
60 60
 
61
-		// Only load on the correct post type.
62
-		$this->add_ons[ $key ]->run( array( 'post_types' => array( 'wpi_' . $key ) ) );
61
+        // Only load on the correct post type.
62
+        $this->add_ons[ $key ]->run( array( 'post_types' => array( 'wpi_' . $key ) ) );
63 63
 
64
-		// Disable images.
65
-		$this->add_ons[ $key ]->disable_default_images();
64
+        // Disable images.
65
+        $this->add_ons[ $key ]->disable_default_images();
66 66
 
67
-	}
67
+    }
68 68
 
69
-	/**
70
-	 * Retrieves store fields.
71
-	 */
69
+    /**
70
+     * Retrieves store fields.
71
+     */
72 72
     public function get_store_fields( $key ) {
73 73
 
74
-		// Fetch from data/invoice-schema.php, from data/discount-schema.php, from data/item-schema.php
75
-		$fields = wpinv_get_data( $key . '-schema' );
74
+        // Fetch from data/invoice-schema.php, from data/discount-schema.php, from data/item-schema.php
75
+        $fields = wpinv_get_data( $key . '-schema' );
76 76
 
77
-		if ( empty( $fields ) ) {
78
-			return array();
79
-		}
77
+        if ( empty( $fields ) ) {
78
+            return array();
79
+        }
80 80
 
81
-		// Clean the fields.
82
-		$prepared = array();
83
-		foreach ( $fields as $id => $field ) {
81
+        // Clean the fields.
82
+        $prepared = array();
83
+        foreach ( $fields as $id => $field ) {
84 84
 
85
-			// Skip read only fields.
86
-			if ( ! empty( $field['readonly'] ) ) {
87
-				continue;
88
-			}
85
+            // Skip read only fields.
86
+            if ( ! empty( $field['readonly'] ) ) {
87
+                continue;
88
+            }
89 89
 
90
-			$prepared[ $id ] = $field;
90
+            $prepared[ $id ] = $field;
91 91
 
92
-		}
92
+        }
93 93
 
94
-		return $prepared;
94
+        return $prepared;
95 95
 
96
-	}
96
+    }
97 97
 
98
-	/**
99
-	 * Registers store fields.
100
-	 */
98
+    /**
99
+     * Registers store fields.
100
+     */
101 101
     public function add_store_fields( $key ) {
102 102
 
103
-		foreach ( $this->get_store_fields( $key ) as $field_id => $data ) {
104
-			$this->add_ons[ $key ]->add_field( $field_id, $data['description'], 'text' );
105
-		}
103
+        foreach ( $this->get_store_fields( $key ) as $field_id => $data ) {
104
+            $this->add_ons[ $key ]->add_field( $field_id, $data['description'], 'text' );
105
+        }
106 106
 
107 107
     }
108 108
 
109
-	/**
110
-	 * Handles store imports.
111
-	 */
109
+    /**
110
+     * Handles store imports.
111
+     */
112 112
     public function import_store( $key, $post_id, $data, $import_options, $_post ) {
113 113
 
114
-		// Is the store class set?
115
-		if ( ! isset( $this->datastores[ $key ] ) ) {
116
-			return;
117
-		}
114
+        // Is the store class set?
115
+        if ( ! isset( $this->datastores[ $key ] ) ) {
116
+            return;
117
+        }
118 118
 
119
-		/**@var GetPaid_Data */
120
-		$data_store = new $this->datastores[ $key ]( $post_id );
119
+        /**@var GetPaid_Data */
120
+        $data_store = new $this->datastores[ $key ]( $post_id );
121 121
 
122
-		// Abort if the invoice/item/discount does not exist.
123
-		if ( ! $data_store->exists() ) {
124
-			return;
125
-		}
122
+        // Abort if the invoice/item/discount does not exist.
123
+        if ( ! $data_store->exists() ) {
124
+            return;
125
+        }
126 126
 
127
-		// Prepare data props.
128
-		$prepared = array();
127
+        // Prepare data props.
128
+        $prepared = array();
129 129
 
130
-		foreach ( array_keys( $this->get_store_fields( $key ) ) as $field ) { 
131
-			// Make sure the user has allowed this field to be updated.
132
-			if ( empty( $_post['ID'] ) || $this->add_ons[ $key ]->can_update_meta( $field, $import_options ) ) { 
130
+        foreach ( array_keys( $this->get_store_fields( $key ) ) as $field ) { 
131
+            // Make sure the user has allowed this field to be updated.
132
+            if ( empty( $_post['ID'] ) || $this->add_ons[ $key ]->can_update_meta( $field, $import_options ) ) { 
133 133
 	
134
-				// Update the custom field with the imported data.
135
-				$prepared[ $field ] = $data[ $field ];
136
-			} 
137
-		}
138
-
139
-		// Only update if we have something to update.
140
-		if ( ! empty( $prepared ) ) {
141
-			$data_store->set_props( $prepared );
142
-			$data_store->save();
143
-		}
134
+                // Update the custom field with the imported data.
135
+                $prepared[ $field ] = $data[ $field ];
136
+            } 
137
+        }
138
+
139
+        // Only update if we have something to update.
140
+        if ( ! empty( $prepared ) ) {
141
+            $data_store->set_props( $prepared );
142
+            $data_store->save();
143
+        }
144 144
 
145 145
     }
146 146
 
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
  * @package GetPaid
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10
-include plugin_dir_path( __FILE__ ) . 'rapid-addon.php';
10
+include plugin_dir_path(__FILE__) . 'rapid-addon.php';
11 11
 
12 12
 /**
13 13
  * WP All Import class.
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     public function __construct() {
35 35
 
36 36
 		// Init each store separately.
37
-		foreach ( array_keys( $this->datastores ) as $key ) {
38
-			$this->init_store( $key );
37
+		foreach (array_keys($this->datastores) as $key) {
38
+			$this->init_store($key);
39 39
 		}
40 40
 
41 41
 	}
@@ -43,51 +43,51 @@  discard block
 block discarded – undo
43 43
 	/**
44 44
 	 * Inits a store.
45 45
 	 */
46
-    public function init_store( $key ) {
46
+    public function init_store($key) {
47 47
 
48 48
 		// Register the add-on.
49
-		$this->add_ons[ $key ] = new RapidAddon( 'GetPaid', 'getpaid_wp_al_import_' . $key );
49
+		$this->add_ons[$key] = new RapidAddon('GetPaid', 'getpaid_wp_al_import_' . $key);
50 50
 
51 51
 		// Create import function.
52
-		$import_function = function ( $post_id, $data, $import_options, $_post ) use ( $key ) {
53
-			$this->import_store( $key, $post_id, $data, $import_options, $_post );
52
+		$import_function = function($post_id, $data, $import_options, $_post) use ($key) {
53
+			$this->import_store($key, $post_id, $data, $import_options, $_post);
54 54
         };
55 55
 
56
-		$this->add_ons[ $key ]->set_import_function( $import_function );
56
+		$this->add_ons[$key]->set_import_function($import_function);
57 57
 
58 58
 		// Register store fields.
59
-		$this->add_store_fields( $key );
59
+		$this->add_store_fields($key);
60 60
 
61 61
 		// Only load on the correct post type.
62
-		$this->add_ons[ $key ]->run( array( 'post_types' => array( 'wpi_' . $key ) ) );
62
+		$this->add_ons[$key]->run(array('post_types' => array('wpi_' . $key)));
63 63
 
64 64
 		// Disable images.
65
-		$this->add_ons[ $key ]->disable_default_images();
65
+		$this->add_ons[$key]->disable_default_images();
66 66
 
67 67
 	}
68 68
 
69 69
 	/**
70 70
 	 * Retrieves store fields.
71 71
 	 */
72
-    public function get_store_fields( $key ) {
72
+    public function get_store_fields($key) {
73 73
 
74 74
 		// Fetch from data/invoice-schema.php, from data/discount-schema.php, from data/item-schema.php
75
-		$fields = wpinv_get_data( $key . '-schema' );
75
+		$fields = wpinv_get_data($key . '-schema');
76 76
 
77
-		if ( empty( $fields ) ) {
77
+		if (empty($fields)) {
78 78
 			return array();
79 79
 		}
80 80
 
81 81
 		// Clean the fields.
82 82
 		$prepared = array();
83
-		foreach ( $fields as $id => $field ) {
83
+		foreach ($fields as $id => $field) {
84 84
 
85 85
 			// Skip read only fields.
86
-			if ( ! empty( $field['readonly'] ) ) {
86
+			if (!empty($field['readonly'])) {
87 87
 				continue;
88 88
 			}
89 89
 
90
-			$prepared[ $id ] = $field;
90
+			$prepared[$id] = $field;
91 91
 
92 92
 		}
93 93
 
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Registers store fields.
100 100
 	 */
101
-    public function add_store_fields( $key ) {
101
+    public function add_store_fields($key) {
102 102
 
103
-		foreach ( $this->get_store_fields( $key ) as $field_id => $data ) {
104
-			$this->add_ons[ $key ]->add_field( $field_id, $data['description'], 'text' );
103
+		foreach ($this->get_store_fields($key) as $field_id => $data) {
104
+			$this->add_ons[$key]->add_field($field_id, $data['description'], 'text');
105 105
 		}
106 106
 
107 107
     }
@@ -109,36 +109,36 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Handles store imports.
111 111
 	 */
112
-    public function import_store( $key, $post_id, $data, $import_options, $_post ) {
112
+    public function import_store($key, $post_id, $data, $import_options, $_post) {
113 113
 
114 114
 		// Is the store class set?
115
-		if ( ! isset( $this->datastores[ $key ] ) ) {
115
+		if (!isset($this->datastores[$key])) {
116 116
 			return;
117 117
 		}
118 118
 
119 119
 		/**@var GetPaid_Data */
120
-		$data_store = new $this->datastores[ $key ]( $post_id );
120
+		$data_store = new $this->datastores[$key]($post_id);
121 121
 
122 122
 		// Abort if the invoice/item/discount does not exist.
123
-		if ( ! $data_store->exists() ) {
123
+		if (!$data_store->exists()) {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		// Prepare data props.
128 128
 		$prepared = array();
129 129
 
130
-		foreach ( array_keys( $this->get_store_fields( $key ) ) as $field ) { 
130
+		foreach (array_keys($this->get_store_fields($key)) as $field) { 
131 131
 			// Make sure the user has allowed this field to be updated.
132
-			if ( empty( $_post['ID'] ) || $this->add_ons[ $key ]->can_update_meta( $field, $import_options ) ) { 
132
+			if (empty($_post['ID']) || $this->add_ons[$key]->can_update_meta($field, $import_options)) { 
133 133
 	
134 134
 				// Update the custom field with the imported data.
135
-				$prepared[ $field ] = $data[ $field ];
135
+				$prepared[$field] = $data[$field];
136 136
 			} 
137 137
 		}
138 138
 
139 139
 		// Only update if we have something to update.
140
-		if ( ! empty( $prepared ) ) {
141
-			$data_store->set_props( $prepared );
140
+		if (!empty($prepared)) {
141
+			$data_store->set_props($prepared);
142 142
 			$data_store->save();
143 143
 		}
144 144
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/address-fields.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@  discard block
 block discarded – undo
12 12
  * @var GetPaid_Payment_Form $form
13 13
  */
14 14
 
15
-defined( 'ABSPATH' ) || exit;
15
+defined('ABSPATH') || exit;
16 16
 
17
-$field_type = sanitize_key( $field_type );
17
+$field_type = sanitize_key($field_type);
18 18
 
19 19
 echo "<div class='row $field_type'>";
20 20
 
21 21
 // Prepare current user.
22
-if ( ! empty( $form->invoice ) ) {
22
+if (!empty($form->invoice)) {
23 23
     $user_id = $form->invoice->get_user_id();
24 24
 }
25 25
 
26
-if ( empty( $user_id ) && is_user_logged_in() ) {
26
+if (empty($user_id) && is_user_logged_in()) {
27 27
     $user_id = get_current_user_id();
28 28
 }
29 29
 
30
-if ( ! empty( $user_id ) ) {
31
-    $user  = wp_get_current_user();
30
+if (!empty($user_id)) {
31
+    $user = wp_get_current_user();
32 32
 }
33 33
 
34
-foreach ( $fields as $address_field ) {
34
+foreach ($fields as $address_field) {
35 35
 
36 36
     // Skip if it is hidden.
37
-    if ( empty( $address_field['visible'] ) ) {
37
+    if (empty($address_field['visible'])) {
38 38
         continue;
39 39
     }
40 40
 
41
-    do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field );
41
+    do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field);
42 42
 
43 43
     // Prepare variables.
44 44
     $field_name  = $address_field['name'];
45 45
     $field_name  = "{$field_type}[$field_name]";
46
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
47
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
48
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
49
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
50
-    $value       = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : '';
51
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
52
-
53
-    $method_name = 'get_' . str_replace( 'wpinv_', '', $address_field['name'] );
54
-    if ( ! empty( $form->invoice ) && is_callable( array( $form->invoice, $method_name ) ) ) {
55
-        $value = call_user_func( array( $form->invoice, $method_name ) );
46
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
47
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
48
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
49
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
50
+    $value       = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : '';
51
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
52
+
53
+    $method_name = 'get_' . str_replace('wpinv_', '', $address_field['name']);
54
+    if (!empty($form->invoice) && is_callable(array($form->invoice, $method_name))) {
55
+        $value = call_user_func(array($form->invoice, $method_name));
56 56
     }
57 57
 
58
-    if ( empty( $value ) && 'wpinv_first_name' == $address_field['name'] && ! empty( $user ) ) {
58
+    if (empty($value) && 'wpinv_first_name' == $address_field['name'] && !empty($user)) {
59 59
         $value = $user->first_name;
60 60
     }
61 61
 
62
-    if ( empty( $value ) && 'wpinv_last_name' == $address_field['name'] && ! empty( $user ) ) {
62
+    if (empty($value) && 'wpinv_last_name' == $address_field['name'] && !empty($user)) {
63 63
         $value = $user->last_name;
64 64
     }
65 65
 
66
-    if ( ! empty( $address_field['required'] ) ) {
66
+    if (!empty($address_field['required'])) {
67 67
         $label .= "<span class='text-danger'> *</span>";
68 68
     }
69 69
 
70 70
     // Display the country.
71
-    if ( 'wpinv_country' == $address_field['name'] ) {
71
+    if ('wpinv_country' == $address_field['name']) {
72 72
 
73 73
         echo "<div class='form-group $wrap_class getpaid-address-field-wrapper__country'";
74 74
 
75 75
         echo aui()->select(
76 76
             array(
77 77
                 'options'     => wpinv_get_country_list(),
78
-                'name'        => esc_attr( $field_name ),
79
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
80
-                'value'       => esc_attr( $country ),
78
+                'name'        => esc_attr($field_name),
79
+                'id'          => sanitize_html_class($field_name) . $uniqid,
80
+                'value'       => esc_attr($country),
81 81
                 'placeholder' => $placeholder,
82
-                'required'    => ! empty( $address_field['required'] ),
83
-                'label'       => wp_kses_post( $label ),
82
+                'required'    => !empty($address_field['required']),
83
+                'label'       => wp_kses_post($label),
84 84
                 'label_type'  => 'vertical',
85 85
                 'help_text'   => $description,
86 86
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             )
94 94
         );
95 95
 
96
-        if ( wpinv_should_validate_vat_number() ) {
96
+        if (wpinv_should_validate_vat_number()) {
97 97
 
98 98
             echo aui()->input(
99 99
                 array(
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                     'id'         => "shipping-toggle$uniqid",
103 103
                     'wrap_class' => "getpaid-address-field-wrapper__address-confirm mt-1 d-none",
104 104
                     'required'   => false,
105
-                    'label'      => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>",
105
+                    'label'      => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>",
106 106
                     'value'      => 1,
107 107
                     'checked'    => true,
108 108
                     'class'      => 'w-auto',
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
     // Display the state.
119
-    else if ( 'wpinv_state' == $address_field['name'] ) {
119
+    else if ('wpinv_state' == $address_field['name']) {
120 120
 
121
-        if ( empty( $value ) ) {
121
+        if (empty($value)) {
122 122
             $value = wpinv_get_default_state();
123 123
         }
124 124
 
125
-        echo getpaid_get_states_select_markup (
125
+        echo getpaid_get_states_select_markup(
126 126
             $country,
127 127
             $value,
128 128
             $placeholder,
129 129
             $label,
130 130
             $description,
131
-            ! empty( $address_field['required'] ),
131
+            !empty($address_field['required']),
132 132
             $wrap_class,
133 133
             $field_name
134 134
         );
135 135
 
136 136
     } else {
137 137
 
138
-        $key      = str_replace( 'wpinv_', '', $address_field['name'] );
139
-        $key      = esc_attr( str_replace( '_', '-', $key ) );
138
+        $key      = str_replace('wpinv_', '', $address_field['name']);
139
+        $key      = esc_attr(str_replace('_', '-', $key));
140 140
         $autocomplete = '';
141 141
         $replacements = array(
142 142
             'zip'        => 'postal-code',
@@ -149,37 +149,37 @@  discard block
 block discarded – undo
149 149
         );
150 150
 
151 151
 
152
-        if ( isset( $replacements[ $key ] ) ) {
152
+        if (isset($replacements[$key])) {
153 153
             $autocomplete = array(
154
-                'autocomplete' => "$field_type {$replacements[ $key ]}",
154
+                'autocomplete' => "$field_type {$replacements[$key]}",
155 155
             );
156 156
         }
157 157
 
158 158
         $append = '';
159 159
 
160
-        if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) {
161
-            $valid    = esc_attr__( 'Valid', 'invoicing' );
162
-            $invalid  = esc_attr__( 'Invalid', 'invoicing' );
163
-            $validate = esc_attr__( 'Validate', 'invoicing' );
160
+        if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) {
161
+            $valid    = esc_attr__('Valid', 'invoicing');
162
+            $invalid  = esc_attr__('Invalid', 'invoicing');
163
+            $validate = esc_attr__('Validate', 'invoicing');
164 164
             $append   = "<span class='btn btn-primary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>";
165 165
         }
166 166
 
167
-        if ( 'billing' === $field_type ) {
168
-            $description .= '<div class="getpaid-error-' . sanitize_html_class( $field_name ) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>';
167
+        if ('billing' === $field_type) {
168
+            $description .= '<div class="getpaid-error-' . sanitize_html_class($field_name) . ' getpaid-custom-payment-form-errors alert alert-danger d-none"></div>';
169 169
         }
170 170
 
171 171
         echo aui()->input(
172 172
             array(
173
-                'name'        => esc_attr( $field_name ),
174
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
175
-                'required'    => ! empty( $address_field['required'] ),
173
+                'name'        => esc_attr($field_name),
174
+                'id'          => sanitize_html_class($field_name) . $uniqid,
175
+                'required'    => !empty($address_field['required']),
176 176
                 'placeholder' => $placeholder,
177
-                'label'       => wp_kses_post( $label ),
177
+                'label'       => wp_kses_post($label),
178 178
                 'label_type'  => 'vertical',
179 179
                 'help_text'   => $description,
180 180
                 'type'        => 'text',
181
-                'value'       => esc_attr( $value ),
182
-                'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
181
+                'value'       => esc_attr($value),
182
+                'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
183 183
                 'wrap_class'  => "$wrap_class getpaid-address-field-wrapper__$key",
184 184
                 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
185 185
                 'extra_attributes'  => $autocomplete,
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     }
191 191
 
192
-    do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field );
192
+    do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field);
193 193
 }
194 194
 
195 195
 echo "</div>";
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class InstalledVersions
13 13
 {
14 14
 private static $installed = array (
15
-  'root' => 
16
-  array (
15
+    'root' => 
16
+    array (
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
@@ -21,96 +21,96 @@  discard block
 block discarded – undo
21 21
     ),
22 22
     'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
23 23
     'name' => 'ayecode/invoicing',
24
-  ),
25
-  'versions' => 
26
-  array (
24
+    ),
25
+    'versions' => 
26
+    array (
27 27
     'ayecode/ayecode-connect-helper' => 
28 28
     array (
29
-      'pretty_version' => '1.0.3',
30
-      'version' => '1.0.3.0',
31
-      'aliases' => 
32
-      array (
33
-      ),
34
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
29
+        'pretty_version' => '1.0.3',
30
+        'version' => '1.0.3.0',
31
+        'aliases' => 
32
+        array (
33
+        ),
34
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37 37
     array (
38
-      'pretty_version' => 'dev-master',
39
-      'version' => 'dev-master',
40
-      'aliases' => 
41
-      array (
42
-      ),
43
-      'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.62',
48
-      'version' => '0.1.62.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
47
+        'pretty_version' => '0.1.62',
48
+        'version' => '0.1.62.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
53 53
     ),
54 54
     'ayecode/wp-deactivation-survey' => 
55 55
     array (
56
-      'pretty_version' => '1.0.4',
57
-      'version' => '1.0.4.0',
58
-      'aliases' => 
59
-      array (
60
-      ),
61
-      'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
56
+        'pretty_version' => '1.0.4',
57
+        'version' => '1.0.4.0',
58
+        'aliases' => 
59
+        array (
60
+        ),
61
+        'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
62 62
     ),
63 63
     'ayecode/wp-font-awesome-settings' => 
64 64
     array (
65
-      'pretty_version' => '1.0.13',
66
-      'version' => '1.0.13.0',
67
-      'aliases' => 
68
-      array (
69
-      ),
70
-      'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
65
+        'pretty_version' => '1.0.13',
66
+        'version' => '1.0.13.0',
67
+        'aliases' => 
68
+        array (
69
+        ),
70
+        'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
71 71
     ),
72 72
     'ayecode/wp-super-duper' => 
73 73
     array (
74
-      'pretty_version' => '1.0.27',
75
-      'version' => '1.0.27.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
74
+        'pretty_version' => '1.0.27',
75
+        'version' => '1.0.27.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
80 80
     ),
81 81
     'composer/installers' => 
82 82
     array (
83
-      'pretty_version' => 'v1.12.0',
84
-      'version' => '1.12.0.0',
85
-      'aliases' => 
86
-      array (
87
-      ),
88
-      'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
83
+        'pretty_version' => 'v1.12.0',
84
+        'version' => '1.12.0.0',
85
+        'aliases' => 
86
+        array (
87
+        ),
88
+        'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
89 89
     ),
90 90
     'maxmind-db/reader' => 
91 91
     array (
92
-      'pretty_version' => 'v1.6.0',
93
-      'version' => '1.6.0.0',
94
-      'aliases' => 
95
-      array (
96
-      ),
97
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
92
+        'pretty_version' => 'v1.6.0',
93
+        'version' => '1.6.0.0',
94
+        'aliases' => 
95
+        array (
96
+        ),
97
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
98 98
     ),
99 99
     'roundcube/plugin-installer' => 
100 100
     array (
101
-      'replaced' => 
102
-      array (
101
+        'replaced' => 
102
+        array (
103 103
         0 => '*',
104
-      ),
104
+        ),
105 105
     ),
106 106
     'shama/baton' => 
107 107
     array (
108
-      'replaced' => 
109
-      array (
108
+        'replaced' => 
109
+        array (
110 110
         0 => '*',
111
-      ),
111
+        ),
112
+    ),
112 113
     ),
113
-  ),
114 114
 );
115 115
 
116 116
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,102 +11,102 @@
 block discarded – undo
11 11
 
12 12
 class InstalledVersions
13 13
 {
14
-private static $installed = array (
14
+private static $installed = array(
15 15
   'root' => 
16
-  array (
16
+  array(
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
20
-    array (
20
+    array(
21 21
     ),
22 22
     'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
23 23
     'name' => 'ayecode/invoicing',
24 24
   ),
25 25
   'versions' => 
26
-  array (
26
+  array(
27 27
     'ayecode/ayecode-connect-helper' => 
28
-    array (
28
+    array(
29 29
       'pretty_version' => '1.0.3',
30 30
       'version' => '1.0.3.0',
31 31
       'aliases' => 
32
-      array (
32
+      array(
33 33
       ),
34 34
       'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37
-    array (
37
+    array(
38 38
       'pretty_version' => 'dev-master',
39 39
       'version' => 'dev-master',
40 40
       'aliases' => 
41
-      array (
41
+      array(
42 42
       ),
43 43
       'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46
-    array (
46
+    array(
47 47
       'pretty_version' => '0.1.62',
48 48
       'version' => '0.1.62.0',
49 49
       'aliases' => 
50
-      array (
50
+      array(
51 51
       ),
52 52
       'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
53 53
     ),
54 54
     'ayecode/wp-deactivation-survey' => 
55
-    array (
55
+    array(
56 56
       'pretty_version' => '1.0.4',
57 57
       'version' => '1.0.4.0',
58 58
       'aliases' => 
59
-      array (
59
+      array(
60 60
       ),
61 61
       'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
62 62
     ),
63 63
     'ayecode/wp-font-awesome-settings' => 
64
-    array (
64
+    array(
65 65
       'pretty_version' => '1.0.13',
66 66
       'version' => '1.0.13.0',
67 67
       'aliases' => 
68
-      array (
68
+      array(
69 69
       ),
70 70
       'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
71 71
     ),
72 72
     'ayecode/wp-super-duper' => 
73
-    array (
73
+    array(
74 74
       'pretty_version' => '1.0.27',
75 75
       'version' => '1.0.27.0',
76 76
       'aliases' => 
77
-      array (
77
+      array(
78 78
       ),
79 79
       'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
80 80
     ),
81 81
     'composer/installers' => 
82
-    array (
82
+    array(
83 83
       'pretty_version' => 'v1.12.0',
84 84
       'version' => '1.12.0.0',
85 85
       'aliases' => 
86
-      array (
86
+      array(
87 87
       ),
88 88
       'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
89 89
     ),
90 90
     'maxmind-db/reader' => 
91
-    array (
91
+    array(
92 92
       'pretty_version' => 'v1.6.0',
93 93
       'version' => '1.6.0.0',
94 94
       'aliases' => 
95
-      array (
95
+      array(
96 96
       ),
97 97
       'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
98 98
     ),
99 99
     'roundcube/plugin-installer' => 
100
-    array (
100
+    array(
101 101
       'replaced' => 
102
-      array (
102
+      array(
103 103
         0 => '*',
104 104
       ),
105 105
     ),
106 106
     'shama/baton' => 
107
-    array (
107
+    array(
108 108
       'replaced' => 
109
-      array (
109
+      array(
110 110
         0 => '*',
111 111
       ),
112 112
     ),
Please login to merge, or discard this patch.
vendor/composer/installed.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php return array (
2
-  'root' => 
3
-  array (
2
+    'root' => 
3
+    array (
4 4
     'pretty_version' => 'dev-master',
5 5
     'version' => 'dev-master',
6 6
     'aliases' => 
@@ -8,94 +8,94 @@  discard block
 block discarded – undo
8 8
     ),
9 9
     'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
10 10
     'name' => 'ayecode/invoicing',
11
-  ),
12
-  'versions' => 
13
-  array (
11
+    ),
12
+    'versions' => 
13
+    array (
14 14
     'ayecode/ayecode-connect-helper' => 
15 15
     array (
16
-      'pretty_version' => '1.0.3',
17
-      'version' => '1.0.3.0',
18
-      'aliases' => 
19
-      array (
20
-      ),
21
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
16
+        'pretty_version' => '1.0.3',
17
+        'version' => '1.0.3.0',
18
+        'aliases' => 
19
+        array (
20
+        ),
21
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
22 22
     ),
23 23
     'ayecode/invoicing' => 
24 24
     array (
25
-      'pretty_version' => 'dev-master',
26
-      'version' => 'dev-master',
27
-      'aliases' => 
28
-      array (
29
-      ),
30
-      'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
25
+        'pretty_version' => 'dev-master',
26
+        'version' => 'dev-master',
27
+        'aliases' => 
28
+        array (
29
+        ),
30
+        'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
31 31
     ),
32 32
     'ayecode/wp-ayecode-ui' => 
33 33
     array (
34
-      'pretty_version' => '0.1.62',
35
-      'version' => '0.1.62.0',
36
-      'aliases' => 
37
-      array (
38
-      ),
39
-      'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
34
+        'pretty_version' => '0.1.62',
35
+        'version' => '0.1.62.0',
36
+        'aliases' => 
37
+        array (
38
+        ),
39
+        'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
40 40
     ),
41 41
     'ayecode/wp-deactivation-survey' => 
42 42
     array (
43
-      'pretty_version' => '1.0.4',
44
-      'version' => '1.0.4.0',
45
-      'aliases' => 
46
-      array (
47
-      ),
48
-      'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
43
+        'pretty_version' => '1.0.4',
44
+        'version' => '1.0.4.0',
45
+        'aliases' => 
46
+        array (
47
+        ),
48
+        'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
49 49
     ),
50 50
     'ayecode/wp-font-awesome-settings' => 
51 51
     array (
52
-      'pretty_version' => '1.0.13',
53
-      'version' => '1.0.13.0',
54
-      'aliases' => 
55
-      array (
56
-      ),
57
-      'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
52
+        'pretty_version' => '1.0.13',
53
+        'version' => '1.0.13.0',
54
+        'aliases' => 
55
+        array (
56
+        ),
57
+        'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
58 58
     ),
59 59
     'ayecode/wp-super-duper' => 
60 60
     array (
61
-      'pretty_version' => '1.0.27',
62
-      'version' => '1.0.27.0',
63
-      'aliases' => 
64
-      array (
65
-      ),
66
-      'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
61
+        'pretty_version' => '1.0.27',
62
+        'version' => '1.0.27.0',
63
+        'aliases' => 
64
+        array (
65
+        ),
66
+        'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
67 67
     ),
68 68
     'composer/installers' => 
69 69
     array (
70
-      'pretty_version' => 'v1.12.0',
71
-      'version' => '1.12.0.0',
72
-      'aliases' => 
73
-      array (
74
-      ),
75
-      'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
70
+        'pretty_version' => 'v1.12.0',
71
+        'version' => '1.12.0.0',
72
+        'aliases' => 
73
+        array (
74
+        ),
75
+        'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
76 76
     ),
77 77
     'maxmind-db/reader' => 
78 78
     array (
79
-      'pretty_version' => 'v1.6.0',
80
-      'version' => '1.6.0.0',
81
-      'aliases' => 
82
-      array (
83
-      ),
84
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
79
+        'pretty_version' => 'v1.6.0',
80
+        'version' => '1.6.0.0',
81
+        'aliases' => 
82
+        array (
83
+        ),
84
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
85 85
     ),
86 86
     'roundcube/plugin-installer' => 
87 87
     array (
88
-      'replaced' => 
89
-      array (
88
+        'replaced' => 
89
+        array (
90 90
         0 => '*',
91
-      ),
91
+        ),
92 92
     ),
93 93
     'shama/baton' => 
94 94
     array (
95
-      'replaced' => 
96
-      array (
95
+        'replaced' => 
96
+        array (
97 97
         0 => '*',
98
-      ),
98
+        ),
99
+    ),
99 100
     ),
100
-  ),
101 101
 );
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,99 +1,99 @@
 block discarded – undo
1
-<?php return array (
1
+<?php return array(
2 2
   'root' => 
3
-  array (
3
+  array(
4 4
     'pretty_version' => 'dev-master',
5 5
     'version' => 'dev-master',
6 6
     'aliases' => 
7
-    array (
7
+    array(
8 8
     ),
9 9
     'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
10 10
     'name' => 'ayecode/invoicing',
11 11
   ),
12 12
   'versions' => 
13
-  array (
13
+  array(
14 14
     'ayecode/ayecode-connect-helper' => 
15
-    array (
15
+    array(
16 16
       'pretty_version' => '1.0.3',
17 17
       'version' => '1.0.3.0',
18 18
       'aliases' => 
19
-      array (
19
+      array(
20 20
       ),
21 21
       'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
22 22
     ),
23 23
     'ayecode/invoicing' => 
24
-    array (
24
+    array(
25 25
       'pretty_version' => 'dev-master',
26 26
       'version' => 'dev-master',
27 27
       'aliases' => 
28
-      array (
28
+      array(
29 29
       ),
30 30
       'reference' => 'c77c76d2bb821dfd39f6e97602e1fc972f810df8',
31 31
     ),
32 32
     'ayecode/wp-ayecode-ui' => 
33
-    array (
33
+    array(
34 34
       'pretty_version' => '0.1.62',
35 35
       'version' => '0.1.62.0',
36 36
       'aliases' => 
37
-      array (
37
+      array(
38 38
       ),
39 39
       'reference' => 'f0625aa6f695cef39fe75bc1707026824e9841d9',
40 40
     ),
41 41
     'ayecode/wp-deactivation-survey' => 
42
-    array (
42
+    array(
43 43
       'pretty_version' => '1.0.4',
44 44
       'version' => '1.0.4.0',
45 45
       'aliases' => 
46
-      array (
46
+      array(
47 47
       ),
48 48
       'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
49 49
     ),
50 50
     'ayecode/wp-font-awesome-settings' => 
51
-    array (
51
+    array(
52 52
       'pretty_version' => '1.0.13',
53 53
       'version' => '1.0.13.0',
54 54
       'aliases' => 
55
-      array (
55
+      array(
56 56
       ),
57 57
       'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
58 58
     ),
59 59
     'ayecode/wp-super-duper' => 
60
-    array (
60
+    array(
61 61
       'pretty_version' => '1.0.27',
62 62
       'version' => '1.0.27.0',
63 63
       'aliases' => 
64
-      array (
64
+      array(
65 65
       ),
66 66
       'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
67 67
     ),
68 68
     'composer/installers' => 
69
-    array (
69
+    array(
70 70
       'pretty_version' => 'v1.12.0',
71 71
       'version' => '1.12.0.0',
72 72
       'aliases' => 
73
-      array (
73
+      array(
74 74
       ),
75 75
       'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
76 76
     ),
77 77
     'maxmind-db/reader' => 
78
-    array (
78
+    array(
79 79
       'pretty_version' => 'v1.6.0',
80 80
       'version' => '1.6.0.0',
81 81
       'aliases' => 
82
-      array (
82
+      array(
83 83
       ),
84 84
       'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
85 85
     ),
86 86
     'roundcube/plugin-installer' => 
87
-    array (
87
+    array(
88 88
       'replaced' => 
89
-      array (
89
+      array(
90 90
         0 => '*',
91 91
       ),
92 92
     ),
93 93
     'shama/baton' => 
94
-    array (
94
+    array(
95 95
       'replaced' => 
96
-      array (
96
+      array(
97 97
         0 => '*',
98 98
       ),
99 99
     ),
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.62";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.62";
19
+    if(version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.62";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-refresh-prices.php 2 patches
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -12,294 +12,294 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Refresh_Prices {
14 14
 
15
-	/**
16
-	 * Contains the response for refreshing prices.
17
-	 * @var array
18
-	 */
19
-	public $response = array();
15
+    /**
16
+     * Contains the response for refreshing prices.
17
+     * @var array
18
+     */
19
+    public $response = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$this->response = array(
29
-			'submission_id'                    => $submission->id,
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $this->response = array(
29
+            'submission_id'                    => $submission->id,
30 30
             'has_recurring'                    => $submission->has_recurring,
31
-			'has_subscription_group'           => $submission->has_subscription_group(),
32
-			'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(),
31
+            'has_subscription_group'           => $submission->has_subscription_group(),
32
+            'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(),
33 33
             'is_free'                          => ! $submission->should_collect_payment_details(),
34
-		);
35
-
36
-		$this->add_totals( $submission );
37
-		$this->add_texts( $submission );
38
-		$this->add_items( $submission );
39
-		$this->add_fees( $submission );
40
-		$this->add_discounts( $submission );
41
-		$this->add_taxes( $submission );
42
-		$this->add_gateways( $submission );
43
-		$this->add_data( $submission );
44
-
45
-	}
46
-
47
-	/**
48
-	 * Adds totals to a response for submission refresh prices.
49
-	 *
50
-	 * @param GetPaid_Payment_Form_Submission $submission
51
-	 */
52
-	public function add_totals( $submission ) {
53
-
54
-		$this->response = array_merge(
55
-			$this->response,
56
-			array(
57
-
58
-				'totals'        => array(
59
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
60
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
61
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
62
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
63
-					'total'     => $submission->format_amount( $submission->get_total() ),
64
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
65
-				),
66
-
67
-				'recurring'     => array(
68
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
69
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
70
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
71
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
72
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
73
-				),
74
-
75
-				'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
76
-				'currency'      => $submission->get_currency(),
77
-
78
-			)
79
-		);
80
-
81
-	}
82
-
83
-	/**
84
-	 * Adds texts to a response for submission refresh prices.
85
-	 *
86
-	 * @param GetPaid_Payment_Form_Submission $submission
87
-	 */
88
-	public function add_texts( $submission ) {
89
-
90
-		$payable = $submission->format_amount( $submission->get_total() );
91
-		$groups  = getpaid_get_subscription_groups( $submission );
92
-
93
-		if ( $submission->has_recurring && 2 > count( $groups ) ) {
94
-
95
-			$recurring = new WPInv_Item( $submission->has_recurring );
96
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
97
-			$main_item = reset( $groups );
98
-
99
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
100
-				$payable = "$payable / $period";
101
-			} else if ( $main_item ) {
102
-
103
-				$main_item = reset( $main_item );
104
-
105
-				// Calculate the next renewal date.
106
-				$_period      = $main_item->get_recurring_period( true );
107
-				$_interval    = $main_item->get_recurring_interval();
108
-
109
-				// If the subscription item has a trial period...
110
-				if ( $main_item->has_free_trial() ) {
111
-					$_period   = $main_item->get_trial_period( true );
112
-					$_interval = $main_item->get_trial_interval();
113
-				}
114
-
115
-				$payable = sprintf(
116
-					__( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
117
-					$submission->format_amount( $submission->get_total() ),
118
-					$submission->format_amount( $submission->get_recurring_total() ),
119
-					$period
120
-				);
121
-
122
-				$payable .= sprintf(
123
-					'<small class="text-muted form-text">%s</small>',
124
-					sprintf(
125
-						__( 'First renewal on %s', 'invoicing' ),
126
-						getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) )
127
-					)
128
-				);
129
-
130
-			} else {
131
-				$payable = sprintf(
132
-					__( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
133
-					$submission->format_amount( $submission->get_total() ),
134
-					$submission->format_amount( $submission->get_recurring_total() ),
135
-					$period
136
-				);
137
-			}
138
-
139
-		}
140
-
141
-		$texts = array(
142
-			'.getpaid-checkout-total-payable' => $payable,
143
-		);
144
-
145
-		foreach ( $submission->get_items() as $item ) {
146
-			$item_id                                               = $item->get_id();
147
-			$initial_price                                         = $submission->format_amount( $item->get_sub_total() - $item->item_discount );
148
-			$recurring_price                                       = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount );
149
-			$texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price );
150
-			$texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) );
151
-
152
-			if ( $item->get_quantity() == 1 ) {
153
-				$texts[".item-$item_id .getpaid-mobile-item-subtotal"] = '';
154
-			}
155
-
156
-		}
157
-
158
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
159
-
160
-	}
161
-
162
-	/**
163
-	 * Adds items to a response for submission refresh prices.
164
-	 *
165
-	 * @param GetPaid_Payment_Form_Submission $submission
166
-	 */
167
-	public function add_items( $submission ) {
168
-
169
-		// Add items.
170
-		$items = array();
34
+        );
35
+
36
+        $this->add_totals( $submission );
37
+        $this->add_texts( $submission );
38
+        $this->add_items( $submission );
39
+        $this->add_fees( $submission );
40
+        $this->add_discounts( $submission );
41
+        $this->add_taxes( $submission );
42
+        $this->add_gateways( $submission );
43
+        $this->add_data( $submission );
44
+
45
+    }
46
+
47
+    /**
48
+     * Adds totals to a response for submission refresh prices.
49
+     *
50
+     * @param GetPaid_Payment_Form_Submission $submission
51
+     */
52
+    public function add_totals( $submission ) {
53
+
54
+        $this->response = array_merge(
55
+            $this->response,
56
+            array(
57
+
58
+                'totals'        => array(
59
+                    'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
60
+                    'discount'  => $submission->format_amount( $submission->get_discount() ),
61
+                    'fees'      => $submission->format_amount( $submission->get_fee() ),
62
+                    'tax'       => $submission->format_amount( $submission->get_tax() ),
63
+                    'total'     => $submission->format_amount( $submission->get_total() ),
64
+                    'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
65
+                ),
66
+
67
+                'recurring'     => array(
68
+                    'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
69
+                    'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
70
+                    'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
71
+                    'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
72
+                    'total'     => $submission->format_amount( $submission->get_recurring_total() ),
73
+                ),
74
+
75
+                'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
76
+                'currency'      => $submission->get_currency(),
77
+
78
+            )
79
+        );
80
+
81
+    }
82
+
83
+    /**
84
+     * Adds texts to a response for submission refresh prices.
85
+     *
86
+     * @param GetPaid_Payment_Form_Submission $submission
87
+     */
88
+    public function add_texts( $submission ) {
89
+
90
+        $payable = $submission->format_amount( $submission->get_total() );
91
+        $groups  = getpaid_get_subscription_groups( $submission );
92
+
93
+        if ( $submission->has_recurring && 2 > count( $groups ) ) {
94
+
95
+            $recurring = new WPInv_Item( $submission->has_recurring );
96
+            $period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
97
+            $main_item = reset( $groups );
98
+
99
+            if ( $submission->get_total() == $submission->get_recurring_total() ) {
100
+                $payable = "$payable / $period";
101
+            } else if ( $main_item ) {
102
+
103
+                $main_item = reset( $main_item );
104
+
105
+                // Calculate the next renewal date.
106
+                $_period      = $main_item->get_recurring_period( true );
107
+                $_interval    = $main_item->get_recurring_interval();
108
+
109
+                // If the subscription item has a trial period...
110
+                if ( $main_item->has_free_trial() ) {
111
+                    $_period   = $main_item->get_trial_period( true );
112
+                    $_interval = $main_item->get_trial_interval();
113
+                }
114
+
115
+                $payable = sprintf(
116
+                    __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
117
+                    $submission->format_amount( $submission->get_total() ),
118
+                    $submission->format_amount( $submission->get_recurring_total() ),
119
+                    $period
120
+                );
121
+
122
+                $payable .= sprintf(
123
+                    '<small class="text-muted form-text">%s</small>',
124
+                    sprintf(
125
+                        __( 'First renewal on %s', 'invoicing' ),
126
+                        getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) )
127
+                    )
128
+                );
129
+
130
+            } else {
131
+                $payable = sprintf(
132
+                    __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
133
+                    $submission->format_amount( $submission->get_total() ),
134
+                    $submission->format_amount( $submission->get_recurring_total() ),
135
+                    $period
136
+                );
137
+            }
138
+
139
+        }
140
+
141
+        $texts = array(
142
+            '.getpaid-checkout-total-payable' => $payable,
143
+        );
144
+
145
+        foreach ( $submission->get_items() as $item ) {
146
+            $item_id                                               = $item->get_id();
147
+            $initial_price                                         = $submission->format_amount( $item->get_sub_total() - $item->item_discount );
148
+            $recurring_price                                       = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount );
149
+            $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price );
150
+            $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) );
151
+
152
+            if ( $item->get_quantity() == 1 ) {
153
+                $texts[".item-$item_id .getpaid-mobile-item-subtotal"] = '';
154
+            }
155
+
156
+        }
157
+
158
+        $this->response = array_merge( $this->response, array( 'texts' => $texts ) );
159
+
160
+    }
161
+
162
+    /**
163
+     * Adds items to a response for submission refresh prices.
164
+     *
165
+     * @param GetPaid_Payment_Form_Submission $submission
166
+     */
167
+    public function add_items( $submission ) {
168
+
169
+        // Add items.
170
+        $items = array();
171 171
 
172 172
         foreach ( $submission->get_items() as $item ) {
173
-			$item_id           = $item->get_id();
174
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
175
-		}
173
+            $item_id           = $item->get_id();
174
+            $items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
175
+        }
176 176
 
177
-		$this->response = array_merge(
178
-			$this->response,
179
-			array( 'items' => $items )
180
-		);
177
+        $this->response = array_merge(
178
+            $this->response,
179
+            array( 'items' => $items )
180
+        );
181 181
 
182
-	}
182
+    }
183 183
 
184
-	/**
185
-	 * Adds fees to a response for submission refresh prices.
186
-	 *
187
-	 * @param GetPaid_Payment_Form_Submission $submission
188
-	 */
189
-	public function add_fees( $submission ) {
184
+    /**
185
+     * Adds fees to a response for submission refresh prices.
186
+     *
187
+     * @param GetPaid_Payment_Form_Submission $submission
188
+     */
189
+    public function add_fees( $submission ) {
190 190
 
191
-		$fees = array();
191
+        $fees = array();
192 192
 
193 193
         foreach ( $submission->get_fees() as $name => $data ) {
194
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
195
-		}
194
+            $fees[$name] = $submission->format_amount( $data['initial_fee'] );
195
+        }
196 196
 
197
-		$this->response = array_merge(
198
-			$this->response,
199
-			array( 'fees' => $fees )
200
-		);
197
+        $this->response = array_merge(
198
+            $this->response,
199
+            array( 'fees' => $fees )
200
+        );
201 201
 
202
-	}
202
+    }
203 203
 
204
-	/**
205
-	 * Adds discounts to a response for submission refresh prices.
206
-	 *
207
-	 * @param GetPaid_Payment_Form_Submission $submission
208
-	 */
209
-	public function add_discounts( $submission ) {
204
+    /**
205
+     * Adds discounts to a response for submission refresh prices.
206
+     *
207
+     * @param GetPaid_Payment_Form_Submission $submission
208
+     */
209
+    public function add_discounts( $submission ) {
210 210
 
211
-		$discounts = array();
211
+        $discounts = array();
212 212
 
213 213
         foreach ( $submission->get_discounts() as $name => $data ) {
214
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
215
-		}
214
+            $discounts[$name] = $submission->format_amount( $data['initial_discount'] );
215
+        }
216 216
 
217
-		$this->response = array_merge(
218
-			$this->response,
219
-			array( 'discounts' => $discounts )
220
-		);
217
+        $this->response = array_merge(
218
+            $this->response,
219
+            array( 'discounts' => $discounts )
220
+        );
221 221
 
222
-	}
222
+    }
223 223
 
224
-	/**
225
-	 * Adds taxes to a response for submission refresh prices.
226
-	 *
227
-	 * @param GetPaid_Payment_Form_Submission $submission
228
-	 */
229
-	public function add_taxes( $submission ) {
230
-
231
-		$taxes  = array();
232
-		$markup = '';
224
+    /**
225
+     * Adds taxes to a response for submission refresh prices.
226
+     *
227
+     * @param GetPaid_Payment_Form_Submission $submission
228
+     */
229
+    public function add_taxes( $submission ) {
230
+
231
+        $taxes  = array();
232
+        $markup = '';
233 233
         foreach ( $submission->get_taxes() as $name => $data ) {
234
-			$name          = sanitize_text_field( $name );
235
-			$amount        = $submission->format_amount( $data['initial_tax'] );
236
-			$taxes[$name]  = $amount;
237
-			$markup       .= "<small class='form-text'>$name : $amount</small>";
238
-		}
239
-
240
-		if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) {
241
-			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
242
-		}
243
-
244
-		$this->response = array_merge(
245
-			$this->response,
246
-			array( 'taxes' => $taxes )
247
-		);
248
-
249
-	}
250
-
251
-	/**
252
-	 * Adds gateways to a response for submission refresh prices.
253
-	 *
254
-	 * @param GetPaid_Payment_Form_Submission $submission
255
-	 */
256
-	public function add_gateways( $submission ) {
257
-
258
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
259
-
260
-		if ( $this->response['has_recurring'] ) {
261
-
262
-			foreach ( $gateways as $i => $gateway ) {
263
-
264
-				if (
265
-					! getpaid_payment_gateway_supports( $gateway, 'subscription' )
266
-					|| ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) )
267
-					|| ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) {
268
-					unset( $gateways[ $i ] );
269
-				}
270
-
271
-			}
272
-
273
-		}
274
-
275
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
276
-		$this->response = array_merge(
277
-			$this->response,
278
-			array( 'gateways' => $gateways )
279
-		);
280
-
281
-	}
282
-
283
-	/**
284
-	 * Adds data to a response for submission refresh prices.
285
-	 *
286
-	 * @param GetPaid_Payment_Form_Submission $submission
287
-	 */
288
-	public function add_data( $submission ) {
289
-
290
-		$this->response = array_merge(
291
-			$this->response,
292
-			array(
293
-				'js_data' => apply_filters(
294
-					'getpaid_submission_js_data',
295
-					array(
296
-						'is_recurring' => $this->response['has_recurring'],
297
-					),
298
-					$submission
299
-				)
300
-			)
301
-		);
302
-
303
-	}
234
+            $name          = sanitize_text_field( $name );
235
+            $amount        = $submission->format_amount( $data['initial_tax'] );
236
+            $taxes[$name]  = $amount;
237
+            $markup       .= "<small class='form-text'>$name : $amount</small>";
238
+        }
239
+
240
+        if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) {
241
+            $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
242
+        }
243
+
244
+        $this->response = array_merge(
245
+            $this->response,
246
+            array( 'taxes' => $taxes )
247
+        );
248
+
249
+    }
250
+
251
+    /**
252
+     * Adds gateways to a response for submission refresh prices.
253
+     *
254
+     * @param GetPaid_Payment_Form_Submission $submission
255
+     */
256
+    public function add_gateways( $submission ) {
257
+
258
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
259
+
260
+        if ( $this->response['has_recurring'] ) {
261
+
262
+            foreach ( $gateways as $i => $gateway ) {
263
+
264
+                if (
265
+                    ! getpaid_payment_gateway_supports( $gateway, 'subscription' )
266
+                    || ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) )
267
+                    || ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) {
268
+                    unset( $gateways[ $i ] );
269
+                }
270
+
271
+            }
272
+
273
+        }
274
+
275
+        $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
276
+        $this->response = array_merge(
277
+            $this->response,
278
+            array( 'gateways' => $gateways )
279
+        );
280
+
281
+    }
282
+
283
+    /**
284
+     * Adds data to a response for submission refresh prices.
285
+     *
286
+     * @param GetPaid_Payment_Form_Submission $submission
287
+     */
288
+    public function add_data( $submission ) {
289
+
290
+        $this->response = array_merge(
291
+            $this->response,
292
+            array(
293
+                'js_data' => apply_filters(
294
+                    'getpaid_submission_js_data',
295
+                    array(
296
+                        'is_recurring' => $this->response['has_recurring'],
297
+                    ),
298
+                    $submission
299
+                )
300
+            )
301
+        );
302
+
303
+    }
304 304
 
305 305
 }
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission refresh prices class
@@ -23,24 +23,24 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$this->response = array(
29 29
 			'submission_id'                    => $submission->id,
30 30
             'has_recurring'                    => $submission->has_recurring,
31 31
 			'has_subscription_group'           => $submission->has_subscription_group(),
32 32
 			'has_multiple_subscription_groups' => $submission->has_multiple_subscription_groups(),
33
-            'is_free'                          => ! $submission->should_collect_payment_details(),
33
+            'is_free'                          => !$submission->should_collect_payment_details(),
34 34
 		);
35 35
 
36
-		$this->add_totals( $submission );
37
-		$this->add_texts( $submission );
38
-		$this->add_items( $submission );
39
-		$this->add_fees( $submission );
40
-		$this->add_discounts( $submission );
41
-		$this->add_taxes( $submission );
42
-		$this->add_gateways( $submission );
43
-		$this->add_data( $submission );
36
+		$this->add_totals($submission);
37
+		$this->add_texts($submission);
38
+		$this->add_items($submission);
39
+		$this->add_fees($submission);
40
+		$this->add_discounts($submission);
41
+		$this->add_taxes($submission);
42
+		$this->add_gateways($submission);
43
+		$this->add_data($submission);
44 44
 
45 45
 	}
46 46
 
@@ -49,30 +49,30 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param GetPaid_Payment_Form_Submission $submission
51 51
 	 */
52
-	public function add_totals( $submission ) {
52
+	public function add_totals($submission) {
53 53
 
54 54
 		$this->response = array_merge(
55 55
 			$this->response,
56 56
 			array(
57 57
 
58 58
 				'totals'        => array(
59
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
60
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
61
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
62
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
63
-					'total'     => $submission->format_amount( $submission->get_total() ),
64
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
59
+					'subtotal'  => $submission->format_amount($submission->get_subtotal()),
60
+					'discount'  => $submission->format_amount($submission->get_discount()),
61
+					'fees'      => $submission->format_amount($submission->get_fee()),
62
+					'tax'       => $submission->format_amount($submission->get_tax()),
63
+					'total'     => $submission->format_amount($submission->get_total()),
64
+					'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES),
65 65
 				),
66 66
 
67 67
 				'recurring'     => array(
68
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
69
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
70
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
71
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
72
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
68
+					'subtotal'  => $submission->format_amount($submission->get_recurring_subtotal()),
69
+					'discount'  => $submission->format_amount($submission->get_recurring_discount()),
70
+					'fees'      => $submission->format_amount($submission->get_recurring_fee()),
71
+					'tax'       => $submission->format_amount($submission->get_recurring_tax()),
72
+					'total'     => $submission->format_amount($submission->get_recurring_total()),
73 73
 				),
74 74
 
75
-				'initial_amt'   => wpinv_round_amount( $submission->get_total(), null, true ),
75
+				'initial_amt'   => wpinv_round_amount($submission->get_total(), null, true),
76 76
 				'currency'      => $submission->get_currency(),
77 77
 
78 78
 			)
@@ -85,53 +85,53 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param GetPaid_Payment_Form_Submission $submission
87 87
 	 */
88
-	public function add_texts( $submission ) {
88
+	public function add_texts($submission) {
89 89
 
90
-		$payable = $submission->format_amount( $submission->get_total() );
91
-		$groups  = getpaid_get_subscription_groups( $submission );
90
+		$payable = $submission->format_amount($submission->get_total());
91
+		$groups  = getpaid_get_subscription_groups($submission);
92 92
 
93
-		if ( $submission->has_recurring && 2 > count( $groups ) ) {
93
+		if ($submission->has_recurring && 2 > count($groups)) {
94 94
 
95
-			$recurring = new WPInv_Item( $submission->has_recurring );
96
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
97
-			$main_item = reset( $groups );
95
+			$recurring = new WPInv_Item($submission->has_recurring);
96
+			$period    = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), '');
97
+			$main_item = reset($groups);
98 98
 
99
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
99
+			if ($submission->get_total() == $submission->get_recurring_total()) {
100 100
 				$payable = "$payable / $period";
101
-			} else if ( $main_item ) {
101
+			} else if ($main_item) {
102 102
 
103
-				$main_item = reset( $main_item );
103
+				$main_item = reset($main_item);
104 104
 
105 105
 				// Calculate the next renewal date.
106
-				$_period      = $main_item->get_recurring_period( true );
106
+				$_period      = $main_item->get_recurring_period(true);
107 107
 				$_interval    = $main_item->get_recurring_interval();
108 108
 
109 109
 				// If the subscription item has a trial period...
110
-				if ( $main_item->has_free_trial() ) {
111
-					$_period   = $main_item->get_trial_period( true );
110
+				if ($main_item->has_free_trial()) {
111
+					$_period   = $main_item->get_trial_period(true);
112 112
 					$_interval = $main_item->get_trial_interval();
113 113
 				}
114 114
 
115 115
 				$payable = sprintf(
116
-					__( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
117
-					$submission->format_amount( $submission->get_total() ),
118
-					$submission->format_amount( $submission->get_recurring_total() ),
116
+					__('%1$s (renews at %2$s / %3$s)', 'invoicing'),
117
+					$submission->format_amount($submission->get_total()),
118
+					$submission->format_amount($submission->get_recurring_total()),
119 119
 					$period
120 120
 				);
121 121
 
122 122
 				$payable .= sprintf(
123 123
 					'<small class="text-muted form-text">%s</small>',
124 124
 					sprintf(
125
-						__( 'First renewal on %s', 'invoicing' ),
126
-						getpaid_format_date( date( 'Y-m-d H:i:s', strtotime( "+$_interval $_period", current_time( 'timestamp' ) ) ) )
125
+						__('First renewal on %s', 'invoicing'),
126
+						getpaid_format_date(date('Y-m-d H:i:s', strtotime("+$_interval $_period", current_time('timestamp'))))
127 127
 					)
128 128
 				);
129 129
 
130 130
 			} else {
131 131
 				$payable = sprintf(
132
-					__( '%1$s (renews at %2$s / %3$s)', 'invoicing' ),
133
-					$submission->format_amount( $submission->get_total() ),
134
-					$submission->format_amount( $submission->get_recurring_total() ),
132
+					__('%1$s (renews at %2$s / %3$s)', 'invoicing'),
133
+					$submission->format_amount($submission->get_total()),
134
+					$submission->format_amount($submission->get_recurring_total()),
135 135
 					$period
136 136
 				);
137 137
 			}
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 			'.getpaid-checkout-total-payable' => $payable,
143 143
 		);
144 144
 
145
-		foreach ( $submission->get_items() as $item ) {
145
+		foreach ($submission->get_items() as $item) {
146 146
 			$item_id                                               = $item->get_id();
147
-			$initial_price                                         = $submission->format_amount( $item->get_sub_total() - $item->item_discount );
148
-			$recurring_price                                       = $submission->format_amount( $item->get_recurring_sub_total() - $item->recurring_item_discount );
149
-			$texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price );
150
-			$texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf( __( 'Subtotal: %s', 'invoicing' ), $submission->format_amount( $item->get_sub_total() ) );
147
+			$initial_price                                         = $submission->format_amount($item->get_sub_total() - $item->item_discount);
148
+			$recurring_price                                       = $submission->format_amount($item->get_recurring_sub_total() - $item->recurring_item_discount);
149
+			$texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price);
150
+			$texts[".item-$item_id .getpaid-mobile-item-subtotal"] = sprintf(__('Subtotal: %s', 'invoicing'), $submission->format_amount($item->get_sub_total()));
151 151
 
152
-			if ( $item->get_quantity() == 1 ) {
152
+			if ($item->get_quantity() == 1) {
153 153
 				$texts[".item-$item_id .getpaid-mobile-item-subtotal"] = '';
154 154
 			}
155 155
 
156 156
 		}
157 157
 
158
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
158
+		$this->response = array_merge($this->response, array('texts' => $texts));
159 159
 
160 160
 	}
161 161
 
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @param GetPaid_Payment_Form_Submission $submission
166 166
 	 */
167
-	public function add_items( $submission ) {
167
+	public function add_items($submission) {
168 168
 
169 169
 		// Add items.
170 170
 		$items = array();
171 171
 
172
-        foreach ( $submission->get_items() as $item ) {
172
+        foreach ($submission->get_items() as $item) {
173 173
 			$item_id           = $item->get_id();
174
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
174
+			$items["$item_id"] = $submission->format_amount($item->get_sub_total());
175 175
 		}
176 176
 
177 177
 		$this->response = array_merge(
178 178
 			$this->response,
179
-			array( 'items' => $items )
179
+			array('items' => $items)
180 180
 		);
181 181
 
182 182
 	}
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @param GetPaid_Payment_Form_Submission $submission
188 188
 	 */
189
-	public function add_fees( $submission ) {
189
+	public function add_fees($submission) {
190 190
 
191 191
 		$fees = array();
192 192
 
193
-        foreach ( $submission->get_fees() as $name => $data ) {
194
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
193
+        foreach ($submission->get_fees() as $name => $data) {
194
+			$fees[$name] = $submission->format_amount($data['initial_fee']);
195 195
 		}
196 196
 
197 197
 		$this->response = array_merge(
198 198
 			$this->response,
199
-			array( 'fees' => $fees )
199
+			array('fees' => $fees)
200 200
 		);
201 201
 
202 202
 	}
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param GetPaid_Payment_Form_Submission $submission
208 208
 	 */
209
-	public function add_discounts( $submission ) {
209
+	public function add_discounts($submission) {
210 210
 
211 211
 		$discounts = array();
212 212
 
213
-        foreach ( $submission->get_discounts() as $name => $data ) {
214
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
213
+        foreach ($submission->get_discounts() as $name => $data) {
214
+			$discounts[$name] = $submission->format_amount($data['initial_discount']);
215 215
 		}
216 216
 
217 217
 		$this->response = array_merge(
218 218
 			$this->response,
219
-			array( 'discounts' => $discounts )
219
+			array('discounts' => $discounts)
220 220
 		);
221 221
 
222 222
 	}
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @param GetPaid_Payment_Form_Submission $submission
228 228
 	 */
229
-	public function add_taxes( $submission ) {
229
+	public function add_taxes($submission) {
230 230
 
231 231
 		$taxes  = array();
232 232
 		$markup = '';
233
-        foreach ( $submission->get_taxes() as $name => $data ) {
234
-			$name          = sanitize_text_field( $name );
235
-			$amount        = $submission->format_amount( $data['initial_tax'] );
233
+        foreach ($submission->get_taxes() as $name => $data) {
234
+			$name          = sanitize_text_field($name);
235
+			$amount        = $submission->format_amount($data['initial_tax']);
236 236
 			$taxes[$name]  = $amount;
237 237
 			$markup       .= "<small class='form-text'>$name : $amount</small>";
238 238
 		}
239 239
 
240
-		if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) {
240
+		if (wpinv_display_individual_tax_rates() && !empty($taxes)) {
241 241
 			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
242 242
 		}
243 243
 
244 244
 		$this->response = array_merge(
245 245
 			$this->response,
246
-			array( 'taxes' => $taxes )
246
+			array('taxes' => $taxes)
247 247
 		);
248 248
 
249 249
 	}
@@ -253,29 +253,29 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param GetPaid_Payment_Form_Submission $submission
255 255
 	 */
256
-	public function add_gateways( $submission ) {
256
+	public function add_gateways($submission) {
257 257
 
258
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
258
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
259 259
 
260
-		if ( $this->response['has_recurring'] ) {
260
+		if ($this->response['has_recurring']) {
261 261
 
262
-			foreach ( $gateways as $i => $gateway ) {
262
+			foreach ($gateways as $i => $gateway) {
263 263
 
264 264
 				if (
265
-					! getpaid_payment_gateway_supports( $gateway, 'subscription' )
266
-					|| ( $this->response['has_subscription_group'] && ! getpaid_payment_gateway_supports( $gateway, 'single_subscription_group' ) )
267
-					|| ( $this->response['has_multiple_subscription_groups'] && ! getpaid_payment_gateway_supports( $gateway, 'multiple_subscription_groups' ) ) ) {
268
-					unset( $gateways[ $i ] );
265
+					!getpaid_payment_gateway_supports($gateway, 'subscription')
266
+					|| ($this->response['has_subscription_group'] && !getpaid_payment_gateway_supports($gateway, 'single_subscription_group'))
267
+					|| ($this->response['has_multiple_subscription_groups'] && !getpaid_payment_gateway_supports($gateway, 'multiple_subscription_groups')) ) {
268
+					unset($gateways[$i]);
269 269
 				}
270 270
 
271 271
 			}
272 272
 
273 273
 		}
274 274
 
275
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
275
+		$gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission);
276 276
 		$this->response = array_merge(
277 277
 			$this->response,
278
-			array( 'gateways' => $gateways )
278
+			array('gateways' => $gateways)
279 279
 		);
280 280
 
281 281
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @param GetPaid_Payment_Form_Submission $submission
287 287
 	 */
288
-	public function add_data( $submission ) {
288
+	public function add_data($submission) {
289 289
 
290 290
 		$this->response = array_merge(
291 291
 			$this->response,
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -26,112 +26,112 @@  discard block
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
31 31
 
32
-					// Item name.
33
-					if ( 'name' == $key ) {
32
+                    // Item name.
33
+                    if ( 'name' == $key ) {
34 34
 
35
-						ob_start();
36
-						// And an optional description.
35
+                        ob_start();
36
+                        // And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39 39
                         if ( ! empty( $description ) ) {
40 40
                             $description = wp_kses_post( $description );
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
-						}
42
+                        }
43 43
 
44
-						// Price help text.
44
+                        // Price help text.
45 45
                         $description = getpaid_item_recurring_price_help_text( $item, $currency );
46 46
                         if ( $description ) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48
-						}
48
+                        }
49 49
 
50
-						do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
50
+                        do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
51 51
 
52
-						if ( wpinv_current_user_can_manage_invoicing() ) {
52
+                        if ( wpinv_current_user_can_manage_invoicing() ) {
53 53
 
54
-							edit_post_link(
55
-								__( 'Edit this item.', 'invoicing' ),
56
-								'<small class="form-text text-muted">',
57
-								'</small>',
58
-								$item->get_id(),
59
-								'text-danger'
60
-							);
54
+                            edit_post_link(
55
+                                __( 'Edit this item.', 'invoicing' ),
56
+                                '<small class="form-text text-muted">',
57
+                                '</small>',
58
+                                $item->get_id(),
59
+                                'text-danger'
60
+                            );
61 61
 
62
-						}
62
+                        }
63 63
 
64
-						$description = ob_get_clean();
64
+                        $description = ob_get_clean();
65 65
 
66
-						// Display the name.
67
-						$tootip = empty( $description ) ? '' : "&nbsp;" . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . $tootip . '</div>';
66
+                        // Display the name.
67
+                        $tootip = empty( $description ) ? '' : "&nbsp;" . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
+                        echo '<div class="mb-1">' . esc_html( $item->get_name() ) . $tootip . '</div>';
69 69
 
70
-						if ( ! empty( $description ) ) {
71
-							printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
72
-						}
73
-
74
-						if ( $item->allows_quantities() ) {
75
-							printf(
76
-								'<small class="d-sm-none text-muted form-text">%s</small>',
77
-								sprintf(
78
-									__( 'Qty %s', 'invoicing' ),
79
-									sprintf(
80
-										'<input
70
+                        if ( ! empty( $description ) ) {
71
+                            printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
72
+                        }
73
+
74
+                        if ( $item->allows_quantities() ) {
75
+                            printf(
76
+                                '<small class="d-sm-none text-muted form-text">%s</small>',
77
+                                sprintf(
78
+                                    __( 'Qty %s', 'invoicing' ),
79
+                                    sprintf(
80
+                                        '<input
81 81
 											type="text"
82 82
 											style="width: 48px;"
83 83
 											class="getpaid-item-mobile-quantity-input p-1 m-0 text-center"
84 84
 											value="%s"
85 85
 											min="1">',
86
-											(float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity()
87
-									)
88
-								)
89
-							);
90
-						} else {
91
-							printf(
92
-								'<small class="d-sm-none text-muted form-text">%s</small>',
93
-								sprintf(
94
-									__( 'Qty %s', 'invoicing' ),
95
-									(float) $item->get_quantity()
96
-								)
97
-							);
98
-						}
99
-
100
-					}
101
-
102
-					// Item price.
103
-					if ( 'price' == $key ) {
104
-
105
-						// Set the currency position.
106
-						$position = wpinv_currency_position();
107
-
108
-						if ( $position == 'left_space' ) {
109
-							$position = 'left';
110
-						}
111
-
112
-						if ( $position == 'right_space' ) {
113
-							$position = 'right';
114
-						}
115
-
116
-						if ( $item->user_can_set_their_price() ) {
117
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
118
-							$minimum          = (float) $item->get_minimum_price();
119
-							$validate_minimum = '';
120
-							$class            = '';
121
-							$data_minimum     = '';
122
-
123
-							if ( $minimum > 0 ) {
124
-								$validate_minimum = sprintf(
125
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
126
-									strip_tags( wpinv_price( $minimum, $currency ) )
127
-								);
128
-
129
-								$class = 'getpaid-validate-minimum-amount';
130
-
131
-								$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
132
-							}
133
-
134
-							?>
86
+                                            (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity()
87
+                                    )
88
+                                )
89
+                            );
90
+                        } else {
91
+                            printf(
92
+                                '<small class="d-sm-none text-muted form-text">%s</small>',
93
+                                sprintf(
94
+                                    __( 'Qty %s', 'invoicing' ),
95
+                                    (float) $item->get_quantity()
96
+                                )
97
+                            );
98
+                        }
99
+
100
+                    }
101
+
102
+                    // Item price.
103
+                    if ( 'price' == $key ) {
104
+
105
+                        // Set the currency position.
106
+                        $position = wpinv_currency_position();
107
+
108
+                        if ( $position == 'left_space' ) {
109
+                            $position = 'left';
110
+                        }
111
+
112
+                        if ( $position == 'right_space' ) {
113
+                            $position = 'right';
114
+                        }
115
+
116
+                        if ( $item->user_can_set_their_price() ) {
117
+                            $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
118
+                            $minimum          = (float) $item->get_minimum_price();
119
+                            $validate_minimum = '';
120
+                            $class            = '';
121
+                            $data_minimum     = '';
122
+
123
+                            if ( $minimum > 0 ) {
124
+                                $validate_minimum = sprintf(
125
+                                    esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
126
+                                    strip_tags( wpinv_price( $minimum, $currency ) )
127
+                                );
128
+
129
+                                $class = 'getpaid-validate-minimum-amount';
130
+
131
+                                $data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
132
+                            }
133
+
134
+                            ?>
135 135
 								<div class="input-group input-group-sm">
136 136
 									<?php if( 'left' == $position ) : ?>
137 137
 										<div class="input-group-prepend">
@@ -156,44 +156,44 @@  discard block
 block discarded – undo
156 156
 
157 157
 							<?php
158 158
 
159
-						} else {
160
-							echo wpinv_price( $item->get_price(), $currency );
159
+                        } else {
160
+                            echo wpinv_price( $item->get_price(), $currency );
161 161
 
162
-							?>
162
+                            ?>
163 163
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
164 164
 							<?php
165
-						}
165
+                        }
166 166
 
167
-						printf(
168
-							'<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
169
-							sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) )
170
-						);
171
-					}
167
+                        printf(
168
+                            '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
169
+                            sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) )
170
+                        );
171
+                    }
172 172
 
173
-					// Item quantity.
174
-					if ( 'quantity' == $key ) {
173
+                    // Item quantity.
174
+                    if ( 'quantity' == $key ) {
175 175
 
176
-						if ( $item->allows_quantities() ) {
177
-							?>
176
+                        if ( $item->allows_quantities() ) {
177
+                            ?>
178 178
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' required>
179 179
 							<?php
180
-						} else {
181
-							echo (float) $item->get_quantity();
182
-							echo '&nbsp;&nbsp;&nbsp;';
183
-							?>
180
+                        } else {
181
+                            echo (float) $item->get_quantity();
182
+                            echo '&nbsp;&nbsp;&nbsp;';
183
+                            ?>
184 184
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
185 185
 							<?php
186
-						}
186
+                        }
187 187
 
188
-					}
188
+                    }
189 189
 
190
-					// Item sub total.
191
-					if ( 'subtotal' == $key ) {
192
-						echo wpinv_price( $item->get_sub_total(), $currency );
193
-					}
190
+                    // Item sub total.
191
+                    if ( 'subtotal' == $key ) {
192
+                        echo wpinv_price( $item->get_sub_total(), $currency );
193
+                    }
194 194
 
195
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
196
-				?>
195
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
196
+                ?>
197 197
 
198 198
 			</div>
199 199
 
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -9,50 +9,50 @@  discard block
 block discarded – undo
9 9
  * @var GetPaid_Form_Item $item
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
14
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
15 15
 
16 16
 $currency = $form->get_currency();
17 17
 
18 18
 ?>
19
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
19
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
20 20
 
21 21
 	<div class="form-row needs-validation">
22 22
 
23
-		<?php foreach ( array_keys( $columns ) as $key ) : ?>
23
+		<?php foreach (array_keys($columns) as $key) : ?>
24 24
 
25
-			<div class="<?php echo 'name' == $key ? 'col-6' : 'col' ?> <?php echo ( in_array( $key, array( 'subtotal', 'quantity', 'tax_rate' ) ) ) ? 'd-none d-sm-block' : '' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>">
25
+			<div class="<?php echo 'name' == $key ? 'col-6' : 'col' ?> <?php echo (in_array($key, array('subtotal', 'quantity', 'tax_rate'))) ? 'd-none d-sm-block' : '' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>">
26 26
 
27 27
 				<?php
28 28
 
29 29
 					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
30
+					do_action("getpaid_form_cart_item_before_$key", $item, $form);
31 31
 
32 32
 					// Item name.
33
-					if ( 'name' == $key ) {
33
+					if ('name' == $key) {
34 34
 
35 35
 						ob_start();
36 36
 						// And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39
-                        if ( ! empty( $description ) ) {
40
-                            $description = wp_kses_post( $description );
39
+                        if (!empty($description)) {
40
+                            $description = wp_kses_post($description);
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42 42
 						}
43 43
 
44 44
 						// Price help text.
45
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-                        if ( $description ) {
45
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
46
+                        if ($description) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48 48
 						}
49 49
 
50
-						do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
50
+						do_action('getpaid_payment_form_cart_item_description', $item, $form);
51 51
 
52
-						if ( wpinv_current_user_can_manage_invoicing() ) {
52
+						if (wpinv_current_user_can_manage_invoicing()) {
53 53
 
54 54
 							edit_post_link(
55
-								__( 'Edit this item.', 'invoicing' ),
55
+								__('Edit this item.', 'invoicing'),
56 56
 								'<small class="form-text text-muted">',
57 57
 								'</small>',
58 58
 								$item->get_id(),
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 						$description = ob_get_clean();
65 65
 
66 66
 						// Display the name.
67
-						$tootip = empty( $description ) ? '' : "&nbsp;" . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . $tootip . '</div>';
67
+						$tootip = empty($description) ? '' : "&nbsp;" . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
+						echo '<div class="mb-1">' . esc_html($item->get_name()) . $tootip . '</div>';
69 69
 
70
-						if ( ! empty( $description ) ) {
71
-							printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
70
+						if (!empty($description)) {
71
+							printf('<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description);
72 72
 						}
73 73
 
74
-						if ( $item->allows_quantities() ) {
74
+						if ($item->allows_quantities()) {
75 75
 							printf(
76 76
 								'<small class="d-sm-none text-muted form-text">%s</small>',
77 77
 								sprintf(
78
-									__( 'Qty %s', 'invoicing' ),
78
+									__('Qty %s', 'invoicing'),
79 79
 									sprintf(
80 80
 										'<input
81 81
 											type="text"
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 							printf(
92 92
 								'<small class="d-sm-none text-muted form-text">%s</small>',
93 93
 								sprintf(
94
-									__( 'Qty %s', 'invoicing' ),
94
+									__('Qty %s', 'invoicing'),
95 95
 									(float) $item->get_quantity()
96 96
 								)
97 97
 							);
@@ -100,56 +100,56 @@  discard block
 block discarded – undo
100 100
 					}
101 101
 
102 102
 					// Item price.
103
-					if ( 'price' == $key ) {
103
+					if ('price' == $key) {
104 104
 
105 105
 						// Set the currency position.
106 106
 						$position = wpinv_currency_position();
107 107
 
108
-						if ( $position == 'left_space' ) {
108
+						if ($position == 'left_space') {
109 109
 							$position = 'left';
110 110
 						}
111 111
 
112
-						if ( $position == 'right_space' ) {
112
+						if ($position == 'right_space') {
113 113
 							$position = 'right';
114 114
 						}
115 115
 
116
-						if ( $item->user_can_set_their_price() ) {
117
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
116
+						if ($item->user_can_set_their_price()) {
117
+							$price            = max((float) $item->get_price(), (float) $item->get_minimum_price());
118 118
 							$minimum          = (float) $item->get_minimum_price();
119 119
 							$validate_minimum = '';
120 120
 							$class            = '';
121 121
 							$data_minimum     = '';
122 122
 
123
-							if ( $minimum > 0 ) {
123
+							if ($minimum > 0) {
124 124
 								$validate_minimum = sprintf(
125
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
126
-									strip_tags( wpinv_price( $minimum, $currency ) )
125
+									esc_attr__('The minimum allowed amount is %s', 'invoicing'),
126
+									strip_tags(wpinv_price($minimum, $currency))
127 127
 								);
128 128
 
129 129
 								$class = 'getpaid-validate-minimum-amount';
130 130
 
131
-								$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
131
+								$data_minimum = "data-minimum-amount='" . esc_attr(getpaid_unstandardize_amount($minimum)) . "'";
132 132
 							}
133 133
 
134 134
 							?>
135 135
 								<div class="input-group input-group-sm">
136
-									<?php if( 'left' == $position ) : ?>
136
+									<?php if ('left' == $position) : ?>
137 137
 										<div class="input-group-prepend">
138
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
138
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
139 139
 										</div>
140 140
 									<?php endif; ?>
141 141
 
142
-									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
142
+									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr(getpaid_unstandardize_amount($price)); ?>" placeholder="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price())); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
143 143
 
144
-									<?php if ( ! empty( $validate_minimum ) ) : ?>
144
+									<?php if (!empty($validate_minimum)) : ?>
145 145
 										<div class="invalid-tooltip">
146 146
 											<?php echo $validate_minimum; ?>
147 147
 										</div>
148 148
 									<?php endif; ?>
149 149
 
150
-									<?php if( 'left' != $position ) : ?>
150
+									<?php if ('left' != $position) : ?>
151 151
 										<div class="input-group-append">
152
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
152
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
153 153
 										</div>
154 154
 									<?php endif; ?>
155 155
 								</div>
@@ -157,23 +157,23 @@  discard block
 block discarded – undo
157 157
 							<?php
158 158
 
159 159
 						} else {
160
-							echo wpinv_price( $item->get_price(), $currency );
160
+							echo wpinv_price($item->get_price(), $currency);
161 161
 
162 162
 							?>
163
-								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
163
+								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
164 164
 							<?php
165 165
 						}
166 166
 
167 167
 						printf(
168 168
 							'<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
169
-							sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) )
169
+							sprintf(__('Subtotal: %s', 'invoicing'), wpinv_price($item->get_sub_total(), $currency))
170 170
 						);
171 171
 					}
172 172
 
173 173
 					// Item quantity.
174
-					if ( 'quantity' == $key ) {
174
+					if ('quantity' == $key) {
175 175
 
176
-						if ( $item->allows_quantities() ) {
176
+						if ($item->allows_quantities()) {
177 177
 							?>
178 178
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' required>
179 179
 							<?php
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 					}
189 189
 
190 190
 					// Item sub total.
191
-					if ( 'subtotal' == $key ) {
192
-						echo wpinv_price( $item->get_sub_total(), $currency );
191
+					if ('subtotal' == $key) {
192
+						echo wpinv_price($item->get_sub_total(), $currency);
193 193
 					}
194 194
 
195
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
195
+					do_action("getpaid_payment_form_cart_item_$key", $item, $form);
196 196
 				?>
197 197
 
198 198
 			</div>
@@ -203,4 +203,4 @@  discard block
 block discarded – undo
203 203
 
204 204
 </div>
205 205
 <?php
206
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
206
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -13,96 +13,96 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
49
-
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49
+
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
 
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title                = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86 86
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
88
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89 89
         add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
90
+        add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
+        add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
92 92
 
93
-		parent::__construct();
93
+        parent::__construct();
94 94
     }
95 95
 
96 96
     /**
97
-	 * Process Payment.
98
-	 *
99
-	 *
100
-	 * @param WPInv_Invoice $invoice Invoice.
101
-	 * @param array $submission_data Posted checkout fields.
102
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103
-	 * @return array
104
-	 */
105
-	public function process_payment( $invoice, $submission_data, $submission ) {
97
+     * Process Payment.
98
+     *
99
+     *
100
+     * @param WPInv_Invoice $invoice Invoice.
101
+     * @param array $submission_data Posted checkout fields.
102
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103
+     * @return array
104
+     */
105
+    public function process_payment( $invoice, $submission_data, $submission ) {
106 106
 
107 107
         // Get redirect url.
108 108
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get the PayPal request URL for an invoice.
129
-	 *
130
-	 * @param  WPInv_Invoice $invoice Invoice object.
131
-	 * @return string
132
-	 */
133
-	public function get_request_url( $invoice ) {
128
+     * Get the PayPal request URL for an invoice.
129
+     *
130
+     * @param  WPInv_Invoice $invoice Invoice object.
131
+     * @return string
132
+     */
133
+    public function get_request_url( $invoice ) {
134 134
 
135 135
         // Endpoint for this request
136
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
136
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137 137
 
138 138
         // Retrieve paypal args.
139 139
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -146,45 +146,45 @@  discard block
 block discarded – undo
146 146
 
147 147
         return add_query_arg( $paypal_args, $this->endpoint );
148 148
 
149
-	}
149
+    }
150 150
 
151 151
     /**
152
-	 * Get PayPal Args for passing to PP.
153
-	 *
154
-	 * @param  WPInv_Invoice $invoice Invoice object.
155
-	 * @return array
156
-	 */
157
-	protected function get_paypal_args( $invoice ) {
152
+     * Get PayPal Args for passing to PP.
153
+     *
154
+     * @param  WPInv_Invoice $invoice Invoice object.
155
+     * @return array
156
+     */
157
+    protected function get_paypal_args( $invoice ) {
158 158
 
159 159
         // Whether or not to send the line items as one item.
160
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
161
-
162
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
163
-			$force_one_line_item = true;
164
-		}
165
-
166
-		$paypal_args = apply_filters(
167
-			'getpaid_paypal_args',
168
-			array_merge(
169
-				$this->get_transaction_args( $invoice ),
170
-				$this->get_line_item_args( $invoice, $force_one_line_item )
171
-			),
172
-			$invoice
173
-		);
174
-
175
-		return $this->fix_request_length( $invoice, $paypal_args );
160
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
161
+
162
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
163
+            $force_one_line_item = true;
164
+        }
165
+
166
+        $paypal_args = apply_filters(
167
+            'getpaid_paypal_args',
168
+            array_merge(
169
+                $this->get_transaction_args( $invoice ),
170
+                $this->get_line_item_args( $invoice, $force_one_line_item )
171
+            ),
172
+            $invoice
173
+        );
174
+
175
+        return $this->fix_request_length( $invoice, $paypal_args );
176 176
     }
177 177
 
178 178
     /**
179
-	 * Get transaction args for paypal request.
180
-	 *
181
-	 * @param WPInv_Invoice $invoice Invoice object.
182
-	 * @return array
183
-	 */
184
-	protected function get_transaction_args( $invoice ) {
185
-
186
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
187
-		return array(
179
+     * Get transaction args for paypal request.
180
+     *
181
+     * @param WPInv_Invoice $invoice Invoice object.
182
+     * @return array
183
+     */
184
+    protected function get_transaction_args( $invoice ) {
185
+
186
+        $email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
187
+        return array(
188 188
             'cmd'           => '_cart',
189 189
             'business'      => $email,
190 190
             'no_shipping'   => '1',
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get line item args for paypal request.
213
-	 *
214
-	 * @param  WPInv_Invoice $invoice Invoice object.
215
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
216
-	 * @return array
217
-	 */
218
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
212
+     * Get line item args for paypal request.
213
+     *
214
+     * @param  WPInv_Invoice $invoice Invoice object.
215
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
216
+     * @return array
217
+     */
218
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
219 219
 
220 220
         // Maybe send invoice as a single item.
221
-		if ( $force_one_line_item ) {
221
+        if ( $force_one_line_item ) {
222 222
             return $this->get_line_item_args_single_item( $invoice );
223 223
         }
224 224
 
@@ -238,129 +238,129 @@  discard block
 block discarded – undo
238 238
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
239 239
         }
240 240
 
241
-		return array_merge( $line_item_args, $this->get_line_items() );
241
+        return array_merge( $line_item_args, $this->get_line_items() );
242 242
 
243 243
     }
244 244
 
245 245
     /**
246
-	 * Get line item args for paypal request as a single line item.
247
-	 *
248
-	 * @param  WPInv_Invoice $invoice Invoice object.
249
-	 * @return array
250
-	 */
251
-	protected function get_line_item_args_single_item( $invoice ) {
252
-		$this->delete_line_items();
246
+     * Get line item args for paypal request as a single line item.
247
+     *
248
+     * @param  WPInv_Invoice $invoice Invoice object.
249
+     * @return array
250
+     */
251
+    protected function get_line_item_args_single_item( $invoice ) {
252
+        $this->delete_line_items();
253 253
 
254 254
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
255
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
255
+        $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
256 256
 
257
-		return $this->get_line_items();
257
+        return $this->get_line_items();
258 258
     }
259 259
 
260 260
     /**
261
-	 * Return all line items.
262
-	 */
263
-	protected function get_line_items() {
264
-		return $this->line_items;
265
-	}
261
+     * Return all line items.
262
+     */
263
+    protected function get_line_items() {
264
+        return $this->line_items;
265
+    }
266 266
 
267 267
     /**
268
-	 * Remove all line items.
269
-	 */
270
-	protected function delete_line_items() {
271
-		$this->line_items = array();
268
+     * Remove all line items.
269
+     */
270
+    protected function delete_line_items() {
271
+        $this->line_items = array();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Prepare line items to send to paypal.
276
-	 *
277
-	 * @param  WPInv_Invoice $invoice Invoice object.
278
-	 */
279
-	protected function prepare_line_items( $invoice ) {
280
-		$this->delete_line_items();
281
-
282
-		// Items.
283
-		foreach ( $invoice->get_items() as $item ) {
284
-			$amount   = $item->get_price();
285
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
286
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
275
+     * Prepare line items to send to paypal.
276
+     *
277
+     * @param  WPInv_Invoice $invoice Invoice object.
278
+     */
279
+    protected function prepare_line_items( $invoice ) {
280
+        $this->delete_line_items();
281
+
282
+        // Items.
283
+        foreach ( $invoice->get_items() as $item ) {
284
+            $amount   = $item->get_price();
285
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
286
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
287 287
         }
288 288
 
289 289
         // Fees.
290
-		foreach ( $invoice->get_fees() as $fee => $data ) {
290
+        foreach ( $invoice->get_fees() as $fee => $data ) {
291 291
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
292 292
         }
293 293
 
294 294
     }
295 295
 
296 296
     /**
297
-	 * Add PayPal Line Item.
298
-	 *
299
-	 * @param  string $item_name Item name.
300
-	 * @param  float    $quantity Item quantity.
301
-	 * @param  float  $amount Amount.
302
-	 * @param  string $item_number Item number.
303
-	 */
304
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
305
-		$index = ( count( $this->line_items ) / 4 ) + 1;
306
-
307
-		$item = apply_filters(
308
-			'getpaid_paypal_line_item',
309
-			array(
310
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
311
-				'quantity'    => (float) $quantity,
312
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
313
-				'item_number' => $item_number,
314
-			),
315
-			$item_name,
316
-			$quantity,
317
-			$amount,
318
-			$item_number
319
-		);
320
-
321
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
297
+     * Add PayPal Line Item.
298
+     *
299
+     * @param  string $item_name Item name.
300
+     * @param  float    $quantity Item quantity.
301
+     * @param  float  $amount Amount.
302
+     * @param  string $item_number Item number.
303
+     */
304
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
305
+        $index = ( count( $this->line_items ) / 4 ) + 1;
306
+
307
+        $item = apply_filters(
308
+            'getpaid_paypal_line_item',
309
+            array(
310
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
311
+                'quantity'    => (float) $quantity,
312
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
313
+                'item_number' => $item_number,
314
+            ),
315
+            $item_name,
316
+            $quantity,
317
+            $amount,
318
+            $item_number
319
+        );
320
+
321
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
322 322
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
323 323
 
324 324
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
325
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
326
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
325
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
326
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
327 327
     }
328 328
 
329 329
     /**
330
-	 * If the default request with line items is too long, generate a new one with only one line item.
331
-	 *
332
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
333
-	 *
334
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
335
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
336
-	 * @return array
337
-	 */
338
-	protected function fix_request_length( $invoice, $paypal_args ) {
339
-		$max_paypal_length = 2083;
340
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
341
-
342
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
343
-			return $paypal_args;
344
-		}
345
-
346
-		return apply_filters(
347
-			'getpaid_paypal_args',
348
-			array_merge(
349
-				$this->get_transaction_args( $invoice ),
350
-				$this->get_line_item_args( $invoice, true )
351
-			),
352
-			$invoice
353
-		);
330
+     * If the default request with line items is too long, generate a new one with only one line item.
331
+     *
332
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
333
+     *
334
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
335
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
336
+     * @return array
337
+     */
338
+    protected function fix_request_length( $invoice, $paypal_args ) {
339
+        $max_paypal_length = 2083;
340
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
341
+
342
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
343
+            return $paypal_args;
344
+        }
345
+
346
+        return apply_filters(
347
+            'getpaid_paypal_args',
348
+            array_merge(
349
+                $this->get_transaction_args( $invoice ),
350
+                $this->get_line_item_args( $invoice, true )
351
+            ),
352
+            $invoice
353
+        );
354 354
 
355 355
     }
356 356
 
357 357
     /**
358
-	 * Processes recurring invoices.
359
-	 *
360
-	 * @param  array $paypal_args PayPal args.
361
-	 * @param  WPInv_Invoice    $invoice Invoice object.
362
-	 */
363
-	public function process_subscription( $paypal_args, $invoice ) {
358
+     * Processes recurring invoices.
359
+     *
360
+     * @param  array $paypal_args PayPal args.
361
+     * @param  WPInv_Invoice    $invoice Invoice object.
362
+     */
363
+    public function process_subscription( $paypal_args, $invoice ) {
364 364
 
365 365
         // Make sure this is a subscription.
366 366
         if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
@@ -381,21 +381,21 @@  discard block
 block discarded – undo
381 381
         $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
382 382
         $subscription_item      = $invoice->get_recurring( true );
383 383
 
384
-		// Convert 365 days to 1 year.
385
-		if ( 'D' == $period && 365 == $interval ) {
386
-			$period = 'Y';
387
-			$interval = 1;
388
-		}
384
+        // Convert 365 days to 1 year.
385
+        if ( 'D' == $period && 365 == $interval ) {
386
+            $period = 'Y';
387
+            $interval = 1;
388
+        }
389 389
 
390 390
         if ( $subscription_item->has_free_trial() ) {
391 391
 
392 392
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
393 393
 
394
-			// Trial period length.
395
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
394
+            // Trial period length.
395
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
396 396
 
397
-			// Trial period.
398
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
397
+            // Trial period.
398
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
399 399
 
400 400
         } else if ( $initial_amount != $recurring_amount ) {
401 401
 
@@ -418,40 +418,40 @@  discard block
 block discarded – undo
418 418
         }
419 419
 
420 420
         // We have a recurring payment
421
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
421
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
422 422
 
423
-			// Subscription price
424
-			$paypal_args['a3'] = $recurring_amount;
423
+            // Subscription price
424
+            $paypal_args['a3'] = $recurring_amount;
425 425
 
426
-			// Subscription duration
427
-			$paypal_args['p3'] = $interval;
426
+            // Subscription duration
427
+            $paypal_args['p3'] = $interval;
428 428
 
429
-			// Subscription period
430
-			$paypal_args['t3'] = $period;
429
+            // Subscription period
430
+            $paypal_args['t3'] = $period;
431 431
 
432 432
         }
433 433
 
434 434
         // Recurring payments
435
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
435
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
436 436
 
437
-			// Non-recurring payments
438
-			$paypal_args['src'] = 0;
437
+            // Non-recurring payments
438
+            $paypal_args['src'] = 0;
439 439
 
440
-		} else {
440
+        } else {
441 441
 
442
-			$paypal_args['src'] = 1;
442
+            $paypal_args['src'] = 1;
443 443
 
444
-			if ( $bill_times > 0 ) {
444
+            if ( $bill_times > 0 ) {
445 445
 
446
-				// An initial period is being used to charge a sign-up fee
447
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
448
-					$bill_times--;
449
-				}
446
+                // An initial period is being used to charge a sign-up fee
447
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
448
+                    $bill_times--;
449
+                }
450 450
 
451 451
                 // Make sure it's not over the max of 52
452 452
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
453 453
 
454
-			}
454
+            }
455 455
         }
456 456
 
457 457
         // Force return URL so that order description & instructions display
@@ -467,19 +467,19 @@  discard block
 block discarded – undo
467 467
         }
468 468
 
469 469
         return apply_filters(
470
-			'getpaid_paypal_subscription_args',
471
-			$paypal_args,
472
-			$invoice
470
+            'getpaid_paypal_subscription_args',
471
+            $paypal_args,
472
+            $invoice
473 473
         );
474 474
 
475 475
     }
476 476
 
477 477
     /**
478
-	 * Processes ipns and marks payments as complete.
479
-	 *
480
-	 * @return void
481
-	 */
482
-	public function verify_ipn() {
478
+     * Processes ipns and marks payments as complete.
479
+     *
480
+     * @return void
481
+     */
482
+    public function verify_ipn() {
483 483
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
484 484
     }
485 485
 
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
     public function sandbox_notice() {
490 490
 
491 491
         return sprintf(
492
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
493
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494
-			'</a>'
495
-		);
492
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
493
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494
+            '</a>'
495
+        );
496 496
 
497 497
     }
498 498
 
499
-	/**
500
-	 * Filters the gateway settings.
501
-	 *
502
-	 * @param array $admin_settings
503
-	 */
504
-	public function admin_settings( $admin_settings ) {
499
+    /**
500
+     * Filters the gateway settings.
501
+     *
502
+     * @param array $admin_settings
503
+     */
504
+    public function admin_settings( $admin_settings ) {
505 505
 
506 506
         $currencies = sprintf(
507 507
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -511,39 +511,39 @@  discard block
 block discarded – undo
511 511
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
512 512
         $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
513 513
 
514
-		// Access tokens.
515
-		$live_email      = wpinv_get_option( 'paypal_email' );
516
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
517
-
518
-		$admin_settings['paypal_connect'] = array(
519
-			'type'       => 'raw_html',
520
-			'id'         => 'paypal_connect',
521
-			'name'       => __( 'Connect to PayPal', 'invoicing' ),
522
-			'desc'       => sprintf(
523
-				'<div class="wpinv-paypal-connect-live"><a class="button button-primary" href="%s">%s</a></div><div class="wpinv-paypal-connect-sandbox"><a class="button button-primary" href="%s">%s</a></div>%s',
524
-				esc_url( self::get_connect_url( false ) ),
525
-				__( 'Connect to PayPal', 'invoicing' ),
526
-				esc_url( self::get_connect_url( true ) ),
527
-				__( 'Connect to PayPal Sandox', 'invoicing' ),
528
-				$this->get_js()
529
-			),
530
-		);
514
+        // Access tokens.
515
+        $live_email      = wpinv_get_option( 'paypal_email' );
516
+        $sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
517
+
518
+        $admin_settings['paypal_connect'] = array(
519
+            'type'       => 'raw_html',
520
+            'id'         => 'paypal_connect',
521
+            'name'       => __( 'Connect to PayPal', 'invoicing' ),
522
+            'desc'       => sprintf(
523
+                '<div class="wpinv-paypal-connect-live"><a class="button button-primary" href="%s">%s</a></div><div class="wpinv-paypal-connect-sandbox"><a class="button button-primary" href="%s">%s</a></div>%s',
524
+                esc_url( self::get_connect_url( false ) ),
525
+                __( 'Connect to PayPal', 'invoicing' ),
526
+                esc_url( self::get_connect_url( true ) ),
527
+                __( 'Connect to PayPal Sandox', 'invoicing' ),
528
+                $this->get_js()
529
+            ),
530
+        );
531 531
 
532 532
         $admin_settings['paypal_email'] = array(
533 533
             'type'  => 'text',
534
-			'class' => 'live-auth-data',
534
+            'class' => 'live-auth-data',
535 535
             'id'    => 'paypal_email',
536 536
             'name'  => __( 'Live Email Address', 'invoicing' ),
537 537
             'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
538 538
         );
539 539
 
540
-		$admin_settings['paypal_sandbox_email'] = array(
540
+        $admin_settings['paypal_sandbox_email'] = array(
541 541
             'type'  => 'text',
542
-			'class' => 'sandbox-auth-data',
542
+            'class' => 'sandbox-auth-data',
543 543
             'id'    => 'paypal_sandbox_email',
544 544
             'name'  => __( 'Sandbox Email Address', 'invoicing' ),
545 545
             'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
546
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
546
+            'std'   => wpinv_get_option( 'paypal_email', '' ),
547 547
         );
548 548
 
549 549
         $admin_settings['paypal_ipn_url'] = array(
@@ -555,29 +555,29 @@  discard block
 block discarded – undo
555 555
             'readonly' => true,
556 556
         );
557 557
 
558
-		return $admin_settings;
559
-	}
558
+        return $admin_settings;
559
+    }
560 560
 
561
-	/**
562
-	 * Retrieves the PayPal connect URL when using the setup wizzard.
563
-	 *
564
-	 *
561
+    /**
562
+     * Retrieves the PayPal connect URL when using the setup wizzard.
563
+     *
564
+     *
565 565
      * @param array $data
566 566
      * @return string
567
-	 */
568
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
569
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
570
-	}
571
-
572
-	/**
573
-	 * Retrieves the PayPal connect URL.
574
-	 *
575
-	 *
567
+     */
568
+    public static function maybe_get_connect_url( $url = '', $data = array() ) {
569
+        return self::get_connect_url( false, urldecode( $data['redirect'] ) );
570
+    }
571
+
572
+    /**
573
+     * Retrieves the PayPal connect URL.
574
+     *
575
+     *
576 576
      * @param bool $is_sandbox
577
-	 * @param string $redirect
577
+     * @param string $redirect
578 578
      * @return string
579
-	 */
580
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
579
+     */
580
+    public static function get_connect_url( $is_sandbox, $redirect = '' ) {
581 581
 
582 582
         $redirect_url = add_query_arg(
583 583
             array(
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
                 'tab'                  => 'gateways',
588 588
                 'section'              => 'paypal',
589 589
                 'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
590
-				'redirect'             => urlencode( $redirect ),
590
+                'redirect'             => urlencode( $redirect ),
591 591
             ),
592 592
             admin_url( 'admin.php' )
593 593
         );
@@ -602,12 +602,12 @@  discard block
 block discarded – undo
602 602
 
603 603
     }
604 604
 
605
-	/**
606
-	 * Generates settings page js.
607
-	 *
605
+    /**
606
+     * Generates settings page js.
607
+     *
608 608
      * @return void
609
-	 */
610
-	public static function get_js() {
609
+     */
610
+    public static function get_js() {
611 611
         ob_start();
612 612
         ?>
613 613
             <script>
@@ -643,72 +643,72 @@  discard block
 block discarded – undo
643 643
         return ob_get_clean();
644 644
     }
645 645
 
646
-	/**
647
-	 * Connects to PayPal.
648
-	 *
649
-	 * @param array $data Connection data.
650
-	 * @return void
651
-	 */
652
-	public function connect_paypal( $data ) {
653
-
654
-		$sandbox      = $this->is_sandbox();
655
-		$data         = wp_unslash( $data );
656
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
657
-
658
-		if ( isset( $data['live_mode'] ) ) {
659
-			$sandbox = empty( $data['live_mode'] );
660
-		}
661
-
662
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
663
-		wpinv_update_option( 'paypal_active', 1 );
664
-
665
-		if ( ! empty( $data['error_description'] ) ) {
666
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
667
-		} else {
668
-
669
-			// Retrieve the user info.
670
-			$user_info = wp_remote_get(
671
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
672
-				array(
673
-
674
-					'headers' => array(
675
-						'Authorization' => 'Bearer ' . $access_token,
676
-						'Content-type'  => 'application/json',
677
-					)
678
-
679
-				)
680
-			);
681
-
682
-			if ( is_wp_error( $user_info ) ) {
683
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
684
-			} else {
685
-
686
-				// Create application.
687
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
688
-
689
-				if ( $sandbox ) {
690
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
691
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
692
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
693
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
694
-				} else {
695
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
696
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
697
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
698
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
699
-				}
700
-
701
-			}
702
-
703
-		}
704
-
705
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
706
-
707
-		if ( isset( $data['step'] ) ) {
708
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
709
-		}
710
-		wp_redirect( $redirect );
711
-		exit;
712
-	}
646
+    /**
647
+     * Connects to PayPal.
648
+     *
649
+     * @param array $data Connection data.
650
+     * @return void
651
+     */
652
+    public function connect_paypal( $data ) {
653
+
654
+        $sandbox      = $this->is_sandbox();
655
+        $data         = wp_unslash( $data );
656
+        $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
657
+
658
+        if ( isset( $data['live_mode'] ) ) {
659
+            $sandbox = empty( $data['live_mode'] );
660
+        }
661
+
662
+        wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
663
+        wpinv_update_option( 'paypal_active', 1 );
664
+
665
+        if ( ! empty( $data['error_description'] ) ) {
666
+            getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
667
+        } else {
668
+
669
+            // Retrieve the user info.
670
+            $user_info = wp_remote_get(
671
+                ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
672
+                array(
673
+
674
+                    'headers' => array(
675
+                        'Authorization' => 'Bearer ' . $access_token,
676
+                        'Content-type'  => 'application/json',
677
+                    )
678
+
679
+                )
680
+            );
681
+
682
+            if ( is_wp_error( $user_info ) ) {
683
+                getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
684
+            } else {
685
+
686
+                // Create application.
687
+                $user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
688
+
689
+                if ( $sandbox ) {
690
+                    wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
691
+                    wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
692
+                    set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
693
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
694
+                } else {
695
+                    wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
696
+                    wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
697
+                    set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
698
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
699
+                }
700
+
701
+            }
702
+
703
+        }
704
+
705
+        $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
706
+
707
+        if ( isset( $data['step'] ) ) {
708
+            $redirect = add_query_arg( 'step', $data['step'], $redirect );
709
+        }
710
+        wp_redirect( $redirect );
711
+        exit;
712
+    }
713 713
 
714 714
 }
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
83
+        $this->title                = __('PayPal Standard', 'invoicing');
84
+        $this->method_title         = __('PayPal Standard', 'invoicing');
85
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89
-        add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
88
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
89
+        add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
90
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
91
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
92 92
 
93 93
 		parent::__construct();
94 94
     }
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103 103
 	 * @return array
104 104
 	 */
105
-	public function process_payment( $invoice, $submission_data, $submission ) {
105
+	public function process_payment($invoice, $submission_data, $submission) {
106 106
 
107 107
         // Get redirect url.
108
-        $paypal_redirect = $this->get_request_url( $invoice );
108
+        $paypal_redirect = $this->get_request_url($invoice);
109 109
 
110 110
         // Add a note about the request url.
111 111
         $invoice->add_note(
112 112
             sprintf(
113
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
114
-                esc_url( $paypal_redirect )
113
+                __('Redirecting to PayPal: %s', 'invoicing'),
114
+                esc_url($paypal_redirect)
115 115
             ),
116 116
             false,
117 117
             false,
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         );
120 120
 
121 121
         // Redirect to PayPal
122
-        wp_redirect( $paypal_redirect );
122
+        wp_redirect($paypal_redirect);
123 123
         exit;
124 124
 
125 125
     }
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
 	 * @param  WPInv_Invoice $invoice Invoice object.
131 131
 	 * @return string
132 132
 	 */
133
-	public function get_request_url( $invoice ) {
133
+	public function get_request_url($invoice) {
134 134
 
135 135
         // Endpoint for this request
136
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
136
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137 137
 
138 138
         // Retrieve paypal args.
139
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
139
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
140 140
 
141
-        if ( $invoice->is_recurring() ) {
141
+        if ($invoice->is_recurring()) {
142 142
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
143 143
         } else {
144 144
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
145 145
         }
146 146
 
147
-        return add_query_arg( $paypal_args, $this->endpoint );
147
+        return add_query_arg($paypal_args, $this->endpoint);
148 148
 
149 149
 	}
150 150
 
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
 	 * @param  WPInv_Invoice $invoice Invoice object.
155 155
 	 * @return array
156 156
 	 */
157
-	protected function get_paypal_args( $invoice ) {
157
+	protected function get_paypal_args($invoice) {
158 158
 
159 159
         // Whether or not to send the line items as one item.
160
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
160
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
161 161
 
162
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
162
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
163 163
 			$force_one_line_item = true;
164 164
 		}
165 165
 
166 166
 		$paypal_args = apply_filters(
167 167
 			'getpaid_paypal_args',
168 168
 			array_merge(
169
-				$this->get_transaction_args( $invoice ),
170
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
+				$this->get_transaction_args($invoice),
170
+				$this->get_line_item_args($invoice, $force_one_line_item)
171 171
 			),
172 172
 			$invoice
173 173
 		);
174 174
 
175
-		return $this->fix_request_length( $invoice, $paypal_args );
175
+		return $this->fix_request_length($invoice, $paypal_args);
176 176
     }
177 177
 
178 178
     /**
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @param WPInv_Invoice $invoice Invoice object.
182 182
 	 * @return array
183 183
 	 */
184
-	protected function get_transaction_args( $invoice ) {
184
+	protected function get_transaction_args($invoice) {
185 185
 
186
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
186
+		$email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', '');
187 187
 		return array(
188 188
             'cmd'           => '_cart',
189 189
             'business'      => $email,
@@ -194,16 +194,16 @@  discard block
 block discarded – undo
194 194
             'rm'            => is_ssl() ? 2 : 1,
195 195
             'upload'        => 1,
196 196
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
197
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
198
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
199
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
200
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
197
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
198
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
199
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
200
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
201 201
             'custom'        => $invoice->get_id(),
202
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
203
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
204
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
205
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
206
-            'cbt'           => get_bloginfo( 'name' )
202
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
203
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
204
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
205
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
206
+            'cbt'           => get_bloginfo('name')
207 207
         );
208 208
 
209 209
     }
@@ -215,30 +215,30 @@  discard block
 block discarded – undo
215 215
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
216 216
 	 * @return array
217 217
 	 */
218
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
218
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
219 219
 
220 220
         // Maybe send invoice as a single item.
221
-		if ( $force_one_line_item ) {
222
-            return $this->get_line_item_args_single_item( $invoice );
221
+		if ($force_one_line_item) {
222
+            return $this->get_line_item_args_single_item($invoice);
223 223
         }
224 224
 
225 225
         // Send each line item individually.
226 226
         $line_item_args = array();
227 227
 
228 228
         // Prepare line items.
229
-        $this->prepare_line_items( $invoice );
229
+        $this->prepare_line_items($invoice);
230 230
 
231 231
         // Add taxes to the cart
232
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
233
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
232
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
233
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
234 234
         }
235 235
 
236 236
         // Add discount.
237
-        if ( $invoice->get_total_discount() > 0 ) {
238
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
237
+        if ($invoice->get_total_discount() > 0) {
238
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
239 239
         }
240 240
 
241
-		return array_merge( $line_item_args, $this->get_line_items() );
241
+		return array_merge($line_item_args, $this->get_line_items());
242 242
 
243 243
     }
244 244
 
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	 * @param  WPInv_Invoice $invoice Invoice object.
249 249
 	 * @return array
250 250
 	 */
251
-	protected function get_line_item_args_single_item( $invoice ) {
251
+	protected function get_line_item_args_single_item($invoice) {
252 252
 		$this->delete_line_items();
253 253
 
254
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
255
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
254
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
255
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
256 256
 
257 257
 		return $this->get_line_items();
258 258
     }
@@ -276,19 +276,19 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @param  WPInv_Invoice $invoice Invoice object.
278 278
 	 */
279
-	protected function prepare_line_items( $invoice ) {
279
+	protected function prepare_line_items($invoice) {
280 280
 		$this->delete_line_items();
281 281
 
282 282
 		// Items.
283
-		foreach ( $invoice->get_items() as $item ) {
283
+		foreach ($invoice->get_items() as $item) {
284 284
 			$amount   = $item->get_price();
285 285
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
286
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
286
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
287 287
         }
288 288
 
289 289
         // Fees.
290
-		foreach ( $invoice->get_fees() as $fee => $data ) {
291
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
290
+		foreach ($invoice->get_fees() as $fee => $data) {
291
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
292 292
         }
293 293
 
294 294
     }
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 * @param  float  $amount Amount.
302 302
 	 * @param  string $item_number Item number.
303 303
 	 */
304
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
305
-		$index = ( count( $this->line_items ) / 4 ) + 1;
304
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
305
+		$index = (count($this->line_items) / 4) + 1;
306 306
 
307 307
 		$item = apply_filters(
308 308
 			'getpaid_paypal_line_item',
309 309
 			array(
310
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
310
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
311 311
 				'quantity'    => (float) $quantity,
312
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
312
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
313 313
 				'item_number' => $item_number,
314 314
 			),
315 315
 			$item_name,
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 			$item_number
319 319
 		);
320 320
 
321
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
322
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
321
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
322
+        $this->line_items['quantity_' . $index] = $item['quantity'];
323 323
 
324 324
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
325
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
326
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
325
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
326
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
327 327
     }
328 328
 
329 329
     /**
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
336 336
 	 * @return array
337 337
 	 */
338
-	protected function fix_request_length( $invoice, $paypal_args ) {
338
+	protected function fix_request_length($invoice, $paypal_args) {
339 339
 		$max_paypal_length = 2083;
340
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
340
+		$query_candidate   = http_build_query($paypal_args, '', '&');
341 341
 
342
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
342
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
343 343
 			return $paypal_args;
344 344
 		}
345 345
 
346 346
 		return apply_filters(
347 347
 			'getpaid_paypal_args',
348 348
 			array_merge(
349
-				$this->get_transaction_args( $invoice ),
350
-				$this->get_line_item_args( $invoice, true )
349
+				$this->get_transaction_args($invoice),
350
+				$this->get_line_item_args($invoice, true)
351 351
 			),
352 352
 			$invoice
353 353
 		);
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 	 * @param  array $paypal_args PayPal args.
361 361
 	 * @param  WPInv_Invoice    $invoice Invoice object.
362 362
 	 */
363
-	public function process_subscription( $paypal_args, $invoice ) {
363
+	public function process_subscription($paypal_args, $invoice) {
364 364
 
365 365
         // Make sure this is a subscription.
366
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
366
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
367 367
             return $paypal_args;
368 368
         }
369 369
 
@@ -371,23 +371,23 @@  discard block
 block discarded – undo
371 371
         $paypal_args['cmd'] = '_xclick-subscriptions';
372 372
 
373 373
         // Subscription name.
374
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
374
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
375 375
 
376 376
         // Get subscription args.
377
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1) );
377
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
378 378
         $interval               = (int) $subscription->get_frequency();
379 379
         $bill_times             = (int) $subscription->get_bill_times();
380
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
381
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
382
-        $subscription_item      = $invoice->get_recurring( true );
380
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
381
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
382
+        $subscription_item      = $invoice->get_recurring(true);
383 383
 
384 384
 		// Convert 365 days to 1 year.
385
-		if ( 'D' == $period && 365 == $interval ) {
385
+		if ('D' == $period && 365 == $interval) {
386 386
 			$period = 'Y';
387 387
 			$interval = 1;
388 388
 		}
389 389
 
390
-        if ( $subscription_item->has_free_trial() ) {
390
+        if ($subscription_item->has_free_trial()) {
391 391
 
392 392
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
393 393
 
@@ -397,28 +397,28 @@  discard block
 block discarded – undo
397 397
 			// Trial period.
398 398
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
399 399
 
400
-        } else if ( $initial_amount != $recurring_amount ) {
400
+        } else if ($initial_amount != $recurring_amount) {
401 401
 
402 402
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
403 403
 
404
-            if ( 1 == $bill_times ) {
404
+            if (1 == $bill_times) {
405 405
                 $param_number = 3;
406 406
             } else {
407 407
                 $param_number = 1;
408 408
             }
409 409
 
410
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
410
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
411 411
 
412 412
             // Sign Up interval
413
-            $paypal_args[ 'p' . $param_number ] = $interval;
413
+            $paypal_args['p' . $param_number] = $interval;
414 414
 
415 415
             // Sign Up unit of duration
416
-            $paypal_args[ 't' . $param_number ] = $period;
416
+            $paypal_args['t' . $param_number] = $period;
417 417
 
418 418
         }
419 419
 
420 420
         // We have a recurring payment
421
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
421
+		if (!isset($param_number) || 1 == $param_number) {
422 422
 
423 423
 			// Subscription price
424 424
 			$paypal_args['a3'] = $recurring_amount;
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         }
433 433
 
434 434
         // Recurring payments
435
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
435
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
436 436
 
437 437
 			// Non-recurring payments
438 438
 			$paypal_args['src'] = 0;
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 
442 442
 			$paypal_args['src'] = 1;
443 443
 
444
-			if ( $bill_times > 0 ) {
444
+			if ($bill_times > 0) {
445 445
 
446 446
 				// An initial period is being used to charge a sign-up fee
447
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
447
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
448 448
 					$bill_times--;
449 449
 				}
450 450
 
451 451
                 // Make sure it's not over the max of 52
452
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
452
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
453 453
 
454 454
 			}
455 455
         }
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
         $paypal_args['rm'] = 2;
459 459
 
460 460
         // Get rid of redudant items.
461
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
461
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
462 462
 
463
-            if ( isset( $paypal_args[ $arg ] ) ) {
464
-                unset( $paypal_args[ $arg ] );
463
+            if (isset($paypal_args[$arg])) {
464
+                unset($paypal_args[$arg]);
465 465
             }
466 466
 
467 467
         }
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return void
481 481
 	 */
482 482
 	public function verify_ipn() {
483
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
483
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
484 484
     }
485 485
 
486 486
     /**
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     public function sandbox_notice() {
490 490
 
491 491
         return sprintf(
492
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
492
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
493 493
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
494 494
 			'</a>'
495 495
 		);
@@ -501,30 +501,30 @@  discard block
 block discarded – undo
501 501
 	 *
502 502
 	 * @param array $admin_settings
503 503
 	 */
504
-	public function admin_settings( $admin_settings ) {
504
+	public function admin_settings($admin_settings) {
505 505
 
506 506
         $currencies = sprintf(
507
-            __( 'Supported Currencies: %s', 'invoicing' ),
508
-            implode( ', ', $this->currencies )
507
+            __('Supported Currencies: %s', 'invoicing'),
508
+            implode(', ', $this->currencies)
509 509
         );
510 510
 
511 511
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
512
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
512
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
513 513
 
514 514
 		// Access tokens.
515
-		$live_email      = wpinv_get_option( 'paypal_email' );
516
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
515
+		$live_email      = wpinv_get_option('paypal_email');
516
+		$sandbox_email   = wpinv_get_option('paypal_sandbox_email');
517 517
 
518 518
 		$admin_settings['paypal_connect'] = array(
519 519
 			'type'       => 'raw_html',
520 520
 			'id'         => 'paypal_connect',
521
-			'name'       => __( 'Connect to PayPal', 'invoicing' ),
521
+			'name'       => __('Connect to PayPal', 'invoicing'),
522 522
 			'desc'       => sprintf(
523 523
 				'<div class="wpinv-paypal-connect-live"><a class="button button-primary" href="%s">%s</a></div><div class="wpinv-paypal-connect-sandbox"><a class="button button-primary" href="%s">%s</a></div>%s',
524
-				esc_url( self::get_connect_url( false ) ),
525
-				__( 'Connect to PayPal', 'invoicing' ),
526
-				esc_url( self::get_connect_url( true ) ),
527
-				__( 'Connect to PayPal Sandox', 'invoicing' ),
524
+				esc_url(self::get_connect_url(false)),
525
+				__('Connect to PayPal', 'invoicing'),
526
+				esc_url(self::get_connect_url(true)),
527
+				__('Connect to PayPal Sandox', 'invoicing'),
528 528
 				$this->get_js()
529 529
 			),
530 530
 		);
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
             'type'  => 'text',
534 534
 			'class' => 'live-auth-data',
535 535
             'id'    => 'paypal_email',
536
-            'name'  => __( 'Live Email Address', 'invoicing' ),
537
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
536
+            'name'  => __('Live Email Address', 'invoicing'),
537
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
538 538
         );
539 539
 
540 540
 		$admin_settings['paypal_sandbox_email'] = array(
541 541
             'type'  => 'text',
542 542
 			'class' => 'sandbox-auth-data',
543 543
             'id'    => 'paypal_sandbox_email',
544
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
545
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
546
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
544
+            'name'  => __('Sandbox Email Address', 'invoicing'),
545
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
546
+			'std'   => wpinv_get_option('paypal_email', ''),
547 547
         );
548 548
 
549 549
         $admin_settings['paypal_ipn_url'] = array(
550 550
             'type'     => 'ipn_url',
551 551
             'id'       => 'paypal_ipn_url',
552
-            'name'     => __( 'IPN Url', 'invoicing' ),
552
+            'name'     => __('IPN Url', 'invoicing'),
553 553
             'std'      => $this->notify_url,
554
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
554
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
555 555
             'readonly' => true,
556 556
         );
557 557
 
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
      * @param array $data
566 566
      * @return string
567 567
 	 */
568
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
569
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
568
+	public static function maybe_get_connect_url($url = '', $data = array()) {
569
+		return self::get_connect_url(false, urldecode($data['redirect']));
570 570
 	}
571 571
 
572 572
 	/**
@@ -577,25 +577,25 @@  discard block
 block discarded – undo
577 577
 	 * @param string $redirect
578 578
      * @return string
579 579
 	 */
580
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
580
+	public static function get_connect_url($is_sandbox, $redirect = '') {
581 581
 
582 582
         $redirect_url = add_query_arg(
583 583
             array(
584 584
                 'getpaid-admin-action' => 'connect_paypal',
585 585
                 'page'                 => 'wpinv-settings',
586
-                'live_mode'            => (int) empty( $is_sandbox ),
586
+                'live_mode'            => (int) empty($is_sandbox),
587 587
                 'tab'                  => 'gateways',
588 588
                 'section'              => 'paypal',
589
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
590
-				'redirect'             => urlencode( $redirect ),
589
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
590
+				'redirect'             => urlencode($redirect),
591 591
             ),
592
-            admin_url( 'admin.php' )
592
+            admin_url('admin.php')
593 593
         );
594 594
 
595 595
         return add_query_arg(
596 596
             array(
597
-                'live_mode'    => (int) empty( $is_sandbox ),
598
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) )
597
+                'live_mode'    => (int) empty($is_sandbox),
598
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url))
599 599
             ),
600 600
             'https://ayecode.io/oauth/paypal'
601 601
         );
@@ -649,26 +649,26 @@  discard block
 block discarded – undo
649 649
 	 * @param array $data Connection data.
650 650
 	 * @return void
651 651
 	 */
652
-	public function connect_paypal( $data ) {
652
+	public function connect_paypal($data) {
653 653
 
654 654
 		$sandbox      = $this->is_sandbox();
655
-		$data         = wp_unslash( $data );
656
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
655
+		$data         = wp_unslash($data);
656
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
657 657
 
658
-		if ( isset( $data['live_mode'] ) ) {
659
-			$sandbox = empty( $data['live_mode'] );
658
+		if (isset($data['live_mode'])) {
659
+			$sandbox = empty($data['live_mode']);
660 660
 		}
661 661
 
662
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
663
-		wpinv_update_option( 'paypal_active', 1 );
662
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
663
+		wpinv_update_option('paypal_active', 1);
664 664
 
665
-		if ( ! empty( $data['error_description'] ) ) {
666
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
665
+		if (!empty($data['error_description'])) {
666
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
667 667
 		} else {
668 668
 
669 669
 			// Retrieve the user info.
670 670
 			$user_info = wp_remote_get(
671
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
671
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
672 672
 				array(
673 673
 
674 674
 					'headers' => array(
@@ -679,35 +679,35 @@  discard block
 block discarded – undo
679 679
 				)
680 680
 			);
681 681
 
682
-			if ( is_wp_error( $user_info ) ) {
683
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
682
+			if (is_wp_error($user_info)) {
683
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
684 684
 			} else {
685 685
 
686 686
 				// Create application.
687
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
687
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
688 688
 
689
-				if ( $sandbox ) {
690
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
691
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
692
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
693
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
689
+				if ($sandbox) {
690
+					wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
691
+					wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
692
+					set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
693
+					getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
694 694
 				} else {
695
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
696
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
697
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
698
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
695
+					wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
696
+					wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
697
+					set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
698
+					getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
699 699
 				}
700 700
 
701 701
 			}
702 702
 
703 703
 		}
704 704
 
705
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
705
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
706 706
 
707
-		if ( isset( $data['step'] ) ) {
708
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
707
+		if (isset($data['step'])) {
708
+			$redirect = add_query_arg('step', $data['step'], $redirect);
709 709
 		}
710
-		wp_redirect( $redirect );
710
+		wp_redirect($redirect);
711 711
 		exit;
712 712
 	}
713 713
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-legacy-gateway.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@  discard block
 block discarded – undo
15 15
 abstract class GetPaid_Authorize_Net_Legacy_Gateway extends GetPaid_Payment_Gateway {
16 16
 
17 17
     /**
18
-	 * Class constructor.
19
-	 */
20
-	public function __construct() {
18
+     * Class constructor.
19
+     */
20
+    public function __construct() {
21 21
         parent::__construct();
22 22
     }
23 23
 
24 24
     /**
25
-	 * Returns the API URL.
26
-	 *
27
-	 *
28
-	 * @param WPInv_Invoice $invoice Invoice.
29
-	 * @return string
30
-	 */
31
-	public function get_api_url( $invoice ) {
25
+     * Returns the API URL.
26
+     *
27
+     *
28
+     * @param WPInv_Invoice $invoice Invoice.
29
+     * @return string
30
+     */
31
+    public function get_api_url( $invoice ) {
32 32
         return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
33 33
     }
34 34
 
35 35
     /**
36
-	 * Communicates with authorize.net
37
-	 *
38
-	 *
39
-	 * @param array $post Data to post.
36
+     * Communicates with authorize.net
37
+     *
38
+     *
39
+     * @param array $post Data to post.
40 40
      * @param WPInv_Invoice $invoice Invoice.
41
-	 * @return stdClass|WP_Error
42
-	 */
41
+     * @return stdClass|WP_Error
42
+     */
43 43
     public function post( $post, $invoice ){
44 44
 
45 45
         $url      = $this->get_api_url( $invoice );
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
     }
90 90
 
91 91
     /**
92
-	 * Returns the API authentication params.
93
-	 *
94
-	 *
95
-	 * @return array
96
-	 */
97
-	public function get_auth_params() {
92
+     * Returns the API authentication params.
93
+     *
94
+     *
95
+     * @return array
96
+     */
97
+    public function get_auth_params() {
98 98
 
99 99
         return array(
100 100
             'name'           => $this->get_option( 'login_id' ),
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     /**
107
-	 * Cancels a subscription remotely
108
-	 *
109
-	 *
110
-	 * @param WPInv_Subscription $subscription Subscription.
107
+     * Cancels a subscription remotely
108
+     *
109
+     *
110
+     * @param WPInv_Subscription $subscription Subscription.
111 111
      * @param WPInv_Invoice $invoice Invoice.
112
-	 */
113
-	public function cancel_subscription( $subscription, $invoice ) {
112
+     */
113
+    public function cancel_subscription( $subscription, $invoice ) {
114 114
 
115 115
         // Backwards compatibility. New version do not use authorize.net subscriptions.
116 116
         $this->post(
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     /**
129
-	 * Processes ipns.
130
-	 *
131
-	 * @return void
132
-	 */
133
-	public function verify_ipn() {
129
+     * Processes ipns.
130
+     *
131
+     * @return void
132
+     */
133
+    public function verify_ipn() {
134 134
 
135 135
         $this->maybe_process_old_ipn();
136 136
 
137 137
         // Validate the IPN.
138 138
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
139
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 200 ) );
139
+            wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 200 ) );
140 140
         }
141 141
 
142 142
         // Event type.
@@ -175,24 +175,24 @@  discard block
 block discarded – undo
175 175
     }
176 176
 
177 177
     /**
178
-	 * Validates IPN invoices.
179
-	 *
178
+     * Validates IPN invoices.
179
+     *
180 180
      * @param WPInv_Invoice $invoice
181 181
      * @param object $payload
182
-	 * @return void
183
-	 */
184
-	public function validate_ipn_invoice( $invoice, $payload ) {
182
+     * @return void
183
+     */
184
+    public function validate_ipn_invoice( $invoice, $payload ) {
185 185
         if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) {
186 186
             exit;
187 187
         }
188 188
     }
189 189
 
190 190
     /**
191
-	 * Process subscriptio IPNS.
192
-	 *
193
-	 * @return void
194
-	 */
195
-	public function maybe_process_old_ipn() {
191
+     * Process subscriptio IPNS.
192
+     *
193
+     * @return void
194
+     */
195
+    public function maybe_process_old_ipn() {
196 196
 
197 197
         $data = wp_kses_post_deep( wp_unslash( $_POST ) );
198 198
 
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
     }
235 235
 
236 236
     /**
237
-	 * Validates the old IPN signature.
237
+     * Validates the old IPN signature.
238 238
      *
239 239
      * @param array $posted
240
-	 */
241
-	public function validate_old_ipn_signature( $posted ) {
240
+     */
241
+    public function validate_old_ipn_signature( $posted ) {
242 242
 
243 243
         $signature = $this->get_option( 'signature_key' );
244 244
         if ( ! empty( $signature ) ) {
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
     }
258 258
 
259 259
     /**
260
-	 * Check Authorize.NET IPN validity.
261
-	 */
262
-	public function validate_ipn() {
260
+     * Check Authorize.NET IPN validity.
261
+     */
262
+    public function validate_ipn() {
263 263
 
264 264
         wpinv_error_log( 'Validating Authorize.NET IPN response' );
265 265
 
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Authorize.net Legacy Payment Gateway class.
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 	 * @param WPInv_Invoice $invoice Invoice.
29 29
 	 * @return string
30 30
 	 */
31
-	public function get_api_url( $invoice ) {
32
-        return $this->is_sandbox( $invoice ) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
31
+	public function get_api_url($invoice) {
32
+        return $this->is_sandbox($invoice) ? 'https://apitest.authorize.net/xml/v1/request.api' : 'https://api.authorize.net/xml/v1/request.api';
33 33
     }
34 34
 
35 35
     /**
@@ -40,48 +40,48 @@  discard block
 block discarded – undo
40 40
      * @param WPInv_Invoice $invoice Invoice.
41 41
 	 * @return stdClass|WP_Error
42 42
 	 */
43
-    public function post( $post, $invoice ){
43
+    public function post($post, $invoice) {
44 44
 
45
-        $url      = $this->get_api_url( $invoice );
45
+        $url      = $this->get_api_url($invoice);
46 46
         $response = wp_remote_post(
47 47
             $url,
48 48
             array(
49 49
                 'headers'          => array(
50 50
                     'Content-Type' => 'application/json; charset=utf-8'
51 51
                 ),
52
-                'body'             => json_encode( $post ),
52
+                'body'             => json_encode($post),
53 53
                 'method'           => 'POST'
54 54
             )
55 55
         );
56 56
 
57
-        if ( is_wp_error( $response ) ) {
57
+        if (is_wp_error($response)) {
58 58
             return $response;
59 59
         }
60 60
 
61
-        $response = wp_unslash( wp_remote_retrieve_body( $response ) );
61
+        $response = wp_unslash(wp_remote_retrieve_body($response));
62 62
         $response = preg_replace('/\xEF\xBB\xBF/', '', $response); // https://community.developer.authorize.net/t5/Integration-and-Testing/JSON-issues/td-p/48851
63
-        $response = json_decode( $response );
63
+        $response = json_decode($response);
64 64
 
65
-        if ( empty( $response ) ) {
66
-            return new WP_Error( 'invalid_reponse', __( 'Invalid gateway response', 'invoicing' ) );
65
+        if (empty($response)) {
66
+            return new WP_Error('invalid_reponse', __('Invalid gateway response', 'invoicing'));
67 67
         }
68 68
 
69
-        if ( $response->messages->resultCode == 'Error' ) {
69
+        if ($response->messages->resultCode == 'Error') {
70 70
 
71
-            if ( $this->is_sandbox( $invoice ) ) {
72
-                wpinv_error_log( $response );
71
+            if ($this->is_sandbox($invoice)) {
72
+                wpinv_error_log($response);
73 73
             }
74 74
 
75
-            if ( $response->messages->message[0]->code == 'E00039' && ! empty( $response->customerProfileId )  && ! empty( $response->customerPaymentProfileId ) ) {
76
-                return new WP_Error( 'dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId );
75
+            if ($response->messages->message[0]->code == 'E00039' && !empty($response->customerProfileId) && !empty($response->customerPaymentProfileId)) {
76
+                return new WP_Error('dup_payment_profile', $response->customerProfileId . '.' . $response->customerPaymentProfileId);
77 77
             }
78 78
 
79
-            if ( ! empty( $response->transactionResponse ) && ! empty( $response->transactionResponse->errors ) ) {
79
+            if (!empty($response->transactionResponse) && !empty($response->transactionResponse->errors)) {
80 80
                 $error = $response->transactionResponse->errors[0];
81
-                return new WP_Error( $error->errorCode, $error->errorText );
81
+                return new WP_Error($error->errorCode, $error->errorText);
82 82
             }
83 83
 
84
-            return new WP_Error( $response->messages->message[0]->code, $response->messages->message[0]->text );
84
+            return new WP_Error($response->messages->message[0]->code, $response->messages->message[0]->text);
85 85
         }
86 86
 
87 87
         return $response;
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	public function get_auth_params() {
98 98
 
99 99
         return array(
100
-            'name'           => $this->get_option( 'login_id' ),
101
-            'transactionKey' => $this->get_option( 'transaction_key' ),
100
+            'name'           => $this->get_option('login_id'),
101
+            'transactionKey' => $this->get_option('transaction_key'),
102 102
         );
103 103
 
104 104
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param WPInv_Subscription $subscription Subscription.
111 111
      * @param WPInv_Invoice $invoice Invoice.
112 112
 	 */
113
-	public function cancel_subscription( $subscription, $invoice ) {
113
+	public function cancel_subscription($subscription, $invoice) {
114 114
 
115 115
         // Backwards compatibility. New version do not use authorize.net subscriptions.
116 116
         $this->post(
@@ -135,38 +135,38 @@  discard block
 block discarded – undo
135 135
         $this->maybe_process_old_ipn();
136 136
 
137 137
         // Validate the IPN.
138
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
139
-		    wp_die( 'Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array( 'response' => 200 ) );
138
+        if (empty($_POST) || !$this->validate_ipn()) {
139
+		    wp_die('Authorize.NET IPN Request Failure', 'Authorize.NET IPN', array('response' => 200));
140 140
         }
141 141
 
142 142
         // Event type.
143
-        $posted = json_decode( file_get_contents( 'php://input' ) );
144
-        if ( empty( $posted ) ) {
145
-            wp_die( 'Invalid JSON', 'Authorize.NET IPN', array( 'response' => 200 ) );
143
+        $posted = json_decode(file_get_contents('php://input'));
144
+        if (empty($posted)) {
145
+            wp_die('Invalid JSON', 'Authorize.NET IPN', array('response' => 200));
146 146
         }
147 147
 
148 148
         // Process the IPN.
149
-        $posted = (object) wp_unslash( $posted );
149
+        $posted = (object) wp_unslash($posted);
150 150
 
151 151
         // Process refunds.
152
-        if ( 'net.authorize.payment.refund.created' == $posted->eventType ) {
153
-            $invoice = new WPInv_Invoice( $posted->payload->merchantReferenceId );
154
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
152
+        if ('net.authorize.payment.refund.created' == $posted->eventType) {
153
+            $invoice = new WPInv_Invoice($posted->payload->merchantReferenceId);
154
+            $this->validate_ipn_invoice($invoice, $posted->payload);
155 155
             $invoice->refund();
156 156
         }
157 157
 
158 158
         // Held funds approved.
159
-        if ( 'net.authorize.payment.fraud.approved' == $posted->eventType ) {
160
-            $invoice = new WPInv_Invoice( $posted->payload->id );
161
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
162
-            $invoice->mark_paid( false, __( 'Payment released', 'invoicing' ) );
159
+        if ('net.authorize.payment.fraud.approved' == $posted->eventType) {
160
+            $invoice = new WPInv_Invoice($posted->payload->id);
161
+            $this->validate_ipn_invoice($invoice, $posted->payload);
162
+            $invoice->mark_paid(false, __('Payment released', 'invoicing'));
163 163
         }
164 164
 
165 165
         // Held funds declined.
166
-        if ( 'net.authorize.payment.fraud.declined' == $posted->eventType ) {
167
-            $invoice = new WPInv_Invoice( $posted->payload->id );
168
-            $this->validate_ipn_invoice( $invoice, $posted->payload );
169
-            $invoice->set_status( 'wpi-failed', __( 'Payment declined', 'invoicing' ) );
166
+        if ('net.authorize.payment.fraud.declined' == $posted->eventType) {
167
+            $invoice = new WPInv_Invoice($posted->payload->id);
168
+            $this->validate_ipn_invoice($invoice, $posted->payload);
169
+            $invoice->set_status('wpi-failed', __('Payment declined', 'invoicing'));
170 170
             $invoice->save();
171 171
         }
172 172
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
      * @param object $payload
182 182
 	 * @return void
183 183
 	 */
184
-	public function validate_ipn_invoice( $invoice, $payload ) {
185
-        if ( ! $invoice->exists() || $payload->id != $invoice->get_transaction_id() ) {
184
+	public function validate_ipn_invoice($invoice, $payload) {
185
+        if (!$invoice->exists() || $payload->id != $invoice->get_transaction_id()) {
186 186
             exit;
187 187
         }
188 188
     }
@@ -194,32 +194,32 @@  discard block
 block discarded – undo
194 194
 	 */
195 195
 	public function maybe_process_old_ipn() {
196 196
 
197
-        $data = wp_kses_post_deep( wp_unslash( $_POST ) );
197
+        $data = wp_kses_post_deep(wp_unslash($_POST));
198 198
 
199 199
         // Only process subscriptions subscriptions.
200
-        if ( empty( $data['x_subscription_id'] ) ) {
200
+        if (empty($data['x_subscription_id'])) {
201 201
             return;
202 202
         }
203 203
 
204 204
         // Check validity.
205
-        $this->validate_old_ipn_signature( $data );
205
+        $this->validate_old_ipn_signature($data);
206 206
 
207 207
         // Fetch the associated subscription.
208
-        $subscription_id = WPInv_Subscription::get_subscription_id_by_field( $data['x_subscription_id'] );
209
-        $subscription    = new WPInv_Subscription( $subscription_id );
208
+        $subscription_id = WPInv_Subscription::get_subscription_id_by_field($data['x_subscription_id']);
209
+        $subscription    = new WPInv_Subscription($subscription_id);
210 210
 
211 211
         // Abort if it is missing or completed.
212
-        if ( ! $subscription->get_id() || $subscription->has_status( 'completed' ) ) {
212
+        if (!$subscription->get_id() || $subscription->has_status('completed')) {
213 213
             return;
214 214
         }
215 215
 
216 216
         // Payment status.
217
-        if ( 1 == $data['x_response_code'] ) {
217
+        if (1 == $data['x_response_code']) {
218 218
 
219 219
             // Renew the subscription.
220 220
             $subscription->add_payment(
221 221
                 array(
222
-                    'transaction_id' => sanitize_text_field( $data['x_trans_id'] ),
222
+                    'transaction_id' => sanitize_text_field($data['x_trans_id']),
223 223
                     'gateway'        => $this->id
224 224
                 )
225 225
             );
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @param array $posted
240 240
 	 */
241
-	public function validate_old_ipn_signature( $posted ) {
241
+	public function validate_old_ipn_signature($posted) {
242 242
 
243
-        $signature = $this->get_option( 'signature_key' );
244
-        if ( ! empty( $signature ) ) {
245
-            $login_id  = $this->get_option( 'login_id' );
246
-            $trans_id  = wpinv_clean( $_POST['x_trans_id'] );
247
-            $amount    = wpinv_clean( $_POST['x_amount'] );
248
-            $hash      = hash_hmac ( 'sha512', "^$login_id^$trans_id^$amount^", hex2bin( $signature ) );
243
+        $signature = $this->get_option('signature_key');
244
+        if (!empty($signature)) {
245
+            $login_id  = $this->get_option('login_id');
246
+            $trans_id  = wpinv_clean($_POST['x_trans_id']);
247
+            $amount    = wpinv_clean($_POST['x_amount']);
248
+            $hash      = hash_hmac('sha512', "^$login_id^$trans_id^$amount^", hex2bin($signature));
249 249
 
250
-            if ( ! hash_equals( $hash, $posted['x_SHA2_Hash'] ) ) {
251
-                wpinv_error_log( $posted['x_SHA2_Hash'], "Invalid signature. Expected $hash" );
250
+            if (!hash_equals($hash, $posted['x_SHA2_Hash'])) {
251
+                wpinv_error_log($posted['x_SHA2_Hash'], "Invalid signature. Expected $hash");
252 252
                 exit;
253 253
             }
254 254
 
@@ -261,28 +261,28 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function validate_ipn() {
263 263
 
264
-        wpinv_error_log( 'Validating Authorize.NET IPN response' );
264
+        wpinv_error_log('Validating Authorize.NET IPN response');
265 265
 
266
-        if ( empty( $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
266
+        if (empty($_SERVER['HTTP_X_ANET_SIGNATURE'])) {
267 267
             return false;
268 268
         }
269 269
 
270
-        $signature = $this->get_option( 'signature_key' );
270
+        $signature = $this->get_option('signature_key');
271 271
 
272
-        if ( empty( $signature ) ) {
273
-            wpinv_error_log( 'Error: You have not set a signature key' );
272
+        if (empty($signature)) {
273
+            wpinv_error_log('Error: You have not set a signature key');
274 274
             return false;
275 275
         }
276 276
 
277
-        $hash  = hash_hmac ( 'sha512', file_get_contents( 'php://input' ), hex2bin( $signature ) );
277
+        $hash = hash_hmac('sha512', file_get_contents('php://input'), hex2bin($signature));
278 278
 
279
-        if ( hash_equals( $hash, $_SERVER['HTTP_X_ANET_SIGNATURE'] ) ) {
280
-            wpinv_error_log( 'Successfully validated the IPN' );
279
+        if (hash_equals($hash, $_SERVER['HTTP_X_ANET_SIGNATURE'])) {
280
+            wpinv_error_log('Successfully validated the IPN');
281 281
             return true;
282 282
         }
283 283
 
284
-        wpinv_error_log( 'IPN hash is not valid' );
285
-        wpinv_error_log(  $_SERVER['HTTP_X_ANET_SIGNATURE']  );
284
+        wpinv_error_log('IPN hash is not valid');
285
+        wpinv_error_log($_SERVER['HTTP_X_ANET_SIGNATURE']);
286 286
         return false;
287 287
 
288 288
     }
Please login to merge, or discard this patch.