Passed
Push — master ( 862b0e...047a35 )
by Stiofan
17:04
created
includes/class-getpaid-template.php 2 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
     public $templates_url;
21 21
 
22 22
     /**
23
-	 * Class constructor.
24
-	 *
25
-	 * @since 1.0.19
26
-	 */
27
-	public function __construct() {
23
+     * Class constructor.
24
+     *
25
+     * @since 1.0.19
26
+     */
27
+    public function __construct() {
28 28
 
29 29
         $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' );
30 30
         $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' );
31 31
     }
32 32
 
33 33
     /**
34
-	 * Checks if this is a preview page
35
-	 *
36
-	 * @since 1.0.19
37
-	 * @return bool
38
-	 */
39
-	public function is_preview() {
34
+     * Checks if this is a preview page
35
+     *
36
+     * @since 1.0.19
37
+     * @return bool
38
+     */
39
+    public function is_preview() {
40 40
         return 
41 41
             $this->is_divi_preview() ||
42 42
             $this->is_elementor_preview() ||
@@ -48,73 +48,73 @@  discard block
 block discarded – undo
48 48
     }
49 49
 
50 50
     /**
51
-	 * Checks if this is an elementor preview page
52
-	 *
53
-	 * @since 1.0.19
54
-	 * @return bool
55
-	 */
56
-	public function is_elementor_preview() {
57
-		return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
58
-	}
59
-
60
-	/**
61
-	 * Checks if this is a DIVI preview page
62
-	 *
63
-	 * @since 1.0.19
64
-	 * @return bool
65
-	 */
66
-	public function is_divi_preview() {
67
-		return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
68
-	}
69
-
70
-	/**
71
-	 * Checks if this is a beaver builder preview page
72
-	 *
73
-	 * @since 1.0.19
74
-	 * @return bool
75
-	 */
76
-	public function is_beaver_preview() {
77
-		return isset( $_REQUEST['fl_builder'] );
78
-	}
79
-
80
-	/**
81
-	 * Checks if this is a siteorigin builder preview page
82
-	 *
83
-	 * @since 1.0.19
84
-	 * @return bool
85
-	 */
86
-	public function is_siteorigin_preview() {
87
-		return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
88
-	}
89
-
90
-	/**
91
-	 * Checks if this is a cornerstone builder preview page
92
-	 *
93
-	 * @since 1.0.19
94
-	 * @return bool
95
-	 */
96
-	public function is_cornerstone_preview() {
97
-		return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
98
-	}
99
-
100
-	/**
101
-	 * Checks if this is a fusion builder preview page
102
-	 *
103
-	 * @since 1.0.19
104
-	 * @return bool
105
-	 */
106
-	public function is_fusion_preview() {
107
-		return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
108
-	}
109
-
110
-	/**
111
-	 * Checks if this is an oxygen builder preview page
112
-	 *
113
-	 * @since 1.0.19
114
-	 * @return bool
115
-	 */
116
-	public function is_oxygen_preview() {
117
-		return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) );
51
+     * Checks if this is an elementor preview page
52
+     *
53
+     * @since 1.0.19
54
+     * @return bool
55
+     */
56
+    public function is_elementor_preview() {
57
+        return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
58
+    }
59
+
60
+    /**
61
+     * Checks if this is a DIVI preview page
62
+     *
63
+     * @since 1.0.19
64
+     * @return bool
65
+     */
66
+    public function is_divi_preview() {
67
+        return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
68
+    }
69
+
70
+    /**
71
+     * Checks if this is a beaver builder preview page
72
+     *
73
+     * @since 1.0.19
74
+     * @return bool
75
+     */
76
+    public function is_beaver_preview() {
77
+        return isset( $_REQUEST['fl_builder'] );
78
+    }
79
+
80
+    /**
81
+     * Checks if this is a siteorigin builder preview page
82
+     *
83
+     * @since 1.0.19
84
+     * @return bool
85
+     */
86
+    public function is_siteorigin_preview() {
87
+        return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
88
+    }
89
+
90
+    /**
91
+     * Checks if this is a cornerstone builder preview page
92
+     *
93
+     * @since 1.0.19
94
+     * @return bool
95
+     */
96
+    public function is_cornerstone_preview() {
97
+        return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
98
+    }
99
+
100
+    /**
101
+     * Checks if this is a fusion builder preview page
102
+     *
103
+     * @since 1.0.19
104
+     * @return bool
105
+     */
106
+    public function is_fusion_preview() {
107
+        return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
108
+    }
109
+
110
+    /**
111
+     * Checks if this is an oxygen builder preview page
112
+     *
113
+     * @since 1.0.19
114
+     * @return bool
115
+     */
116
+    public function is_oxygen_preview() {
117
+        return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) );
118 118
     }
119 119
 
120 120
     /**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
125 125
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
126 126
      */
127
-	public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
127
+    public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
128 128
 
129 129
         // Load the defaults for the template path and default path.
130 130
         $template_path = empty( $template_path ) ? 'invoicing' : $template_path;
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
     }
146 146
     
147 147
     /**
148
-	 * Loads a template
149
-	 *
150
-	 * @since 1.0.19
151
-	 * @return bool
152
-	 */
153
-	protected function load_template( $template_name, $template_path, $args ) {
148
+     * Loads a template
149
+     *
150
+     * @since 1.0.19
151
+     * @return bool
152
+     */
153
+    protected function load_template( $template_name, $template_path, $args ) {
154 154
 
155 155
         if ( is_array( $args ) ){
156 156
             extract( $args );
157 157
         }
158 158
 
159 159
         // Fires before loading a template.
160
-	    do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
160
+        do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
161 161
 
162 162
         // Load the template.
163
-	    include( $template_path );
163
+        include( $template_path );
164 164
 
165 165
         // Fires after loading a template.
166 166
         do_action( 'wpinv_after_template_part', $template_name, $template_path, $args );
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
178 178
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
179 179
      */
180
-	public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
180
+    public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
181 181
 
182 182
         // Locate the template.
183 183
         $located = $this->locate_template( $template_name, $template_path, $default_path );
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
203 203
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
204 204
      */
205
-	public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
205
+    public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
206 206
         ob_start();
207 207
         $this->display_template( $template_name, $args, $template_path, $default_path );
208 208
         return ob_get_clean();
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct() {
28 28
 
29
-        $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' );
30
-        $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' );
29
+        $this->templates_dir = apply_filters('getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates');
30
+        $this->templates_url = apply_filters('getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates');
31 31
     }
32 32
 
33 33
     /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @return bool
55 55
 	 */
56 56
 	public function is_elementor_preview() {
57
-		return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' );
57
+		return isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax');
58 58
 	}
59 59
 
60 60
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return bool
65 65
 	 */
66 66
 	public function is_divi_preview() {
67
-		return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' );
67
+		return isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'et_pb');
68 68
 	}
69 69
 
70 70
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @return bool
75 75
 	 */
76 76
 	public function is_beaver_preview() {
77
-		return isset( $_REQUEST['fl_builder'] );
77
+		return isset($_REQUEST['fl_builder']);
78 78
 	}
79 79
 
80 80
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @return bool
85 85
 	 */
86 86
 	public function is_siteorigin_preview() {
87
-		return ! empty( $_REQUEST['siteorigin_panels_live_editor'] );
87
+		return !empty($_REQUEST['siteorigin_panels_live_editor']);
88 88
 	}
89 89
 
90 90
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return bool
95 95
 	 */
96 96
 	public function is_cornerstone_preview() {
97
-		return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint';
97
+		return !empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint';
98 98
 	}
99 99
 
100 100
 	/**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return bool
105 105
 	 */
106 106
 	public function is_fusion_preview() {
107
-		return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] );
107
+		return !empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce']);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return bool
115 115
 	 */
116 116
 	public function is_oxygen_preview() {
117
-		return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) );
117
+		return !empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"));
118 118
     }
119 119
 
120 120
     /**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
      * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
125 125
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
126 126
      */
127
-	public function locate_template( $template_name, $template_path = '', $default_path = '' ) {
127
+	public function locate_template($template_name, $template_path = '', $default_path = '') {
128 128
 
129 129
         // Load the defaults for the template path and default path.
130
-        $template_path = empty( $template_path ) ? 'invoicing' : $template_path;
131
-        $default_path  = empty( $default_path ) ? $this->templates_dir : $default_path;
132
-        $default_path  = apply_filters( 'getpaid_template_default_template_path', $default_path, $template_name );
130
+        $template_path = empty($template_path) ? 'invoicing' : $template_path;
131
+        $default_path  = empty($default_path) ? $this->templates_dir : $default_path;
132
+        $default_path  = apply_filters('getpaid_template_default_template_path', $default_path, $template_name);
133 133
 
134 134
         // Is it overidden?
135 135
         $template = locate_template(
136
-            array( trailingslashit( $template_path ) . $template_name, 'wpinv-' . $template_name )
136
+            array(trailingslashit($template_path) . $template_name, 'wpinv-' . $template_name)
137 137
         );
138 138
 
139 139
         // If not, load the default template.
140
-        if ( empty( $template ) ) {
141
-            $template = trailingslashit( $default_path ) . $template_name;
140
+        if (empty($template)) {
141
+            $template = trailingslashit($default_path) . $template_name;
142 142
         }
143 143
 
144
-        return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path );
144
+        return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path);
145 145
     }
146 146
     
147 147
     /**
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	 * @since 1.0.19
151 151
 	 * @return bool
152 152
 	 */
153
-	protected function load_template( $template_name, $template_path, $args ) {
153
+	protected function load_template($template_name, $template_path, $args) {
154 154
 
155
-        if ( is_array( $args ) ){
156
-            extract( $args );
155
+        if (is_array($args)) {
156
+            extract($args);
157 157
         }
158 158
 
159 159
         // Fires before loading a template.
160
-	    do_action( 'wpinv_before_template_part', $template_name, $template_path, $args );
160
+	    do_action('wpinv_before_template_part', $template_name, $template_path, $args);
161 161
 
162 162
         // Load the template.
163
-	    include( $template_path );
163
+	    include($template_path);
164 164
 
165 165
         // Fires after loading a template.
166
-        do_action( 'wpinv_after_template_part', $template_name, $template_path, $args );
166
+        do_action('wpinv_after_template_part', $template_name, $template_path, $args);
167 167
 
168 168
     }
169 169
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
178 178
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
179 179
      */
180
-	public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
180
+	public function display_template($template_name, $args = array(), $template_path = '', $default_path = '') {
181 181
 
182 182
         // Locate the template.
183
-        $located = $this->locate_template( $template_name, $template_path, $default_path );
183
+        $located = $this->locate_template($template_name, $template_path, $default_path);
184 184
 
185 185
         // Abort if the file does not exist.
186
-        if ( ! file_exists( $located ) ) {
187
-            getpaid_doing_it_wrong( __CLASS__ . '::' .__METHOD__, sprintf( '<code>%s</code> does not exist.', $located ), '1.0.19' );
186
+        if (!file_exists($located)) {
187
+            getpaid_doing_it_wrong(__CLASS__ . '::' . __METHOD__, sprintf('<code>%s</code> does not exist.', $located), '1.0.19');
188 188
             return;
189 189
         }
190 190
 
191
-        $this->load_template( $template_name, $located, $args );
191
+        $this->load_template($template_name, $located, $args);
192 192
 
193 193
     }
194 194
     
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
      * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
203 203
      * @param string $default_path The root path to the default template. Defaults to invoicing/templates
204 204
      */
205
-	public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
205
+	public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
206 206
         ob_start();
207
-        $this->display_template( $template_name, $args, $template_path, $default_path );
207
+        $this->display_template($template_name, $args, $template_path, $default_path);
208 208
         return ob_get_clean();
209 209
     }
210 210
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 2 patches
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -12,436 +12,436 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 500 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-
98
-		}
99
-
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 500 );
102
-	}
103
-
104
-	/**
105
-	 * Check PayPal IPN validity.
106
-	 */
107
-	protected function validate_ipn() {
108
-
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
110
-
111
-		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
114
-
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data' );
117
-		}
118
-
119
-		// Validate the IPN.
120
-		$posted['cmd'] = '_notify-validate';
121
-
122
-		// Send back post vars to paypal.
123
-		$params = array(
124
-			'body'        => $posted,
125
-			'timeout'     => 60,
126
-			'httpversion' => '1.1',
127
-			'compress'    => false,
128
-			'decompress'  => false,
129
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
-		);
131
-
132
-		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
-
135
-		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
138
-			return true;
139
-		}
140
-
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
-			return false;
144
-		}
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 500 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+
98
+        }
99
+
100
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
+        wp_die( 'Could not retrieve the associated invoice.', 500 );
102
+    }
103
+
104
+    /**
105
+     * Check PayPal IPN validity.
106
+     */
107
+    protected function validate_ipn() {
108
+
109
+        wpinv_error_log( 'Validating PayPal IPN response', false );
110
+
111
+        // Retrieve the associated invoice.
112
+        $posted  = wp_unslash( $_POST );
113
+        $invoice = $this->get_ipn_invoice( $posted );
114
+
115
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
116
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data' );
117
+        }
118
+
119
+        // Validate the IPN.
120
+        $posted['cmd'] = '_notify-validate';
121
+
122
+        // Send back post vars to paypal.
123
+        $params = array(
124
+            'body'        => $posted,
125
+            'timeout'     => 60,
126
+            'httpversion' => '1.1',
127
+            'compress'    => false,
128
+            'decompress'  => false,
129
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
+        );
131
+
132
+        // Post back to get a response.
133
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
+
135
+        // Check to see if the request was valid.
136
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
+            wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
138
+            return true;
139
+        }
140
+
141
+        if ( is_wp_error( $response ) ) {
142
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
+            return false;
144
+        }
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
-		return false;
148
-
149
-	}
146
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
+        return false;
148
+
149
+    }
150 150
 
151
-	/**
152
-	 * Check currency from IPN matches the invoice.
153
-	 *
154
-	 * @param WPInv_Invoice $invoice          Invoice object.
155
-	 * @param string   $currency currency to validate.
156
-	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
151
+    /**
152
+     * Check currency from IPN matches the invoice.
153
+     *
154
+     * @param WPInv_Invoice $invoice          Invoice object.
155
+     * @param string   $currency currency to validate.
156
+     */
157
+    protected function validate_ipn_currency( $invoice, $currency ) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
160 160
 
161
-			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+            /* translators: %s: currency code. */
162
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
-		}
164
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
+        }
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency' );
168
-	}
167
+        wpinv_error_log( $currency, 'Validated IPN Currency' );
168
+    }
169 169
 
170
-	/**
171
-	 * Check payment amount from IPN matches the invoice.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice          Invoice object.
174
-	 * @param float   $amount amount to validate.
175
-	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
170
+    /**
171
+     * Check payment amount from IPN matches the invoice.
172
+     *
173
+     * @param WPInv_Invoice $invoice          Invoice object.
174
+     * @param float   $amount amount to validate.
175
+     */
176
+    protected function validate_ipn_amount( $invoice, $amount ) {
177
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
178 178
 
179
-			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+            /* translators: %s: Amount. */
180
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
-		}
182
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
+        }
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount' );
186
-	}
185
+        wpinv_error_log( $amount, 'Validated IPN Amount' );
186
+    }
187 187
 
188
-	/**
189
-	 * Verify receiver email from PayPal.
190
-	 *
191
-	 * @param WPInv_Invoice $invoice          Invoice object.
192
-	 * @param string   $receiver_email Email to validate.
193
-	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
188
+    /**
189
+     * Verify receiver email from PayPal.
190
+     *
191
+     * @param WPInv_Invoice $invoice          Invoice object.
192
+     * @param string   $receiver_email Email to validate.
193
+     */
194
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
+        $paypal_email = wpinv_get_option( 'paypal_email' );
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
199 199
 
200
-			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+            /* translators: %s: email address . */
201
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
-		}
203
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
+        }
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
207
-	}
206
+        wpinv_error_log( 'Validated PayPal Email', false );
207
+    }
208 208
 
209
-	/**
210
-	 * Handles one time payments.
211
-	 *
212
-	 * @param WPInv_Invoice $invoice  Invoice object.
213
-	 * @param array    $posted Posted data.
214
-	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
216
-
217
-		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
220
-
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
223
-
224
-		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
-			$invoice->save();
228
-		}
209
+    /**
210
+     * Handles one time payments.
211
+     *
212
+     * @param WPInv_Invoice $invoice  Invoice object.
213
+     * @param array    $posted Posted data.
214
+     */
215
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
216
+
217
+        // Collect payment details
218
+        $payment_status = strtolower( $posted['payment_status'] );
219
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
220
+
221
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
222
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
223
+
224
+        // Update the transaction id.
225
+        if ( ! empty( $posted['txn_id'] ) ) {
226
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
+            $invoice->save();
228
+        }
229 229
 
230
-		// Process a refund.
231
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
230
+        // Process a refund.
231
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232 232
 
233
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
233
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
234 234
 
235
-			if ( ! $invoice->is_refunded() ) {
236
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
237
-			}
235
+            if ( ! $invoice->is_refunded() ) {
236
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
237
+            }
238 238
 
239
-			return wpinv_error_log( $posted['reason_code'], false );
240
-		}
239
+            return wpinv_error_log( $posted['reason_code'], false );
240
+        }
241 241
 
242
-		// Process payments.
243
-		if ( $payment_status == 'completed' ) {
242
+        // Process payments.
243
+        if ( $payment_status == 'completed' ) {
244 244
 
245
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
246
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
247
-			}
245
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
246
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
247
+            }
248 248
 
249
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
249
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
250 250
 
251
-			$note = '';
251
+            $note = '';
252 252
 
253
-			if ( ! empty( $posted['mc_fee'] ) ) {
254
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
-			}
253
+            if ( ! empty( $posted['mc_fee'] ) ) {
254
+                $note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
+            }
256 256
 
257
-			if ( ! empty( $posted['payer_status'] ) ) {
258
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
259
-			}
257
+            if ( ! empty( $posted['payer_status'] ) ) {
258
+                $note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
259
+            }
260 260
 
261
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
262
-			return wpinv_error_log( 'Invoice marked as paid.', false );
261
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
262
+            return wpinv_error_log( 'Invoice marked as paid.', false );
263 263
 
264
-		}
264
+        }
265 265
 
266
-		// Pending payments.
267
-		if ( $payment_status == 'pending' ) {
266
+        // Pending payments.
267
+        if ( $payment_status == 'pending' ) {
268 268
 
269
-			/* translators: %s: pending reason. */
270
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
269
+            /* translators: %s: pending reason. */
270
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271 271
 
272
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
273
-		}
272
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
273
+        }
274 274
 
275
-		/* translators: %s: payment status. */
276
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
275
+        /* translators: %s: payment status. */
276
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277 277
 
278
-	}
278
+    }
279 279
 
280
-	/**
281
-	 * Handles one time payments.
282
-	 *
283
-	 * @param WPInv_Invoice $invoice  Invoice object.
284
-	 * @param array    $posted Posted data.
285
-	 */
286
-	protected function ipn_txn_cart( $invoice, $posted ) {
287
-		$this->ipn_txn_web_accept( $invoice, $posted );
288
-	}
280
+    /**
281
+     * Handles one time payments.
282
+     *
283
+     * @param WPInv_Invoice $invoice  Invoice object.
284
+     * @param array    $posted Posted data.
285
+     */
286
+    protected function ipn_txn_cart( $invoice, $posted ) {
287
+        $this->ipn_txn_web_accept( $invoice, $posted );
288
+    }
289 289
 
290
-	/**
291
-	 * Handles subscription sign ups.
292
-	 *
293
-	 * @param WPInv_Invoice $invoice  Invoice object.
294
-	 * @param array    $posted Posted data.
295
-	 */
296
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
290
+    /**
291
+     * Handles subscription sign ups.
292
+     *
293
+     * @param WPInv_Invoice $invoice  Invoice object.
294
+     * @param array    $posted Posted data.
295
+     */
296
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
297 297
 
298
-		wpinv_error_log( 'Processing subscription signup', false );
298
+        wpinv_error_log( 'Processing subscription signup', false );
299 299
 
300
-		// Make sure the invoice has a subscription.
301
-		$subscription = getpaid_get_invoice_subscription( $invoice );
300
+        // Make sure the invoice has a subscription.
301
+        $subscription = getpaid_get_invoice_subscription( $invoice );
302 302
 
303
-		if ( empty( $subscription ) ) {
304
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
305
-		}
303
+        if ( empty( $subscription ) ) {
304
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
305
+        }
306 306
 
307
-		// Validate the IPN.
308
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
309
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
310
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
307
+        // Validate the IPN.
308
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
309
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
310
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311 311
 
312
-		// Activate the subscription.
313
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
314
-		$subscription->set_date_created( current_time( 'mysql' ) );
315
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
316
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
317
-		$subscription->activate();
312
+        // Activate the subscription.
313
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
314
+        $subscription->set_date_created( current_time( 'mysql' ) );
315
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
316
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
317
+        $subscription->activate();
318 318
 
319
-		// Set the transaction id.
320
-		if ( ! empty( $posted['txn_id'] ) ) {
321
-			$invoice->set_transaction_id( $posted['txn_id'] );
322
-		}
319
+        // Set the transaction id.
320
+        if ( ! empty( $posted['txn_id'] ) ) {
321
+            $invoice->set_transaction_id( $posted['txn_id'] );
322
+        }
323 323
 
324
-		// Update the payment status.
325
-		$invoice->mark_paid();
324
+        // Update the payment status.
325
+        $invoice->mark_paid();
326 326
 
327
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
327
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
328 328
 
329
-		wpinv_error_log( 'Subscription started.', false );
330
-	}
329
+        wpinv_error_log( 'Subscription started.', false );
330
+    }
331 331
 
332
-	/**
333
-	 * Handles subscription renewals.
334
-	 *
335
-	 * @param WPInv_Invoice $invoice  Invoice object.
336
-	 * @param array    $posted Posted data.
337
-	 */
338
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
332
+    /**
333
+     * Handles subscription renewals.
334
+     *
335
+     * @param WPInv_Invoice $invoice  Invoice object.
336
+     * @param array    $posted Posted data.
337
+     */
338
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
339 339
 
340
-		// Make sure the invoice has a subscription.
341
-		$subscription = wpinv_get_subscription( $invoice );
340
+        // Make sure the invoice has a subscription.
341
+        $subscription = wpinv_get_subscription( $invoice );
342 342
 
343
-		if ( empty( $subscription ) ) {
344
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
345
-		}
343
+        if ( empty( $subscription ) ) {
344
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
345
+        }
346 346
 
347
-		// Abort if this is the first payment.
348
-		if ( ( $invoice->is_paid() && date( 'Ynd', strtotime( $invoice->get_date_completed() ) ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) || date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
347
+        // Abort if this is the first payment.
348
+        if ( ( $invoice->is_paid() && date( 'Ynd', strtotime( $invoice->get_date_completed() ) ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) || date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
349 349
 
350
-			if ( ! empty( $posted['txn_id'] ) ) {
351
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
352
-				$invoice->mark_paid();
353
-				$invoice->save();
354
-			}
350
+            if ( ! empty( $posted['txn_id'] ) ) {
351
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
352
+                $invoice->mark_paid();
353
+                $invoice->save();
354
+            }
355 355
 
356
-			return;
357
-		}
356
+            return;
357
+        }
358 358
 
359
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
359
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
360 360
 
361
-		// Abort if the payment is already recorded.
362
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
363
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
364
-		}
361
+        // Abort if the payment is already recorded.
362
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
363
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
364
+        }
365 365
 
366
-		$args = array(
367
-			'transaction_id' => $posted['txn_id'],
368
-			'gateway'        => $this->id,
369
-		);
370
-
371
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
372
-
373
-		if ( empty( $invoice ) ) {
374
-			return;
375
-		}
376
-
377
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
378
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
379
-
380
-		$subscription->renew();
381
-		wpinv_error_log( 'Subscription renewed.', false );
382
-
383
-	}
384
-
385
-	/**
386
-	 * Handles subscription cancelations.
387
-	 *
388
-	 * @param WPInv_Invoice $invoice  Invoice object.
389
-	 */
390
-	protected function ipn_txn_subscr_cancel( $invoice ) {
366
+        $args = array(
367
+            'transaction_id' => $posted['txn_id'],
368
+            'gateway'        => $this->id,
369
+        );
370
+
371
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
372
+
373
+        if ( empty( $invoice ) ) {
374
+            return;
375
+        }
376
+
377
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
378
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
379
+
380
+        $subscription->renew();
381
+        wpinv_error_log( 'Subscription renewed.', false );
382
+
383
+    }
384
+
385
+    /**
386
+     * Handles subscription cancelations.
387
+     *
388
+     * @param WPInv_Invoice $invoice  Invoice object.
389
+     */
390
+    protected function ipn_txn_subscr_cancel( $invoice ) {
391 391
 
392
-		// Make sure the invoice has a subscription.
393
-		$subscription = wpinv_get_subscription( $invoice );
392
+        // Make sure the invoice has a subscription.
393
+        $subscription = wpinv_get_subscription( $invoice );
394 394
 
395
-		if ( empty( $subscription ) ) {
396
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
397
-		}
395
+        if ( empty( $subscription ) ) {
396
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
397
+        }
398 398
 
399
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
400
-		$subscription->cancel();
401
-		wpinv_error_log( 'Subscription cancelled.', false );
399
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
400
+        $subscription->cancel();
401
+        wpinv_error_log( 'Subscription cancelled.', false );
402 402
 
403
-	}
403
+    }
404 404
 
405
-	/**
406
-	 * Handles subscription completions.
407
-	 *
408
-	 * @param WPInv_Invoice $invoice  Invoice object.
409
-	 * @param array    $posted Posted data.
410
-	 */
411
-	protected function ipn_txn_subscr_eot( $invoice ) {
405
+    /**
406
+     * Handles subscription completions.
407
+     *
408
+     * @param WPInv_Invoice $invoice  Invoice object.
409
+     * @param array    $posted Posted data.
410
+     */
411
+    protected function ipn_txn_subscr_eot( $invoice ) {
412 412
 
413
-		// Make sure the invoice has a subscription.
414
-		$subscription = wpinv_get_subscription( $invoice );
413
+        // Make sure the invoice has a subscription.
414
+        $subscription = wpinv_get_subscription( $invoice );
415 415
 
416
-		if ( empty( $subscription ) ) {
417
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
418
-		}
416
+        if ( empty( $subscription ) ) {
417
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
418
+        }
419 419
 
420
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
421
-		$subscription->complete();
422
-		wpinv_error_log( 'Subscription completed.', false );
420
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
421
+        $subscription->complete();
422
+        wpinv_error_log( 'Subscription completed.', false );
423 423
 
424
-	}
424
+    }
425 425
 
426
-	/**
427
-	 * Handles subscription fails.
428
-	 *
429
-	 * @param WPInv_Invoice $invoice  Invoice object.
430
-	 * @param array    $posted Posted data.
431
-	 */
432
-	protected function ipn_txn_subscr_failed( $invoice ) {
426
+    /**
427
+     * Handles subscription fails.
428
+     *
429
+     * @param WPInv_Invoice $invoice  Invoice object.
430
+     * @param array    $posted Posted data.
431
+     */
432
+    protected function ipn_txn_subscr_failed( $invoice ) {
433 433
 
434
-		// Make sure the invoice has a subscription.
435
-		$subscription = wpinv_get_subscription( $invoice );
434
+        // Make sure the invoice has a subscription.
435
+        $subscription = wpinv_get_subscription( $invoice );
436 436
 
437
-		if ( empty( $subscription ) ) {
438
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
439
-		}
437
+        if ( empty( $subscription ) ) {
438
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
439
+        }
440 440
 
441
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
442
-		$subscription->failing();
443
-		wpinv_error_log( 'Subscription marked as failing.', false );
441
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
442
+        $subscription->failing();
443
+        wpinv_error_log( 'Subscription marked as failing.', false );
444 444
 
445
-	}
445
+    }
446 446
 
447 447
 }
Please login to merge, or discard this patch.
Spacing   +133 added lines, -133 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 IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 500 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 500);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 
98 98
 		}
99 99
 
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 500 );
100
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
101
+		wp_die('Could not retrieve the associated invoice.', 500);
102 102
 	}
103 103
 
104 104
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function validate_ipn() {
108 108
 
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
+		wpinv_error_log('Validating PayPal IPN response', false);
110 110
 
111 111
 		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
112
+		$posted  = wp_unslash($_POST);
113
+		$invoice = $this->get_ipn_invoice($posted);
114 114
 
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data' );
115
+		if ($this->gateway->is_sandbox($invoice)) {
116
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data');
117 117
 		}
118 118
 
119 119
 		// Validate the IPN.
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		);
131 131
 
132 132
 		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
134 134
 
135 135
 		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
136
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
137
+			wpinv_error_log($response['body'], 'Received valid response from PayPal IPN');
138 138
 			return true;
139 139
 		}
140 140
 
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
141
+		if (is_wp_error($response)) {
142
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
143 143
 			return false;
144 144
 		}
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
147 147
 		return false;
148 148
 
149 149
 	}
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param WPInv_Invoice $invoice          Invoice object.
155 155
 	 * @param string   $currency currency to validate.
156 156
 	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
157
+	protected function validate_ipn_currency($invoice, $currency) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
160 160
 
161 161
 			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
165 165
 		}
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency' );
167
+		wpinv_error_log($currency, 'Validated IPN Currency');
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 	 * @param WPInv_Invoice $invoice          Invoice object.
174 174
 	 * @param float   $amount amount to validate.
175 175
 	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
176
+	protected function validate_ipn_amount($invoice, $amount) {
177
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
178 178
 
179 179
 			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
183 183
 		}
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount' );
185
+		wpinv_error_log($amount, 'Validated IPN Amount');
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param WPInv_Invoice $invoice          Invoice object.
192 192
 	 * @param string   $receiver_email Email to validate.
193 193
 	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
194
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
195
+		$paypal_email = wpinv_get_option('paypal_email');
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
198
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
199 199
 
200 200
 			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
204 204
 		}
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
206
+		wpinv_error_log('Validated PayPal Email', false);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,68 +212,68 @@  discard block
 block discarded – undo
212 212
 	 * @param WPInv_Invoice $invoice  Invoice object.
213 213
 	 * @param array    $posted Posted data.
214 214
 	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
215
+	protected function ipn_txn_web_accept($invoice, $posted) {
216 216
 
217 217
 		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
218
+		$payment_status = strtolower($posted['payment_status']);
219
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+		$this->validate_ipn_receiver_email($invoice, $business_email);
222
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
223 223
 
224 224
 		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
225
+		if (!empty($posted['txn_id'])) {
226
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
227 227
 			$invoice->save();
228 228
 		}
229 229
 
230 230
 		// Process a refund.
231
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
231
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
232 232
 
233
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
233
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
234 234
 
235
-			if ( ! $invoice->is_refunded() ) {
236
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
235
+			if (!$invoice->is_refunded()) {
236
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
237 237
 			}
238 238
 
239
-			return wpinv_error_log( $posted['reason_code'], false );
239
+			return wpinv_error_log($posted['reason_code'], false);
240 240
 		}
241 241
 
242 242
 		// Process payments.
243
-		if ( $payment_status == 'completed' ) {
243
+		if ($payment_status == 'completed') {
244 244
 
245
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
246
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
245
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
246
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
247 247
 			}
248 248
 
249
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
249
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
250 250
 
251 251
 			$note = '';
252 252
 
253
-			if ( ! empty( $posted['mc_fee'] ) ) {
254
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
253
+			if (!empty($posted['mc_fee'])) {
254
+				$note = sprintf(__('PayPal Transaction Fee %.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
255 255
 			}
256 256
 
257
-			if ( ! empty( $posted['payer_status'] ) ) {
258
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
257
+			if (!empty($posted['payer_status'])) {
258
+				$note = ' ' . sprintf(__('Buyer status %.', 'invoicing'), sanitize_text_field($posted['payer_status']));
259 259
 			}
260 260
 
261
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
262
-			return wpinv_error_log( 'Invoice marked as paid.', false );
261
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
262
+			return wpinv_error_log('Invoice marked as paid.', false);
263 263
 
264 264
 		}
265 265
 
266 266
 		// Pending payments.
267
-		if ( $payment_status == 'pending' ) {
267
+		if ($payment_status == 'pending') {
268 268
 
269 269
 			/* translators: %s: pending reason. */
270
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
270
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
271 271
 
272
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
272
+			return wpinv_error_log('Invoice marked as "payment held".', false);
273 273
 		}
274 274
 
275 275
 		/* translators: %s: payment status. */
276
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
276
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
277 277
 
278 278
 	}
279 279
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param WPInv_Invoice $invoice  Invoice object.
284 284
 	 * @param array    $posted Posted data.
285 285
 	 */
286
-	protected function ipn_txn_cart( $invoice, $posted ) {
287
-		$this->ipn_txn_web_accept( $invoice, $posted );
286
+	protected function ipn_txn_cart($invoice, $posted) {
287
+		$this->ipn_txn_web_accept($invoice, $posted);
288 288
 	}
289 289
 
290 290
 	/**
@@ -293,40 +293,40 @@  discard block
 block discarded – undo
293 293
 	 * @param WPInv_Invoice $invoice  Invoice object.
294 294
 	 * @param array    $posted Posted data.
295 295
 	 */
296
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
296
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
297 297
 
298
-		wpinv_error_log( 'Processing subscription signup', false );
298
+		wpinv_error_log('Processing subscription signup', false);
299 299
 
300 300
 		// Make sure the invoice has a subscription.
301
-		$subscription = getpaid_get_invoice_subscription( $invoice );
301
+		$subscription = getpaid_get_invoice_subscription($invoice);
302 302
 
303
-		if ( empty( $subscription ) ) {
304
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
303
+		if (empty($subscription)) {
304
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
305 305
 		}
306 306
 
307 307
 		// Validate the IPN.
308
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
309
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
310
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
308
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
309
+		$this->validate_ipn_receiver_email($invoice, $business_email);
310
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
311 311
 
312 312
 		// Activate the subscription.
313
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
314
-		$subscription->set_date_created( current_time( 'mysql' ) );
315
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
316
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
313
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
314
+		$subscription->set_date_created(current_time('mysql'));
315
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
316
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
317 317
 		$subscription->activate();
318 318
 
319 319
 		// Set the transaction id.
320
-		if ( ! empty( $posted['txn_id'] ) ) {
321
-			$invoice->set_transaction_id( $posted['txn_id'] );
320
+		if (!empty($posted['txn_id'])) {
321
+			$invoice->set_transaction_id($posted['txn_id']);
322 322
 		}
323 323
 
324 324
 		// Update the payment status.
325 325
 		$invoice->mark_paid();
326 326
 
327
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
327
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
328 328
 
329
-		wpinv_error_log( 'Subscription started.', false );
329
+		wpinv_error_log('Subscription started.', false);
330 330
 	}
331 331
 
332 332
 	/**
@@ -335,20 +335,20 @@  discard block
 block discarded – undo
335 335
 	 * @param WPInv_Invoice $invoice  Invoice object.
336 336
 	 * @param array    $posted Posted data.
337 337
 	 */
338
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
338
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
339 339
 
340 340
 		// Make sure the invoice has a subscription.
341
-		$subscription = wpinv_get_subscription( $invoice );
341
+		$subscription = wpinv_get_subscription($invoice);
342 342
 
343
-		if ( empty( $subscription ) ) {
344
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
343
+		if (empty($subscription)) {
344
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
345 345
 		}
346 346
 
347 347
 		// Abort if this is the first payment.
348
-		if ( ( $invoice->is_paid() && date( 'Ynd', strtotime( $invoice->get_date_completed() ) ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) || date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
348
+		if (($invoice->is_paid() && date('Ynd', strtotime($invoice->get_date_completed())) == date('Ynd', strtotime($posted['payment_date']))) || date('Ynd', $subscription->get_time_created()) == date('Ynd', strtotime($posted['payment_date']))) {
349 349
 
350
-			if ( ! empty( $posted['txn_id'] ) ) {
351
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
350
+			if (!empty($posted['txn_id'])) {
351
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));
352 352
 				$invoice->mark_paid();
353 353
 				$invoice->save();
354 354
 			}
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 			return;
357 357
 		}
358 358
 
359
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
359
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
360 360
 
361 361
 		// Abort if the payment is already recorded.
362
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
363
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
362
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
363
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
364 364
 		}
365 365
 
366 366
 		$args = array(
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
 			'gateway'        => $this->id,
369 369
 		);
370 370
 
371
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
371
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
372 372
 
373
-		if ( empty( $invoice ) ) {
373
+		if (empty($invoice)) {
374 374
 			return;
375 375
 		}
376 376
 
377
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
378
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
377
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
378
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
379 379
 
380 380
 		$subscription->renew();
381
-		wpinv_error_log( 'Subscription renewed.', false );
381
+		wpinv_error_log('Subscription renewed.', false);
382 382
 
383 383
 	}
384 384
 
@@ -387,18 +387,18 @@  discard block
 block discarded – undo
387 387
 	 *
388 388
 	 * @param WPInv_Invoice $invoice  Invoice object.
389 389
 	 */
390
-	protected function ipn_txn_subscr_cancel( $invoice ) {
390
+	protected function ipn_txn_subscr_cancel($invoice) {
391 391
 
392 392
 		// Make sure the invoice has a subscription.
393
-		$subscription = wpinv_get_subscription( $invoice );
393
+		$subscription = wpinv_get_subscription($invoice);
394 394
 
395
-		if ( empty( $subscription ) ) {
396
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
395
+		if (empty($subscription)) {
396
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
397 397
 		}
398 398
 
399
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
399
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
400 400
 		$subscription->cancel();
401
-		wpinv_error_log( 'Subscription cancelled.', false );
401
+		wpinv_error_log('Subscription cancelled.', false);
402 402
 
403 403
 	}
404 404
 
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 	 * @param WPInv_Invoice $invoice  Invoice object.
409 409
 	 * @param array    $posted Posted data.
410 410
 	 */
411
-	protected function ipn_txn_subscr_eot( $invoice ) {
411
+	protected function ipn_txn_subscr_eot($invoice) {
412 412
 
413 413
 		// Make sure the invoice has a subscription.
414
-		$subscription = wpinv_get_subscription( $invoice );
414
+		$subscription = wpinv_get_subscription($invoice);
415 415
 
416
-		if ( empty( $subscription ) ) {
417
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
416
+		if (empty($subscription)) {
417
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
418 418
 		}
419 419
 
420
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
420
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
421 421
 		$subscription->complete();
422
-		wpinv_error_log( 'Subscription completed.', false );
422
+		wpinv_error_log('Subscription completed.', false);
423 423
 
424 424
 	}
425 425
 
@@ -429,18 +429,18 @@  discard block
 block discarded – undo
429 429
 	 * @param WPInv_Invoice $invoice  Invoice object.
430 430
 	 * @param array    $posted Posted data.
431 431
 	 */
432
-	protected function ipn_txn_subscr_failed( $invoice ) {
432
+	protected function ipn_txn_subscr_failed($invoice) {
433 433
 
434 434
 		// Make sure the invoice has a subscription.
435
-		$subscription = wpinv_get_subscription( $invoice );
435
+		$subscription = wpinv_get_subscription($invoice);
436 436
 
437
-		if ( empty( $subscription ) ) {
438
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
437
+		if (empty($subscription)) {
438
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
439 439
 		}
440 440
 
441
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
441
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
442 442
 		$subscription->failing();
443
-		wpinv_error_log( 'Subscription marked as failing.', false );
443
+		wpinv_error_log('Subscription marked as failing.', false);
444 444
 
445 445
 	}
446 446
 
Please login to merge, or discard this patch.
templates/payment-forms/cart-totals.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@  discard block
 block discarded – undo
11 11
 
12 12
 // Totals rows.
13 13
 $totals = apply_filters(
14
-	'getpaid_payment_form_cart_table_totals',
15
-	array(
16
-		'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-		'tax'      => __( 'Tax', 'invoicing' ),
18
-		'fees'     => __( 'Fee', 'invoicing' ),
19
-		'discount' => __( 'Discount', 'invoicing' ),
20
-		'total'    => __( 'Total', 'invoicing' ),
21
-	),
22
-	$form
14
+    'getpaid_payment_form_cart_table_totals',
15
+    array(
16
+        'subtotal' => __( 'Subtotal', 'invoicing' ),
17
+        'tax'      => __( 'Tax', 'invoicing' ),
18
+        'fees'     => __( 'Fee', 'invoicing' ),
19
+        'discount' => __( 'Discount', 'invoicing' ),
20
+        'total'    => __( 'Total', 'invoicing' ),
21
+    ),
22
+    $form
23 23
 );
24 24
 
25 25
 $currency = $form->get_currency();
26 26
 $country  = wpinv_get_default_country();
27 27
 
28 28
 if ( ! empty( $form->invoice ) ) {
29
-	$country  = $form->invoice->get_country();
29
+    $country  = $form->invoice->get_country();
30 30
 }
31 31
 
32 32
 if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) {
33
-	unset( $totals['tax'] );
33
+    unset( $totals['tax'] );
34 34
 }
35 35
 
36 36
 do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals );
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 
62 62
 							<?php
63 63
 
64
-								// Total tax.
65
-								if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) {
66
-									echo wpinv_price( 0, $currency );
67
-								}
64
+                                // Total tax.
65
+                                if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) {
66
+                                    echo wpinv_price( 0, $currency );
67
+                                }
68 68
 
69
-								do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
-							?>
69
+                                do_action( "getpaid_payment_form_cart_totals_$key", $form );
70
+                            ?>
71 71
 
72 72
 						</div>
73 73
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Totals rows.
13 13
 $totals = apply_filters(
14 14
 	'getpaid_payment_form_cart_table_totals',
15 15
 	array(
16
-		'subtotal' => __( 'Subtotal', 'invoicing' ),
17
-		'tax'      => __( 'Tax', 'invoicing' ),
18
-		'fees'     => __( 'Fee', 'invoicing' ),
19
-		'discount' => __( 'Discount', 'invoicing' ),
20
-		'total'    => __( 'Total', 'invoicing' ),
16
+		'subtotal' => __('Subtotal', 'invoicing'),
17
+		'tax'      => __('Tax', 'invoicing'),
18
+		'fees'     => __('Fee', 'invoicing'),
19
+		'discount' => __('Discount', 'invoicing'),
20
+		'total'    => __('Total', 'invoicing'),
21 21
 	),
22 22
 	$form
23 23
 );
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 $currency = $form->get_currency();
26 26
 $country  = wpinv_get_default_country();
27 27
 
28
-if ( ! empty( $form->invoice ) ) {
29
-	$country  = $form->invoice->get_country();
28
+if (!empty($form->invoice)) {
29
+	$country = $form->invoice->get_country();
30 30
 }
31 31
 
32
-if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) {
33
-	unset( $totals['tax'] );
32
+if (!wpinv_use_taxes() && isset($totals['tax'])) {
33
+	unset($totals['tax']);
34 34
 }
35 35
 
36
-do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals );
36
+do_action('getpaid_before_payment_form_cart_totals', $form, $totals);
37 37
 
38 38
 ?>
39 39
 <style>
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
 	<div class="row">
48 48
 		<div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0">
49 49
 
50
-			<?php foreach ( $totals as $key => $label ) : ?>
50
+			<?php foreach ($totals as $key => $label) : ?>
51 51
 
52
-				<div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?> font-weight-bold py-2 px-3 <?php echo 'total' == $key ? 'bg-light' : 'border-bottom' ?>">
52
+				<div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?> font-weight-bold py-2 px-3 <?php echo 'total' == $key ? 'bg-light' : 'border-bottom' ?>">
53 53
 
54 54
 					<div class="form-row">
55 55
 
56 56
 						<div class="col-8 pl-sm-0 getpaid-payment-form-line-totals-label">
57
-							<?php echo sanitize_text_field( $label ); ?>
57
+							<?php echo sanitize_text_field($label); ?>
58 58
 						</div>
59 59
 
60
-						<div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>">
60
+						<div class="col-4 getpaid-payment-form-line-totals-value getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>">
61 61
 
62 62
 							<?php
63 63
 
64 64
 								// Total tax.
65
-								if ( in_array( $key, array( 'tax', 'discount', 'subtotal', 'total', 'fees' ) ) ) {
66
-									echo wpinv_price( 0, $currency );
65
+								if (in_array($key, array('tax', 'discount', 'subtotal', 'total', 'fees'))) {
66
+									echo wpinv_price(0, $currency);
67 67
 								}
68 68
 
69
-								do_action( "getpaid_payment_form_cart_totals_$key", $form );
69
+								do_action("getpaid_payment_form_cart_totals_$key", $form);
70 70
 							?>
71 71
 
72 72
 						</div>
@@ -82,4 +82,4 @@  discard block
 block discarded – undo
82 82
 </div>
83 83
 
84 84
 <?php
85
-do_action(  'getpaid_payment_form_cart_totals', $form, $totals );
85
+do_action('getpaid_payment_form_cart_totals', $form, $totals);
Please login to merge, or discard this patch.
templates/payment-forms/cart.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Cart table columns.
13 13
 $columns = array(
14
-    'name'     => __( 'Item', 'invoicing' ),
15
-    'price'    => __( 'Price', 'invoicing' ),
16
-    'quantity' => __( 'Quantity', 'invoicing' ),
17
-    'subtotal' => __( 'Subtotal', 'invoicing' ),
14
+    'name'     => __('Item', 'invoicing'),
15
+    'price'    => __('Price', 'invoicing'),
16
+    'quantity' => __('Quantity', 'invoicing'),
17
+    'subtotal' => __('Subtotal', 'invoicing'),
18 18
 );
19 19
 
20
-if ( ! empty( $form->invoice ) ) {
21
-    $columns = getpaid_invoice_item_columns( $form->invoice );
20
+if (!empty($form->invoice)) {
21
+    $columns = getpaid_invoice_item_columns($form->invoice);
22 22
 }
23 23
 
24
-$columns = apply_filters( 'getpaid_payment_form_cart_table_columns', $columns, $form );
24
+$columns = apply_filters('getpaid_payment_form_cart_table_columns', $columns, $form);
25 25
 
26
-do_action( 'getpaid_before_payment_form_cart', $form );
26
+do_action('getpaid_before_payment_form_cart', $form);
27 27
 
28 28
 ?>
29 29
     <div class="getpaid-payment-form-items-cart border form-group">
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
         <div class="getpaid-payment-form-items-cart-header font-weight-bold bg-light border-bottom py-2 px-3">
33 33
             <div class="form-row">
34
-                <?php foreach ( $columns as $key => $label ) : ?>
35
-                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>">
36
-                        <?php echo sanitize_text_field( $label ); ?>
34
+                <?php foreach ($columns as $key => $label) : ?>
35
+                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>">
36
+                        <?php echo sanitize_text_field($label); ?>
37 37
                     </div>
38 38
                 <?php endforeach; ?>
39 39
             </div>
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
         <?php
43 43
 
44 44
             // Display the item totals.
45
-            foreach ( $form->get_items() as $item ) {
46
-                wpinv_get_template( 'payment-forms/cart-item.php', compact( 'form', 'item', 'columns' ) );
45
+            foreach ($form->get_items() as $item) {
46
+                wpinv_get_template('payment-forms/cart-item.php', compact('form', 'item', 'columns'));
47 47
             }
48 48
 
49 49
             // Display the cart totals.
50
-            wpinv_get_template( 'payment-forms/cart-totals.php', compact( 'form' ) );
50
+            wpinv_get_template('payment-forms/cart-totals.php', compact('form'));
51 51
 
52 52
         ?>
53 53
     </div>
54 54
 
55 55
 <?php 
56 56
 
57
-do_action( 'getpaid_after_payment_form_cart', $form );
57
+do_action('getpaid_after_payment_form_cart', $form);
Please login to merge, or discard this patch.
templates/invoice/line-totals.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@  discard block
 block discarded – undo
9 9
  * @var WPInv_Invoice $invoice
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 // Totals rows.
15
-$totals = getpaid_invoice_totals_rows( $invoice );
15
+$totals = getpaid_invoice_totals_rows($invoice);
16 16
 
17
-do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals );
17
+do_action('getpaid_before_invoice_line_totals', $invoice, $totals);
18 18
 
19 19
 ?>
20 20
 <div class='getpaid-invoice-line-totals'>
21 21
     <div class="row">
22 22
         <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0">
23 23
 
24
-            <?php foreach ( $totals as $key => $label ) : ?>
24
+            <?php foreach ($totals as $key => $label) : ?>
25 25
 
26
-                <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>">
26
+                <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>">
27 27
 
28 28
                     <div class="form-row">
29 29
 
30 30
                         <div class="col-8 getpaid-invoice-line-totals-label">
31
-                            <?php echo sanitize_text_field( $label ); ?>
31
+                            <?php echo sanitize_text_field($label); ?>
32 32
                         </div>
33 33
 
34 34
                         <div class="col-4 getpaid-invoice-line-totals-value pl-0">
@@ -36,32 +36,32 @@  discard block
 block discarded – undo
36 36
                             <?php
37 37
 
38 38
                                 // Total tax.
39
-                                if ( 'tax' == $key ) {
40
-                                    echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );
39
+                                if ('tax' == $key) {
40
+                                    echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency());
41 41
                                 }
42 42
 
43 43
                                 // Total Fee.
44
-                                if ( 'fee' == $key ) {
45
-                                    echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() );
44
+                                if ('fee' == $key) {
45
+                                    echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency());
46 46
                                 }
47 47
 
48 48
                                 // Total discount.
49
-                                if ( 'discount' == $key ) {
50
-                                    echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );
49
+                                if ('discount' == $key) {
50
+                                    echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency());
51 51
                                 }
52 52
 
53 53
                                 // Sub total.
54
-                                if ( 'subtotal' == $key ) {
55
-                                    echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );
54
+                                if ('subtotal' == $key) {
55
+                                    echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency());
56 56
                                 }
57 57
 
58 58
                                 // Total.
59
-                                if ( 'total' == $key ) {
60
-                                    echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
59
+                                if ('total' == $key) {
60
+                                    echo wpinv_price($invoice->get_total(), $invoice->get_currency());
61 61
                                 }
62 62
  
63 63
                                 // Fires when printing a cart total.
64
-                                do_action( "getpaid_invoice_cart_totals_$key", $invoice );
64
+                                do_action("getpaid_invoice_cart_totals_$key", $invoice);
65 65
 
66 66
                             ?>
67 67
 
@@ -75,4 +75,4 @@  discard block
 block discarded – undo
75 75
     </div>
76 76
 </div> <!-- end .getpaid-invoice-line-totals -->
77 77
 
78
-<?php do_action(  'getpaid_after_invoice_line_totals', $invoice, $totals ); ?>
78
+<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?>
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@
 block discarded – undo
37 37
     public function get_privacy_message() {
38 38
 
39 39
         $content = '<div class="wp-suggested-text">' .
40
-                   '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
41
-                   '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
42
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
43
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
44
-                   '<ul>' .
45
-                   '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
46
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
47
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
48
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
49
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
50
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
51
-                   '</ul>' .
52
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
53
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
54
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
55
-                   '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
56
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
57
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
58
-                   '</div>';
40
+                    '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
41
+                    '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
42
+                    '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
43
+                    '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
44
+                    '<ul>' .
45
+                    '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
46
+                    '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
47
+                    '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
48
+                    '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
49
+                    '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
50
+                    '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
51
+                    '</ul>' .
52
+                    '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
53
+                    '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
54
+                    '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
55
+                    '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
56
+                    '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
57
+                    '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
58
+                    '</div>';
59 59
 
60 60
         return apply_filters( 'wpinv_privacy_policy_content', $content );
61 61
     }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Privacy/GDPR related functionality which ties into WordPress functionality.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy Class.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $this->init();
27 27
 
28 28
         // This hook registers Invoicing data exporters.
29
-        $this->add_exporter( 'wpinv-customer-invoices', __( 'Customer Invoices', 'invoicing' ), array( 'WPInv_Privacy_Exporters', 'customer_invoice_data_exporter' ) );
29
+        $this->add_exporter('wpinv-customer-invoices', __('Customer Invoices', 'invoicing'), array('WPInv_Privacy_Exporters', 'customer_invoice_data_exporter'));
30 30
     }
31 31
 
32 32
     /**
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
     public function get_privacy_message() {
38 38
 
39 39
         $content = '<div class="wp-suggested-text">' .
40
-                   '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
41
-                   '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
42
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
43
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
40
+                   '<h2>' . __('Invoices and checkout', 'invoicing') . '</h2>' .
41
+                   '<p class="privacy-policy-tutorial">' . __('Example privacy texts.', 'invoicing') . '</p>' .
42
+                   '<p>' . __('We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing') . '</p>' .
43
+                   '<p>' . __('Handling this data also allows us to:', 'invoicing') . '</p>' .
44 44
                    '<ul>' .
45
-                   '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
46
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
47
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
48
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
49
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
50
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
45
+                   '<li>' . __('- Send you important account/invoice/service information.', 'invoicing') . '</li>' .
46
+                   '<li>' . __('- Estimate taxes based on your location.', 'invoicing') . '</li>' .
47
+                   '<li>' . __('- Respond to your queries or complaints.', 'invoicing') . '</li>' .
48
+                   '<li>' . __('- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
49
+                   '<li>' . __('- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing') . '</li>' .
50
+                   '<li>' . __('- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
51 51
                    '</ul>' .
52
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
53
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
54
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
55
-                   '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
56
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
57
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
52
+                   '<p>' . __('In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing') . '</p>' .
53
+                   '<h2>' . __('What we share with others', 'invoicing') . '</h2>' .
54
+                   '<p>' . __('We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing') . '</p>' .
55
+                   '<p class="privacy-policy-tutorial">' . __('In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing') . '</p>' .
56
+                   '<p>' . __('We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing') . '</p>' .
57
+                   '<p>' . __('Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing') . '</p>' .
58 58
                    '</div>';
59 59
 
60
-        return apply_filters( 'wpinv_privacy_policy_content', $content );
60
+        return apply_filters('wpinv_privacy_policy_content', $content);
61 61
     }
62 62
 
63 63
 }
Please login to merge, or discard this patch.
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,39 +17,39 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
34
-            'limit'    => get_option( 'posts_per_page' ),
33
+        $args = array(
34
+            'limit'    => get_option('posts_per_page'),
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
             'paginate' => false,
38 38
         );
39 39
 
40
-        $invoices = wpinv_get_invoices( $args );
40
+        $invoices = wpinv_get_invoices($args);
41 41
 
42
-        if ( 0 < count( $invoices ) ) {
43
-            foreach ( $invoices as $invoice ) {
42
+        if (0 < count($invoices)) {
43
+            foreach ($invoices as $invoice) {
44 44
                 $data_to_export[] = array(
45 45
                     'group_id'          => 'customer_invoices',
46
-                    'group_label'       => __( 'GetPaid: Invoices', 'invoicing' ),
47
-                    'group_description' => __( 'Customer invoices.', 'invoicing' ),
46
+                    'group_label'       => __('GetPaid: Invoices', 'invoicing'),
47
+                    'group_description' => __('Customer invoices.', 'invoicing'),
48 48
                     'item_id'           => "wpinv-{$invoice->get_id()}",
49
-                    'data'              => self::get_customer_invoice_data( $invoice ),
49
+                    'data'              => self::get_customer_invoice_data($invoice),
50 50
                 );
51 51
             }
52
-            $done = get_option( 'posts_per_page' ) > count( $invoices );
52
+            $done = get_option('posts_per_page') > count($invoices);
53 53
         } else {
54 54
             $done = true;
55 55
         }
@@ -67,116 +67,116 @@  discard block
 block discarded – undo
67 67
      * @param WPInv_Invoice $invoice invoice object.
68 68
      * @return array
69 69
      */
70
-    public static function get_customer_invoice_data( $invoice ) {
70
+    public static function get_customer_invoice_data($invoice) {
71 71
 
72 72
         // Prepare basic properties.
73 73
         $props_to_export = array(
74 74
             'number'               => array(
75
-                'name' => __( 'Invoice Number', 'invoicing' ),
75
+                'name' => __('Invoice Number', 'invoicing'),
76 76
                 'value' => $invoice->get_number(),
77 77
             ),
78 78
             'created_date'         => array(
79
-                'name' => __( 'Created Date', 'invoicing' ),
79
+                'name' => __('Created Date', 'invoicing'),
80 80
                 'value' => $invoice->get_date_created(),
81 81
             ),
82 82
             'due_date'         => array(
83
-                'name' => __( 'Due Date', 'invoicing' ),
83
+                'name' => __('Due Date', 'invoicing'),
84 84
                 'value' => $invoice->get_due_date(),
85 85
             ),
86 86
             'items'                => array(
87
-                'name' => __( 'Invoice Items', 'invoicing' ),
88
-                'value' => self::process_invoice_items( $invoice ),
87
+                'name' => __('Invoice Items', 'invoicing'),
88
+                'value' => self::process_invoice_items($invoice),
89 89
             ),
90 90
             'discount'                => array(
91
-                'name' => __( 'Invoice Discount', 'invoicing' ),
92
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
91
+                'name' => __('Invoice Discount', 'invoicing'),
92
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
93 93
             ),
94 94
             'total'                => array(
95
-                'name' => __( 'Invoice Total', 'invoicing' ),
96
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
95
+                'name' => __('Invoice Total', 'invoicing'),
96
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
97 97
             ),
98 98
             'status'               => array(
99
-                'name' => __( 'Invoice Status', 'invoicing' ),
99
+                'name' => __('Invoice Status', 'invoicing'),
100 100
                 'value' => $invoice->get_status_nicename(),
101 101
             ),
102 102
             'first_name'           => array(
103
-                'name' => __( 'First Name', 'invoicing' ),
103
+                'name' => __('First Name', 'invoicing'),
104 104
                 'value' => $invoice->get_first_name(),
105 105
             ),
106 106
             'last_name'           => array(
107
-                'name' => __( 'Last Name', 'invoicing' ),
107
+                'name' => __('Last Name', 'invoicing'),
108 108
                 'value' => $invoice->get_last_name(),
109 109
             ),
110 110
             'email'           => array(
111
-                'name' => __( 'Email Address', 'invoicing' ),
111
+                'name' => __('Email Address', 'invoicing'),
112 112
                 'value' => $invoice->get_email(),
113 113
             ),
114 114
             'company'           => array(
115
-                'name' => __( 'Company', 'invoicing' ),
115
+                'name' => __('Company', 'invoicing'),
116 116
                 'value' => $invoice->get_company(),
117 117
             ),
118 118
             'phone'           => array(
119
-                'name' => __( 'Phone Number', 'invoicing' ),
119
+                'name' => __('Phone Number', 'invoicing'),
120 120
                 'value' => $invoice->get_phone(),
121 121
             ),
122 122
             'address'           => array(
123
-                'name' => __( 'Address', 'invoicing' ),
123
+                'name' => __('Address', 'invoicing'),
124 124
                 'value' => $invoice->get_address(),
125 125
             ),
126 126
             'city'           => array(
127
-                'name' => __( 'City', 'invoicing' ),
127
+                'name' => __('City', 'invoicing'),
128 128
                 'value' => $invoice->get_city(),
129 129
             ),
130 130
             'state'           => array(
131
-                'name' => __( 'State', 'invoicing' ),
131
+                'name' => __('State', 'invoicing'),
132 132
                 'value' => $invoice->get_state(),
133 133
             ),
134 134
             'zip'           => array(
135
-                'name' => __( 'Zip', 'invoicing' ),
135
+                'name' => __('Zip', 'invoicing'),
136 136
                 'value' => $invoice->get_zip(),
137 137
             ),
138 138
             'vat_number'    => array(
139
-                'name' => __( 'VAT Number', 'invoicing' ),
139
+                'name' => __('VAT Number', 'invoicing'),
140 140
                 'value' => $invoice->get_vat_number(),
141 141
             ),
142 142
             'description'   => array(
143
-                'name' => __( 'Description', 'invoicing' ),
143
+                'name' => __('Description', 'invoicing'),
144 144
                 'value' => $invoice->get_description(),
145 145
             ), 
146 146
         );
147 147
 
148 148
         // In case the invoice is paid, add the payment date and gateway.
149
-        if ( $invoice->is_paid() ) {
149
+        if ($invoice->is_paid()) {
150 150
 
151 151
             $props_to_export['completed_date'] = array(
152
-                'name' => __( 'Completed Date', 'invoicing' ),
152
+                'name' => __('Completed Date', 'invoicing'),
153 153
                 'value' => $invoice->get_completed_date(),
154 154
             );
155 155
 
156 156
             $props_to_export['gateway'] = array(
157
-                'name' => __( 'Paid Via', 'invoicing' ),
157
+                'name' => __('Paid Via', 'invoicing'),
158 158
                 'value' => $invoice->get_gateway(),
159 159
             );
160 160
 
161 161
         }
162 162
 
163 163
         // Maybe add subscription details.
164
-        $props_to_export = self::process_subscription( $invoice, $props_to_export );
164
+        $props_to_export = self::process_subscription($invoice, $props_to_export);
165 165
 
166 166
         // Add the ip address.
167 167
         $props_to_export['ip'] = array(
168
-            'name' => __( 'IP Address', 'invoicing' ),
168
+            'name' => __('IP Address', 'invoicing'),
169 169
             'value' => $invoice->get_ip(),
170 170
         );
171 171
 
172 172
         // Add the invoice url.
173 173
         $props_to_export['view_url'] = array(
174
-            'name' => __( 'Invoice URL', 'invoicing' ),
174
+            'name' => __('Invoice URL', 'invoicing'),
175 175
             'value' => $invoice->get_view_url(),
176 176
         );
177 177
 
178 178
         // Return the values.
179
-        return apply_filters( 'getpaid_privacy_export_invoice_personal_data', array_values( $props_to_export ), $invoice );
179
+        return apply_filters('getpaid_privacy_export_invoice_personal_data', array_values($props_to_export), $invoice);
180 180
 
181 181
     }
182 182
 
@@ -188,40 +188,40 @@  discard block
 block discarded – undo
188 188
      * @param array $props invoice props.
189 189
      * @return array
190 190
      */
191
-    public static function process_subscription( $invoice, $props ) {
191
+    public static function process_subscription($invoice, $props) {
192 192
 
193
-        $subscription = wpinv_get_subscription( $invoice );
194
-        if ( ! empty( $subscription ) ) {
193
+        $subscription = wpinv_get_subscription($invoice);
194
+        if (!empty($subscription)) {
195 195
 
196
-            $frequency    = getpaid_get_subscription_period_label( $subscription->get_period(),$subscription->get_frequency() );
197
-            $period       = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency;
198
-            $initial_amt  = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
199
-            $bill_times   = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() );
200
-            $renewal_date = getpaid_format_date_value( $subscription->get_expiration() );
196
+            $frequency    = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency());
197
+            $period       = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency;
198
+            $initial_amt  = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
199
+            $bill_times   = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times());
200
+            $renewal_date = getpaid_format_date_value($subscription->get_expiration());
201 201
 
202 202
             // Billing cycle.
203 203
             $props['period'] = array(
204
-                'name' => __( 'Billing Cycle', 'invoicing' ),
204
+                'name' => __('Billing Cycle', 'invoicing'),
205 205
                 'value' => $period,
206 206
             );
207 207
 
208 208
             // Initial amount.
209 209
             $props['initial_amount'] = array(
210
-                'name' => __( 'Initial Amount', 'invoicing' ),
210
+                'name' => __('Initial Amount', 'invoicing'),
211 211
                 'value' => $initial_amt,
212 212
             );
213 213
 
214 214
             // Bill times.
215 215
             $props['bill_times'] = array(
216
-                'name' => __( 'Times Billed', 'invoicing' ),
216
+                'name' => __('Times Billed', 'invoicing'),
217 217
                 'value' => $bill_times,
218 218
             );
219 219
 
220 220
             // Add expiry date.
221
-            if ( $subscription->is_active() ) {
221
+            if ($subscription->is_active()) {
222 222
 
223 223
                 $props['renewal_date'] = array(
224
-                    'name' => __( 'Expires', 'invoicing' ),
224
+                    'name' => __('Expires', 'invoicing'),
225 225
                     'value' => $renewal_date,
226 226
                 );
227 227
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
      * @param WPInv_Invoice $invoice invoice object.
241 241
      * @return array
242 242
      */
243
-    public static function process_invoice_items( $invoice ) {
243
+    public static function process_invoice_items($invoice) {
244 244
 
245 245
         $item_names = array();
246
-        foreach ( $invoice->get_items() as $cart_item ) {
246
+        foreach ($invoice->get_items() as $cart_item) {
247 247
             $item_names[] = sprintf(
248 248
                 '%s x %s - %s',
249 249
                 $cart_item->get_name(),
250 250
                 $cart_item->get_quantity(),
251
-                wpinv_price( $invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency() )
251
+                wpinv_price($invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency())
252 252
             );
253 253
         }
254 254
 
255
-        return implode( ', ', $item_names );
255
+        return implode(', ', $item_names);
256 256
 
257 257
     }
258 258
 
Please login to merge, or discard this patch.
templates/wpinv-invalid-access.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Fetch the invoice.
13
-if ( empty( $invoice ) ) {
14
-    $invoice = new WPInv_Invoice( $GLOBALS['post'] );
13
+if (empty($invoice)) {
14
+    $invoice = new WPInv_Invoice($GLOBALS['post']);
15 15
 }
16 16
 
17 17
 ?><!DOCTYPE html>
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
 
22 22
     <head>
23 23
 
24
-		<meta charset="<?php bloginfo( 'charset' ); ?>">
24
+		<meta charset="<?php bloginfo('charset'); ?>">
25 25
         <meta name="viewport" content="width=device-width, initial-scale=1.0" >
26 26
 
27 27
         <meta name="robots" content="noindex,nofollow">
28 28
 
29 29
 		<link rel="profile" href="https://gmpg.org/xfn/11">
30 30
 
31
-        <title><?php _e( 'Invalid Access', 'invoicing' ); ?></title>
31
+        <title><?php _e('Invalid Access', 'invoicing'); ?></title>
32 32
 
33
-        <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
33
+        <?php do_action('wpinv_invoice_print_head', $invoice); ?>
34 34
 
35 35
     </head>
36 36
 
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
 
40 40
         <?php
41 41
 
42
-            if ( ! $invoice->exists() || $invoice->is_draft() ) {
43
-                $error = __( 'This invoice was deleted or is not visible.', 'invoicing' );
42
+            if (!$invoice->exists() || $invoice->is_draft()) {
43
+                $error = __('This invoice was deleted or is not visible.', 'invoicing');
44 44
             } else {
45 45
 
46 46
                 $user_id = get_current_user_id();
47
-                if ( wpinv_require_login_to_checkout() && empty( $user_id ) ) {
48
-                    $error  = __( 'You must be logged in to view this invoice.', 'invoicing' );
47
+                if (wpinv_require_login_to_checkout() && empty($user_id)) {
48
+                    $error  = __('You must be logged in to view this invoice.', 'invoicing');
49 49
                     $error .= sprintf(
50 50
                         ' <a href="%s">%s</a>',
51
-                        wp_login_url( $invoice->get_view_url() ),
52
-                        __( 'Login.', 'invoicing' )
51
+                        wp_login_url($invoice->get_view_url()),
52
+                        __('Login.', 'invoicing')
53 53
                     );
54 54
                 } else {
55
-                    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
55
+                    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
56 56
                 }
57 57
 
58 58
             }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
         <div class="container">
63 63
             <div class="alert alert-danger m-5" role="alert">
64
-                <h4 class="alert-heading"><?php _e( 'Access Denied', 'invoicing' ); ?></h4>
64
+                <h4 class="alert-heading"><?php _e('Access Denied', 'invoicing'); ?></h4>
65 65
                 <p><?php echo $error; ?></p>
66 66
             </div>
67 67
         </div>
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-fees.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,109 +12,109 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Fees {
14 14
 
15
-	/**
16
-	 * The fee validation error.
17
-	 * @var string
18
-	 */
19
-	public $fee_error;
20
-
21
-	/**
22
-	 * Submission fees.
23
-	 * @var array
24
-	 */
25
-	public $fees = array();
15
+    /**
16
+     * The fee validation error.
17
+     * @var string
18
+     */
19
+    public $fee_error;
20
+
21
+    /**
22
+     * Submission fees.
23
+     * @var array
24
+     */
25
+    public $fees = array();
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+
34
+        // Process any existing invoice fees.
35
+        if ( $submission->has_invoice() ) {
36
+            $this->fees = $submission->get_invoice()->get_fees();
37
+        }
38
+
39
+        // Process price fields.
40
+        $data         = $submission->get_data();
41
+        $payment_form = $submission->get_payment_form();
42
+
43
+        foreach ( $payment_form->get_elements() as $element ) {
44
+
45
+            if ( 'price_input' == $element['type'] ) {
46
+                $this->process_price_input( $element, $data, $submission );
47
+            }
48
+
49
+            if ( 'price_select' == $element['type'] ) {
50
+                $this->process_price_select( $element, $data );
51
+            }
52
+
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Process a price input field.
59
+     *
60
+     * @param array $element
61
+     * @param array $data
62
+     * @param GetPaid_Payment_Form_Submission $submission
63
+     */
64
+    public function process_price_input( $element, $data, $submission ) {
65
+
66
+        // Abort if not passed.
67
+        if ( empty( $data[ $element['id'] ] ) ) {
68
+            return;
69
+        }
70
+
71
+        $amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
+        $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
+
74
+        if ( $amount < $minimum ) {
75
+            throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) );
76
+        }
77
+
78
+        $this->fees[ $element['label'] ] = array(
79
+            'name'          => $element['label'],
80
+            'initial_fee'   => $amount,
81
+            'recurring_fee' => 0,
82
+        );
83
+
84
+    }
26 85
 
27 86
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-
34
-		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
36
-			$this->fees = $submission->get_invoice()->get_fees();
37
-		}
38
-
39
-		// Process price fields.
40
-		$data         = $submission->get_data();
41
-		$payment_form = $submission->get_payment_form();
42
-
43
-		foreach ( $payment_form->get_elements() as $element ) {
44
-
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data, $submission );
47
-			}
48
-
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
51
-			}
52
-
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Process a price input field.
59
-	 *
60
-	 * @param array $element
61
-	 * @param array $data
62
-	 * @param GetPaid_Payment_Form_Submission $submission
63
-	 */
64
-	public function process_price_input( $element, $data, $submission ) {
65
-
66
-		// Abort if not passed.
67
-		if ( empty( $data[ $element['id'] ] ) ) {
68
-			return;
69
-		}
70
-
71
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
-
74
-		if ( $amount < $minimum ) {
75
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) );
76
-		}
77
-
78
-		$this->fees[ $element['label'] ] = array(
79
-			'name'          => $element['label'],
80
-			'initial_fee'   => $amount,
81
-			'recurring_fee' => 0,
82
-		);
83
-
84
-	}
85
-
86
-	/**
87
-	 * Process a price select field.
88
-	 *
89
-	 * @param array $element
90
-	 * @param array $data
91
-	 */
92
-	public function process_price_select( $element, $data ) {
93
-
94
-		// Abort if not passed.
95
-		if ( empty( $data[ $element['id'] ] ) ) {
96
-			return;
97
-		}
98
-
99
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
100
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
101
-		$total    = 0;
102
-
103
-		foreach ( $selected as $price ) {
104
-
105
-			if ( ! isset( $options[ $price ] ) ) {
106
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
107
-			}
108
-
109
-			$total += (float) wpinv_sanitize_amount( $price );
110
-		}
111
-
112
-		$this->fees[ $element['label'] ] = array(
113
-			'name'          => $element['label'],
114
-			'initial_fee'   => $total,
115
-			'recurring_fee' => 0,
116
-		);
117
-
118
-	}
87
+     * Process a price select field.
88
+     *
89
+     * @param array $element
90
+     * @param array $data
91
+     */
92
+    public function process_price_select( $element, $data ) {
93
+
94
+        // Abort if not passed.
95
+        if ( empty( $data[ $element['id'] ] ) ) {
96
+            return;
97
+        }
98
+
99
+        $options  = getpaid_convert_price_string_to_options( $element['options'] );
100
+        $selected = wpinv_parse_list( $data[ $element['id'] ] );
101
+        $total    = 0;
102
+
103
+        foreach ( $selected as $price ) {
104
+
105
+            if ( ! isset( $options[ $price ] ) ) {
106
+                throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
107
+            }
108
+
109
+            $total += (float) wpinv_sanitize_amount( $price );
110
+        }
111
+
112
+        $this->fees[ $element['label'] ] = array(
113
+            'name'          => $element['label'],
114
+            'initial_fee'   => $total,
115
+            'recurring_fee' => 0,
116
+        );
117
+
118
+    }
119 119
 
120 120
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 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 fees class
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 
34 34
 		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
35
+		if ($submission->has_invoice()) {
36 36
 			$this->fees = $submission->get_invoice()->get_fees();
37 37
 		}
38 38
 
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		$data         = $submission->get_data();
41 41
 		$payment_form = $submission->get_payment_form();
42 42
 
43
-		foreach ( $payment_form->get_elements() as $element ) {
43
+		foreach ($payment_form->get_elements() as $element) {
44 44
 
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data, $submission );
45
+			if ('price_input' == $element['type']) {
46
+				$this->process_price_input($element, $data, $submission);
47 47
 			}
48 48
 
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
49
+			if ('price_select' == $element['type']) {
50
+				$this->process_price_select($element, $data);
51 51
 			}
52 52
 
53 53
 		}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 	 * @param array $data
62 62
 	 * @param GetPaid_Payment_Form_Submission $submission
63 63
 	 */
64
-	public function process_price_input( $element, $data, $submission ) {
64
+	public function process_price_input($element, $data, $submission) {
65 65
 
66 66
 		// Abort if not passed.
67
-		if ( empty( $data[ $element['id'] ] ) ) {
67
+		if (empty($data[$element['id']])) {
68 68
 			return;
69 69
 		}
70 70
 
71
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
71
+		$amount  = (float) wpinv_sanitize_amount($data[$element['id']]);
72
+		$minimum = empty($element['minimum']) ? 0 : (float) wpinv_sanitize_amount($element['minimum']);
73 73
 
74
-		if ( $amount < $minimum ) {
75
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_price( $minimum, $submission->get_currency() ) ) );
74
+		if ($amount < $minimum) {
75
+			throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_price($minimum, $submission->get_currency())));
76 76
 		}
77 77
 
78
-		$this->fees[ $element['label'] ] = array(
78
+		$this->fees[$element['label']] = array(
79 79
 			'name'          => $element['label'],
80 80
 			'initial_fee'   => $amount,
81 81
 			'recurring_fee' => 0,
@@ -89,27 +89,27 @@  discard block
 block discarded – undo
89 89
 	 * @param array $element
90 90
 	 * @param array $data
91 91
 	 */
92
-	public function process_price_select( $element, $data ) {
92
+	public function process_price_select($element, $data) {
93 93
 
94 94
 		// Abort if not passed.
95
-		if ( empty( $data[ $element['id'] ] ) ) {
95
+		if (empty($data[$element['id']])) {
96 96
 			return;
97 97
 		}
98 98
 
99
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
100
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
99
+		$options  = getpaid_convert_price_string_to_options($element['options']);
100
+		$selected = wpinv_parse_list($data[$element['id']]);
101 101
 		$total    = 0;
102 102
 
103
-		foreach ( $selected as $price ) {
103
+		foreach ($selected as $price) {
104 104
 
105
-			if ( ! isset( $options[ $price ] ) ) {
106
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
105
+			if (!isset($options[$price])) {
106
+				throw new Exception(__('You have selected an invalid amount', 'invoicing'));
107 107
 			}
108 108
 
109
-			$total += (float) wpinv_sanitize_amount( $price );
109
+			$total += (float) wpinv_sanitize_amount($price);
110 110
 		}
111 111
 
112
-		$this->fees[ $element['label'] ] = array(
112
+		$this->fees[$element['label']] = array(
113 113
 			'name'          => $element['label'],
114 114
 			'initial_fee'   => $total,
115 115
 			'recurring_fee' => 0,
Please login to merge, or discard this patch.