Passed
Push — master ( c6d0db...756836 )
by Brian
04:55 queued 28s
created
includes/gateways/class-getpaid-payment-gateway.php 2 patches
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -13,450 +13,450 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class GetPaid_Payment_Gateway {
15 15
 
16
-	/**
17
-	 * Set if the place checkout button should be renamed on selection.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public $checkout_button_text;
22
-
23
-	/**
24
-	 * Boolean whether the method is enabled.
25
-	 *
26
-	 * @var bool
27
-	 */
28
-	public $enabled = true;
29
-
30
-	/**
31
-	 * Payment method id.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	public $id;
36
-
37
-	/**
38
-	 * Payment method order.
39
-	 *
40
-	 * @var int
41
-	 */
42
-	public $order = 10;
43
-
44
-	/**
45
-	 * Payment method title for the frontend.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	public $title;
50
-
51
-	/**
52
-	 * Payment method description for the frontend.
53
-	 *
54
-	 * @var string
55
-	 */
56
-	public $description;
57
-
58
-	/**
59
-	 * Gateway title.
60
-	 *
61
-	 * @var string
62
-	 */
63
-	public $method_title = '';
64
-
65
-	/**
66
-	 * Gateway description.
67
-	 *
68
-	 * @var string
69
-	 */
70
-	public $method_description = '';
71
-
72
-	/**
73
-	 * Countries this gateway is allowed for.
74
-	 *
75
-	 * @var array
76
-	 */
77
-	public $countries;
78
-
79
-	/**
80
-	 * Currencies this gateway is allowed for.
81
-	 *
82
-	 * @var array
83
-	 */
84
-	public $currencies;
85
-
86
-	/**
87
-	 * Currencies this gateway is not allowed for.
88
-	 *
89
-	 * @var array
90
-	 */
91
-	public $exclude_currencies;
92
-
93
-	/**
94
-	 * Maximum transaction amount, zero does not define a maximum.
95
-	 *
96
-	 * @var int
97
-	 */
98
-	public $max_amount = 0;
99
-
100
-	/**
101
-	 * Optional URL to view a transaction.
102
-	 *
103
-	 * @var string
104
-	 */
105
-	public $view_transaction_url = '';
106
-
107
-	/**
108
-	 * Optional URL to view a subscription.
109
-	 *
110
-	 * @var string
111
-	 */
112
-	public $view_subscription_url = '';
113
-
114
-	/**
115
-	 * Optional label to show for "new payment method" in the payment
116
-	 * method/token selection radio selection.
117
-	 *
118
-	 * @var string
119
-	 */
120
-	public $new_method_label = '';
121
-
122
-	/**
123
-	 * Contains a user's saved tokens for this gateway.
124
-	 *
125
-	 * @var array
126
-	 */
127
-	protected $tokens = array();
128
-
129
-	/**
130
-	 * An array of features that this gateway supports.
131
-	 *
132
-	 * @var array
133
-	 */
134
-	protected $supports = array();
135
-
136
-	/**
137
-	 * Class constructor.
138
-	 */
139
-	public function __construct() {
140
-
141
-		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
-
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
145
-
146
-		// Enable Subscriptions.
147
-		if ( $this->supports( 'subscription' ) ) {
148
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
149
-		}
150
-
151
-		// Enable sandbox.
152
-		if ( $this->supports( 'sandbox' ) ) {
153
-			add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
154
-		}
155
-
156
-		// Gateway settings.
157
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
16
+    /**
17
+     * Set if the place checkout button should be renamed on selection.
18
+     *
19
+     * @var string
20
+     */
21
+    public $checkout_button_text;
22
+
23
+    /**
24
+     * Boolean whether the method is enabled.
25
+     *
26
+     * @var bool
27
+     */
28
+    public $enabled = true;
29
+
30
+    /**
31
+     * Payment method id.
32
+     *
33
+     * @var string
34
+     */
35
+    public $id;
36
+
37
+    /**
38
+     * Payment method order.
39
+     *
40
+     * @var int
41
+     */
42
+    public $order = 10;
43
+
44
+    /**
45
+     * Payment method title for the frontend.
46
+     *
47
+     * @var string
48
+     */
49
+    public $title;
50
+
51
+    /**
52
+     * Payment method description for the frontend.
53
+     *
54
+     * @var string
55
+     */
56
+    public $description;
57
+
58
+    /**
59
+     * Gateway title.
60
+     *
61
+     * @var string
62
+     */
63
+    public $method_title = '';
64
+
65
+    /**
66
+     * Gateway description.
67
+     *
68
+     * @var string
69
+     */
70
+    public $method_description = '';
71
+
72
+    /**
73
+     * Countries this gateway is allowed for.
74
+     *
75
+     * @var array
76
+     */
77
+    public $countries;
78
+
79
+    /**
80
+     * Currencies this gateway is allowed for.
81
+     *
82
+     * @var array
83
+     */
84
+    public $currencies;
85
+
86
+    /**
87
+     * Currencies this gateway is not allowed for.
88
+     *
89
+     * @var array
90
+     */
91
+    public $exclude_currencies;
92
+
93
+    /**
94
+     * Maximum transaction amount, zero does not define a maximum.
95
+     *
96
+     * @var int
97
+     */
98
+    public $max_amount = 0;
99
+
100
+    /**
101
+     * Optional URL to view a transaction.
102
+     *
103
+     * @var string
104
+     */
105
+    public $view_transaction_url = '';
106
+
107
+    /**
108
+     * Optional URL to view a subscription.
109
+     *
110
+     * @var string
111
+     */
112
+    public $view_subscription_url = '';
113
+
114
+    /**
115
+     * Optional label to show for "new payment method" in the payment
116
+     * method/token selection radio selection.
117
+     *
118
+     * @var string
119
+     */
120
+    public $new_method_label = '';
121
+
122
+    /**
123
+     * Contains a user's saved tokens for this gateway.
124
+     *
125
+     * @var array
126
+     */
127
+    protected $tokens = array();
128
+
129
+    /**
130
+     * An array of features that this gateway supports.
131
+     *
132
+     * @var array
133
+     */
134
+    protected $supports = array();
135
+
136
+    /**
137
+     * Class constructor.
138
+     */
139
+    public function __construct() {
140
+
141
+        // Register gateway.
142
+        add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
+
144
+        $this->enabled = wpinv_is_gateway_active( $this->id );
145
+
146
+        // Enable Subscriptions.
147
+        if ( $this->supports( 'subscription' ) ) {
148
+            add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
149
+        }
150
+
151
+        // Enable sandbox.
152
+        if ( $this->supports( 'sandbox' ) ) {
153
+            add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
154
+        }
155
+
156
+        // Gateway settings.
157
+        add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
158 158
 		
159 159
 
160
-		// Gateway checkout fiellds.
161
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
162
-
163
-		// Process payment.
164
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
160
+        // Gateway checkout fiellds.
161
+        add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
162
+
163
+        // Process payment.
164
+        add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
165
+
166
+        // Change the checkout button text.
167
+        if ( ! empty( $this->checkout_button_text ) ) {
168
+            add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
169
+        }
170
+
171
+        // Check if a gateway is valid for a given currency.
172
+        add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
173
+
174
+        // Generate the transaction url.
175
+        add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
176
+
177
+        // Generate the subscription url.
178
+        add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
179
+
180
+        // Confirm payments.
181
+        add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
182
+
183
+        // Verify IPNs.
184
+        add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
185
+
186
+    }
187
+
188
+    /**
189
+     * Checks if this gateway is a given gateway.
190
+     *
191
+     * @since 1.0.19
192
+     * @return bool
193
+     */
194
+    public function is( $gateway ) {
195
+        return $gateway == $this->id;
196
+    }
197
+
198
+    /**
199
+     * Returns a users saved tokens for this gateway.
200
+     *
201
+     * @since 1.0.19
202
+     * @return array
203
+     */
204
+    public function get_tokens( $sandbox = null ) {
205
+
206
+        if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
207
+            $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
208
+
209
+            if ( is_array( $tokens ) ) {
210
+                $this->tokens = $tokens;
211
+            }
212
+
213
+        }
214
+
215
+        if ( ! is_bool( $sandbox ) ) {
216
+            return $this->tokens;
217
+        }
218
+
219
+        $args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
220
+        return wp_list_filter( $this->tokens, $args );
221
+
222
+    }
223
+
224
+    /**
225
+     * Saves a token for this gateway.
226
+     *
227
+     * @since 1.0.19
228
+     */
229
+    public function save_token( $token ) {
230
+
231
+        $tokens   = $this->get_tokens();
232
+        $tokens[] = $token;
233
+
234
+        update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
235
+
236
+        $this->tokens = $tokens;
237
+
238
+    }
239
+
240
+    /**
241
+     * Return the title for admin screens.
242
+     *
243
+     * @return string
244
+     */
245
+    public function get_method_title() {
246
+        return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
247
+    }
248
+
249
+    /**
250
+     * Return the description for admin screens.
251
+     *
252
+     * @return string
253
+     */
254
+    public function get_method_description() {
255
+        return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
256
+    }
257
+
258
+    /**
259
+     * Get the success url.
260
+     *
261
+     * @param WPInv_Invoice $invoice Invoice object.
262
+     * @return string
263
+     */
264
+    public function get_return_url( $invoice ) {
265
+
266
+        // Payment success url
267
+        $return_url = add_query_arg(
268
+            array(
269
+                'payment-confirm' => $this->id,
270
+                'invoice_key'     => $invoice->get_key(),
271
+                'utm_nooverride'  => 1
272
+            ),
273
+            wpinv_get_success_page_uri()
274
+        );
275
+
276
+        return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
277
+    }
278
+
279
+    /**
280
+     * Confirms payments when rendering the success page.
281
+     *
282
+     * @param string $content Success page content.
283
+     * @return string
284
+     */
285
+    public function confirm_payment( $content ) {
286
+
287
+        // Retrieve the invoice.
288
+        $invoice_id = getpaid_get_current_invoice_id();
289
+        $invoice    = wpinv_get_invoice( $invoice_id );
290
+
291
+        // Ensure that it exists and that it is pending payment.
292
+        if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
293
+            return $content;
294
+        }
295
+
296
+        // Can the user view this invoice??
297
+        if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
298
+            return $content;
299
+        }
300
+
301
+        // Show payment processing indicator.
302
+        return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
303
+    }
304
+
305
+    /**
306
+     * Processes ipns and marks payments as complete.
307
+     *
308
+     * @return void
309
+     */
310
+    public function verify_ipn() {}
311
+
312
+    /**
313
+     * Get a link to the transaction on the 3rd party gateway site (if applicable).
314
+     *
315
+     * @param string $transaction_url transaction url.
316
+     * @param WPInv_Invoice $invoice Invoice object.
317
+     * @return string transaction URL, or empty string.
318
+     */
319
+    public function filter_transaction_url( $transaction_url, $invoice ) {
320
+
321
+        $transaction_id  = $invoice->get_transaction_id();
322
+
323
+        if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
324
+            $transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
325
+            $replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
326
+            $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
327
+        }
328
+
329
+        return $transaction_url;
330
+    }
331
+
332
+    /**
333
+     * Get a link to the subscription on the 3rd party gateway site (if applicable).
334
+     *
335
+     * @param string $subscription_url transaction url.
336
+     * @param WPInv_Invoice $invoice Invoice object.
337
+     * @return string subscription URL, or empty string.
338
+     */
339
+    public function filter_subscription_url( $subscription_url, $invoice ) {
340
+
341
+        $profile_id      = $invoice->get_subscription_id();
342
+
343
+        if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
344
+
345
+            $subscription_url = sprintf( $this->view_subscription_url, $profile_id );
346
+            $replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
347
+            $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
348
+
349
+        }
350
+
351
+        return $subscription_url;
352
+    }
353
+
354
+    /**
355
+     * Check if the gateway is available for use.
356
+     *
357
+     * @return bool
358
+     */
359
+    public function is_available() {
360
+        return ! empty( $this->enabled );
361
+    }
362
+
363
+    /**
364
+     * Return the gateway's title.
365
+     *
366
+     * @return string
367
+     */
368
+    public function get_title() {
369
+        return apply_filters( 'getpaid_gateway_title', $this->title, $this );
370
+    }
371
+
372
+    /**
373
+     * Return the gateway's description.
374
+     *
375
+     * @return string
376
+     */
377
+    public function get_description() {
378
+        return apply_filters( 'getpaid_gateway_description', $this->description, $this );
379
+    }
380
+
381
+    /**
382
+     * Process Payment.
383
+     *
384
+     *
385
+     * @param WPInv_Invoice $invoice Invoice.
386
+     * @param array $submission_data Posted checkout fields.
387
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
388
+     * @return void
389
+     */
390
+    public function process_payment( $invoice, $submission_data, $submission ) {
391
+        // Process the payment then either redirect to the success page or the gateway.
392
+        do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
393
+    }
394
+
395
+    /**
396
+     * Process refund.
397
+     *
398
+     * If the gateway declares 'refunds' support, this will allow it to refund.
399
+     * a passed in amount.
400
+     *
401
+     * @param WPInv_Invoice $invoice Invoice.
402
+     * @param  float  $amount Refund amount.
403
+     * @param  string $reason Refund reason.
404
+     * @return WP_Error|bool True or false based on success, or a WP_Error object.
405
+     */
406
+    public function process_refund( $invoice, $amount = null, $reason = '' ) {
407
+        return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
408
+    }
409
+
410
+    /**
411
+     * Displays the payment fields, credit cards etc.
412
+     * 
413
+     * @param int $invoice_id 0 or invoice id.
414
+     * @param GetPaid_Payment_Form $form Current payment form.
415
+     */
416
+    public function payment_fields( $invoice_id, $form ) {
417
+        do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
418
+    }
419
+
420
+    /**
421
+     * Filters the gateway settings.
422
+     * 
423
+     * @param array $admin_settings
424
+     */
425
+    public function admin_settings( $admin_settings ) {
426
+        return $admin_settings;
427
+    }
428
+
429
+    /**
430
+     * Retrieves the value of a gateway setting.
431
+     * 
432
+     * @param string $option
433
+     */
434
+    public function get_option( $option, $default = false ) {
435
+        return wpinv_get_option( $this->id . '_' . $option, $default );
436
+    }
437
+
438
+    /**
439
+     * Check if a gateway supports a given feature.
440
+     *
441
+     * Gateways should override this to declare support (or lack of support) for a feature.
442
+     * For backward compatibility, gateways support 'products' by default, but nothing else.
443
+     *
444
+     * @param string $feature string The name of a feature to test support for.
445
+     * @return bool True if the gateway supports the feature, false otherwise.
446
+     * @since 1.0.19
447
+     */
448
+    public function supports( $feature ) {
449
+        return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
450
+    }
165 451
 
166
-		// Change the checkout button text.
167
-		if ( ! empty( $this->checkout_button_text ) ) {
168
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
169
-		}
170
-
171
-		// Check if a gateway is valid for a given currency.
172
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
173
-
174
-		// Generate the transaction url.
175
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
176
-
177
-		// Generate the subscription url.
178
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
179
-
180
-		// Confirm payments.
181
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
182
-
183
-		// Verify IPNs.
184
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
185
-
186
-	}
187
-
188
-	/**
189
-	 * Checks if this gateway is a given gateway.
190
-	 *
191
-	 * @since 1.0.19
192
-	 * @return bool
193
-	 */
194
-	public function is( $gateway ) {
195
-		return $gateway == $this->id;
196
-	}
197
-
198
-	/**
199
-	 * Returns a users saved tokens for this gateway.
200
-	 *
201
-	 * @since 1.0.19
202
-	 * @return array
203
-	 */
204
-	public function get_tokens( $sandbox = null ) {
205
-
206
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
207
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
208
-
209
-			if ( is_array( $tokens ) ) {
210
-				$this->tokens = $tokens;
211
-			}
212
-
213
-		}
214
-
215
-		if ( ! is_bool( $sandbox ) ) {
216
-			return $this->tokens;
217
-		}
218
-
219
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
220
-		return wp_list_filter( $this->tokens, $args );
221
-
222
-	}
223
-
224
-	/**
225
-	 * Saves a token for this gateway.
226
-	 *
227
-	 * @since 1.0.19
228
-	 */
229
-	public function save_token( $token ) {
230
-
231
-		$tokens   = $this->get_tokens();
232
-		$tokens[] = $token;
233
-
234
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
235
-
236
-		$this->tokens = $tokens;
237
-
238
-	}
239
-
240
-	/**
241
-	 * Return the title for admin screens.
242
-	 *
243
-	 * @return string
244
-	 */
245
-	public function get_method_title() {
246
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
247
-	}
248
-
249
-	/**
250
-	 * Return the description for admin screens.
251
-	 *
252
-	 * @return string
253
-	 */
254
-	public function get_method_description() {
255
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
256
-	}
257
-
258
-	/**
259
-	 * Get the success url.
260
-	 *
261
-	 * @param WPInv_Invoice $invoice Invoice object.
262
-	 * @return string
263
-	 */
264
-	public function get_return_url( $invoice ) {
265
-
266
-		// Payment success url
267
-		$return_url = add_query_arg(
268
-			array(
269
-				'payment-confirm' => $this->id,
270
-				'invoice_key'     => $invoice->get_key(),
271
-				'utm_nooverride'  => 1
272
-			),
273
-			wpinv_get_success_page_uri()
274
-		);
275
-
276
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
277
-	}
278
-
279
-	/**
280
-	 * Confirms payments when rendering the success page.
281
-	 *
282
-	 * @param string $content Success page content.
283
-	 * @return string
284
-	 */
285
-	public function confirm_payment( $content ) {
286
-
287
-		// Retrieve the invoice.
288
-		$invoice_id = getpaid_get_current_invoice_id();
289
-		$invoice    = wpinv_get_invoice( $invoice_id );
290
-
291
-		// Ensure that it exists and that it is pending payment.
292
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
293
-			return $content;
294
-		}
295
-
296
-		// Can the user view this invoice??
297
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
298
-			return $content;
299
-		}
300
-
301
-		// Show payment processing indicator.
302
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
303
-	}
304
-
305
-	/**
306
-	 * Processes ipns and marks payments as complete.
307
-	 *
308
-	 * @return void
309
-	 */
310
-	public function verify_ipn() {}
311
-
312
-	/**
313
-	 * Get a link to the transaction on the 3rd party gateway site (if applicable).
314
-	 *
315
-	 * @param string $transaction_url transaction url.
316
-	 * @param WPInv_Invoice $invoice Invoice object.
317
-	 * @return string transaction URL, or empty string.
318
-	 */
319
-	public function filter_transaction_url( $transaction_url, $invoice ) {
320
-
321
-		$transaction_id  = $invoice->get_transaction_id();
322
-
323
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
324
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
325
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
326
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
327
-		}
328
-
329
-		return $transaction_url;
330
-	}
331
-
332
-	/**
333
-	 * Get a link to the subscription on the 3rd party gateway site (if applicable).
334
-	 *
335
-	 * @param string $subscription_url transaction url.
336
-	 * @param WPInv_Invoice $invoice Invoice object.
337
-	 * @return string subscription URL, or empty string.
338
-	 */
339
-	public function filter_subscription_url( $subscription_url, $invoice ) {
340
-
341
-		$profile_id      = $invoice->get_subscription_id();
342
-
343
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
344
-
345
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
346
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
347
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
348
-
349
-		}
350
-
351
-		return $subscription_url;
352
-	}
353
-
354
-	/**
355
-	 * Check if the gateway is available for use.
356
-	 *
357
-	 * @return bool
358
-	 */
359
-	public function is_available() {
360
-		return ! empty( $this->enabled );
361
-	}
362
-
363
-	/**
364
-	 * Return the gateway's title.
365
-	 *
366
-	 * @return string
367
-	 */
368
-	public function get_title() {
369
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
370
-	}
371
-
372
-	/**
373
-	 * Return the gateway's description.
374
-	 *
375
-	 * @return string
376
-	 */
377
-	public function get_description() {
378
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
379
-	}
380
-
381
-	/**
382
-	 * Process Payment.
383
-	 *
384
-	 *
385
-	 * @param WPInv_Invoice $invoice Invoice.
386
-	 * @param array $submission_data Posted checkout fields.
387
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
388
-	 * @return void
389
-	 */
390
-	public function process_payment( $invoice, $submission_data, $submission ) {
391
-		// Process the payment then either redirect to the success page or the gateway.
392
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
393
-	}
394
-
395
-	/**
396
-	 * Process refund.
397
-	 *
398
-	 * If the gateway declares 'refunds' support, this will allow it to refund.
399
-	 * a passed in amount.
400
-	 *
401
-	 * @param WPInv_Invoice $invoice Invoice.
402
-	 * @param  float  $amount Refund amount.
403
-	 * @param  string $reason Refund reason.
404
-	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
405
-	 */
406
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
407
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
408
-	}
409
-
410
-	/**
411
-	 * Displays the payment fields, credit cards etc.
412
-	 * 
413
-	 * @param int $invoice_id 0 or invoice id.
414
-	 * @param GetPaid_Payment_Form $form Current payment form.
415
-	 */
416
-	public function payment_fields( $invoice_id, $form ) {
417
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
418
-	}
419
-
420
-	/**
421
-	 * Filters the gateway settings.
422
-	 * 
423
-	 * @param array $admin_settings
424
-	 */
425
-	public function admin_settings( $admin_settings ) {
426
-		return $admin_settings;
427
-	}
428
-
429
-	/**
430
-	 * Retrieves the value of a gateway setting.
431
-	 * 
432
-	 * @param string $option
433
-	 */
434
-	public function get_option( $option, $default = false ) {
435
-		return wpinv_get_option( $this->id . '_' . $option, $default );
436
-	}
437
-
438
-	/**
439
-	 * Check if a gateway supports a given feature.
440
-	 *
441
-	 * Gateways should override this to declare support (or lack of support) for a feature.
442
-	 * For backward compatibility, gateways support 'products' by default, but nothing else.
443
-	 *
444
-	 * @param string $feature string The name of a feature to test support for.
445
-	 * @return bool True if the gateway supports the feature, false otherwise.
446
-	 * @since 1.0.19
447
-	 */
448
-	public function supports( $feature ) {
449
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
450
-	}
451
-
452
-	/**
453
-	 * Returns the credit card form html.
454
-	 * 
455
-	 * @param bool $save whether or not to display the save button.
456
-	 */
452
+    /**
453
+     * Returns the credit card form html.
454
+     * 
455
+     * @param bool $save whether or not to display the save button.
456
+     */
457 457
     public function get_cc_form( $save = false ) {
458 458
 
459
-		ob_start();
459
+        ob_start();
460 460
 
461 461
         $id_prefix = esc_attr( uniqid( $this->id ) );
462 462
 
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
                                         'name'              => $this->id . '[cc_cvv2]',
552 552
                                         'id'                => "$id_prefix-cc-cvv2",
553 553
                                         'label'             => __( 'CCV', 'invoicing' ),
554
-										'label_type'        => 'vertical',
555
-										'class'             => 'form-control-sm',
554
+                                        'label_type'        => 'vertical',
555
+                                        'class'             => 'form-control-sm',
556 556
                                     )
557 557
                                 );
558 558
                             ?>
@@ -562,175 +562,175 @@  discard block
 block discarded – undo
562 562
 					
563 563
 					<?php
564 564
 
565
-						if ( $save ) {
566
-							echo $this->save_payment_method_checkbox();
567
-						}
565
+                        if ( $save ) {
566
+                            echo $this->save_payment_method_checkbox();
567
+                        }
568 568
 
569
-					?>
569
+                    ?>
570 570
                 </div>
571 571
 
572 572
             </div>
573 573
 		<?php
574 574
 		
575
-		return ob_get_clean();
575
+        return ob_get_clean();
576 576
 
577 577
     }
578 578
 
579
-	/**
580
-	 * Displays a new payment method entry form.
581
-	 *
582
-	 * @since 1.0.19
583
-	 */
584
-	public function new_payment_method_entry( $form ) {
585
-		echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
586
-	}
587
-
588
-	/**
589
-	 * Grab and display our saved payment methods.
590
-	 *
591
-	 * @since 1.0.19
592
-	 */
593
-	public function saved_payment_methods() {
594
-		$html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
595
-
596
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
597
-			$html .= $this->get_saved_payment_method_option_html( $token );
598
-		}
599
-
600
-		$html .= $this->get_new_payment_method_option_html();
601
-		$html .= '</ul>';
602
-
603
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
604
-	}
605
-
606
-	/**
607
-	 * Gets saved payment method HTML from a token.
608
-	 *
609
-	 * @since 1.0.19
610
-	 * @param  array $token Payment Token.
611
-	 * @return string Generated payment method HTML
612
-	 */
613
-	public function get_saved_payment_method_option_html( $token ) {
614
-
615
-		return sprintf(
616
-			'<li class="getpaid-payment-method form-group">
579
+    /**
580
+     * Displays a new payment method entry form.
581
+     *
582
+     * @since 1.0.19
583
+     */
584
+    public function new_payment_method_entry( $form ) {
585
+        echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
586
+    }
587
+
588
+    /**
589
+     * Grab and display our saved payment methods.
590
+     *
591
+     * @since 1.0.19
592
+     */
593
+    public function saved_payment_methods() {
594
+        $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
595
+
596
+        foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
597
+            $html .= $this->get_saved_payment_method_option_html( $token );
598
+        }
599
+
600
+        $html .= $this->get_new_payment_method_option_html();
601
+        $html .= '</ul>';
602
+
603
+        echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
604
+    }
605
+
606
+    /**
607
+     * Gets saved payment method HTML from a token.
608
+     *
609
+     * @since 1.0.19
610
+     * @param  array $token Payment Token.
611
+     * @return string Generated payment method HTML
612
+     */
613
+    public function get_saved_payment_method_option_html( $token ) {
614
+
615
+        return sprintf(
616
+            '<li class="getpaid-payment-method form-group">
617 617
 				<label>
618 618
 					<input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s />
619 619
 					<span>%3$s</span>
620 620
 				</label>
621 621
 			</li>',
622
-			esc_attr( $this->id ),
623
-			esc_attr( $token['id'] ),
624
-			esc_html( $token['name'] ),
625
-			checked( empty( $token['default'] ), false, false )
626
-		);
622
+            esc_attr( $this->id ),
623
+            esc_attr( $token['id'] ),
624
+            esc_html( $token['name'] ),
625
+            checked( empty( $token['default'] ), false, false )
626
+        );
627 627
 
628
-	}
628
+    }
629 629
 
630
-	/**
631
-	 * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
632
-	 *
633
-	 * @since 1.0.19
634
-	 */
635
-	public function get_new_payment_method_option_html() {
630
+    /**
631
+     * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
632
+     *
633
+     * @since 1.0.19
634
+     */
635
+    public function get_new_payment_method_option_html() {
636 636
 
637
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
637
+        $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
638 638
 
639
-		return sprintf(
640
-			'<li class="getpaid-new-payment-method">
639
+        return sprintf(
640
+            '<li class="getpaid-new-payment-method">
641 641
 				<label>
642 642
 					<input name="getpaid-%1$s-payment-method" type="radio" value="new" style="width:auto;" />
643 643
 					<span>%2$s</span>
644 644
 				</label>
645 645
 			</li>',
646
-			esc_attr( $this->id ),
647
-			esc_html( $label )
648
-		);
646
+            esc_attr( $this->id ),
647
+            esc_html( $label )
648
+        );
649 649
 
650
-	}
650
+    }
651 651
 
652
-	/**
653
-	 * Outputs a checkbox for saving a new payment method to the database.
654
-	 *
655
-	 * @since 1.0.19
656
-	 */
657
-	public function save_payment_method_checkbox() {
652
+    /**
653
+     * Outputs a checkbox for saving a new payment method to the database.
654
+     *
655
+     * @since 1.0.19
656
+     */
657
+    public function save_payment_method_checkbox() {
658 658
 
659
-		return sprintf(
660
-			'<p class="form-group getpaid-save-payment-method">
659
+        return sprintf(
660
+            '<p class="form-group getpaid-save-payment-method">
661 661
 				<label>
662 662
 					<input name="getpaid-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
663 663
 					<span>%2$s</span>
664 664
 				</label>
665 665
 			</p>',
666
-			esc_attr( $this->id ),
667
-			esc_html__( 'Save payment method', 'invoicing' )
668
-		);
666
+            esc_attr( $this->id ),
667
+            esc_html__( 'Save payment method', 'invoicing' )
668
+        );
669 669
 
670
-	}
670
+    }
671 671
 
672
-	/**
673
-	 * Registers the gateway.
674
-	 *
675
-	 * @return array
676
-	 */
677
-	public function register_gateway( $gateways ) {
672
+    /**
673
+     * Registers the gateway.
674
+     *
675
+     * @return array
676
+     */
677
+    public function register_gateway( $gateways ) {
678 678
 
679
-		$gateways[ $this->id ] = array(
679
+        $gateways[ $this->id ] = array(
680 680
 
681
-			'admin_label'    => $this->method_title,
681
+            'admin_label'    => $this->method_title,
682 682
             'checkout_label' => $this->title,
683
-			'ordering'       => $this->order,
684
-
685
-		);
686
-
687
-		return $gateways;
688
-
689
-	}
690
-
691
-	/**
692
-	 * Checks whether or not this is a sandbox request.
693
-	 *
694
-	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
695
-	 * @return bool
696
-	 */
697
-	public function is_sandbox( $invoice = null ) {
698
-
699
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
700
-			return $invoice->get_mode() == 'test';
701
-		}
702
-
703
-		return wpinv_is_test_mode( $this->id );
704
-
705
-	}
706
-
707
-	/**
708
-	 * Renames the checkout button
709
-	 *
710
-	 * @return string
711
-	 */
712
-	public function rename_checkout_button() {
713
-		return $this->checkout_button_text;
714
-	}
715
-
716
-	/**
717
-	 * Validate gateway currency
718
-	 *
719
-	 * @return bool
720
-	 */
721
-	public function validate_currency( $validation, $currency ) {
722
-
723
-		// Required currencies.
724
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
725
-			return false;
726
-		}
727
-
728
-		// Excluded currencies.
729
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
730
-			return false;
731
-		}
732
-
733
-		return $validation;
734
-	}
683
+            'ordering'       => $this->order,
684
+
685
+        );
686
+
687
+        return $gateways;
688
+
689
+    }
690
+
691
+    /**
692
+     * Checks whether or not this is a sandbox request.
693
+     *
694
+     * @param  WPInv_Invoice|null $invoice Invoice object or null.
695
+     * @return bool
696
+     */
697
+    public function is_sandbox( $invoice = null ) {
698
+
699
+        if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
700
+            return $invoice->get_mode() == 'test';
701
+        }
702
+
703
+        return wpinv_is_test_mode( $this->id );
704
+
705
+    }
706
+
707
+    /**
708
+     * Renames the checkout button
709
+     *
710
+     * @return string
711
+     */
712
+    public function rename_checkout_button() {
713
+        return $this->checkout_button_text;
714
+    }
715
+
716
+    /**
717
+     * Validate gateway currency
718
+     *
719
+     * @return bool
720
+     */
721
+    public function validate_currency( $validation, $currency ) {
722
+
723
+        // Required currencies.
724
+        if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
725
+            return false;
726
+        }
727
+
728
+        // Excluded currencies.
729
+        if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
730
+            return false;
731
+        }
732
+
733
+        return $validation;
734
+    }
735 735
 
736 736
 }
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 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
  * Abstaract Payment Gateway class.
@@ -139,49 +139,49 @@  discard block
 block discarded – undo
139 139
 	public function __construct() {
140 140
 
141 141
 		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
142
+		add_filter('wpinv_payment_gateways', array($this, 'register_gateway'));
143 143
 
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
144
+		$this->enabled = wpinv_is_gateway_active($this->id);
145 145
 
146 146
 		// Enable Subscriptions.
147
-		if ( $this->supports( 'subscription' ) ) {
148
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
147
+		if ($this->supports('subscription')) {
148
+			add_filter("wpinv_{$this->id}_support_subscription", '__return_true');
149 149
 		}
150 150
 
151 151
 		// Enable sandbox.
152
-		if ( $this->supports( 'sandbox' ) ) {
153
-			add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
152
+		if ($this->supports('sandbox')) {
153
+			add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true');
154 154
 		}
155 155
 
156 156
 		// Gateway settings.
157
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
157
+		add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings'));
158 158
 		
159 159
 
160 160
 		// Gateway checkout fiellds.
161
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
161
+		add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2);
162 162
 
163 163
 		// Process payment.
164
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
164
+		add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3);
165 165
 
166 166
 		// Change the checkout button text.
167
-		if ( ! empty( $this->checkout_button_text ) ) {
168
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
167
+		if (!empty($this->checkout_button_text)) {
168
+			add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button'));
169 169
 		}
170 170
 
171 171
 		// Check if a gateway is valid for a given currency.
172
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
172
+		add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2);
173 173
 
174 174
 		// Generate the transaction url.
175
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
175
+		add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2);
176 176
 
177 177
 		// Generate the subscription url.
178
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
178
+		add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2);
179 179
 
180 180
 		// Confirm payments.
181
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
181
+		add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2);
182 182
 
183 183
 		// Verify IPNs.
184
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
184
+		add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn'));
185 185
 
186 186
 	}
187 187
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @since 1.0.19
192 192
 	 * @return bool
193 193
 	 */
194
-	public function is( $gateway ) {
194
+	public function is($gateway) {
195 195
 		return $gateway == $this->id;
196 196
 	}
197 197
 
@@ -201,23 +201,23 @@  discard block
 block discarded – undo
201 201
 	 * @since 1.0.19
202 202
 	 * @return array
203 203
 	 */
204
-	public function get_tokens( $sandbox = null ) {
204
+	public function get_tokens($sandbox = null) {
205 205
 
206
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
207
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
206
+		if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) {
207
+			$tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true);
208 208
 
209
-			if ( is_array( $tokens ) ) {
209
+			if (is_array($tokens)) {
210 210
 				$this->tokens = $tokens;
211 211
 			}
212 212
 
213 213
 		}
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
215
+		if (!is_bool($sandbox)) {
216 216
 			return $this->tokens;
217 217
 		}
218 218
 
219
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
220
-		return wp_list_filter( $this->tokens, $args );
219
+		$args = array('type' => $sandbox ? 'sandbox' : 'live');
220
+		return wp_list_filter($this->tokens, $args);
221 221
 
222 222
 	}
223 223
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @since 1.0.19
228 228
 	 */
229
-	public function save_token( $token ) {
229
+	public function save_token($token) {
230 230
 
231 231
 		$tokens   = $this->get_tokens();
232 232
 		$tokens[] = $token;
233 233
 
234
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
234
+		update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens);
235 235
 
236 236
 		$this->tokens = $tokens;
237 237
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function get_method_title() {
246
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
246
+		return apply_filters('getpaid_gateway_method_title', $this->method_title, $this);
247 247
 	}
248 248
 
249 249
 	/**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return string
253 253
 	 */
254 254
 	public function get_method_description() {
255
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
255
+		return apply_filters('getpaid_gateway_method_description', $this->method_description, $this);
256 256
 	}
257 257
 
258 258
 	/**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @param WPInv_Invoice $invoice Invoice object.
262 262
 	 * @return string
263 263
 	 */
264
-	public function get_return_url( $invoice ) {
264
+	public function get_return_url($invoice) {
265 265
 
266 266
 		// Payment success url
267 267
 		$return_url = add_query_arg(
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 			wpinv_get_success_page_uri()
274 274
 		);
275 275
 
276
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
276
+		return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this);
277 277
 	}
278 278
 
279 279
 	/**
@@ -282,24 +282,24 @@  discard block
 block discarded – undo
282 282
 	 * @param string $content Success page content.
283 283
 	 * @return string
284 284
 	 */
285
-	public function confirm_payment( $content ) {
285
+	public function confirm_payment($content) {
286 286
 
287 287
 		// Retrieve the invoice.
288 288
 		$invoice_id = getpaid_get_current_invoice_id();
289
-		$invoice    = wpinv_get_invoice( $invoice_id );
289
+		$invoice    = wpinv_get_invoice($invoice_id);
290 290
 
291 291
 		// Ensure that it exists and that it is pending payment.
292
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
292
+		if (empty($invoice_id) || !$invoice->needs_payment()) {
293 293
 			return $content;
294 294
 		}
295 295
 
296 296
 		// Can the user view this invoice??
297
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
297
+		if (!wpinv_user_can_view_invoice($invoice)) {
298 298
 			return $content;
299 299
 		}
300 300
 
301 301
 		// Show payment processing indicator.
302
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
302
+		return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice'));
303 303
 	}
304 304
 
305 305
 	/**
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
 	 * @param WPInv_Invoice $invoice Invoice object.
317 317
 	 * @return string transaction URL, or empty string.
318 318
 	 */
319
-	public function filter_transaction_url( $transaction_url, $invoice ) {
319
+	public function filter_transaction_url($transaction_url, $invoice) {
320 320
 
321
-		$transaction_id  = $invoice->get_transaction_id();
321
+		$transaction_id = $invoice->get_transaction_id();
322 322
 
323
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
324
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
325
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
326
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
323
+		if (!empty($this->view_transaction_url) && !empty($transaction_id)) {
324
+			$transaction_url = sprintf($this->view_transaction_url, $transaction_id);
325
+			$replace         = $this->is_sandbox($invoice) ? 'sandbox' : '';
326
+			$transaction_url = str_replace('{sandbox}', $replace, $transaction_url);
327 327
 		}
328 328
 
329 329
 		return $transaction_url;
@@ -336,15 +336,15 @@  discard block
 block discarded – undo
336 336
 	 * @param WPInv_Invoice $invoice Invoice object.
337 337
 	 * @return string subscription URL, or empty string.
338 338
 	 */
339
-	public function filter_subscription_url( $subscription_url, $invoice ) {
339
+	public function filter_subscription_url($subscription_url, $invoice) {
340 340
 
341
-		$profile_id      = $invoice->get_subscription_id();
341
+		$profile_id = $invoice->get_subscription_id();
342 342
 
343
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
343
+		if (!empty($this->view_subscription_url) && !empty($profile_id)) {
344 344
 
345
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
346
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
347
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
345
+			$subscription_url = sprintf($this->view_subscription_url, $profile_id);
346
+			$replace          = $this->is_sandbox($invoice) ? 'sandbox' : '';
347
+			$subscription_url = str_replace('{sandbox}', $replace, $subscription_url);
348 348
 
349 349
 		}
350 350
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 * @return bool
358 358
 	 */
359 359
 	public function is_available() {
360
-		return ! empty( $this->enabled );
360
+		return !empty($this->enabled);
361 361
 	}
362 362
 
363 363
 	/**
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @return string
367 367
 	 */
368 368
 	public function get_title() {
369
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
369
+		return apply_filters('getpaid_gateway_title', $this->title, $this);
370 370
 	}
371 371
 
372 372
 	/**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @return string
376 376
 	 */
377 377
 	public function get_description() {
378
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
378
+		return apply_filters('getpaid_gateway_description', $this->description, $this);
379 379
 	}
380 380
 
381 381
 	/**
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
388 388
 	 * @return void
389 389
 	 */
390
-	public function process_payment( $invoice, $submission_data, $submission ) {
390
+	public function process_payment($invoice, $submission_data, $submission) {
391 391
 		// Process the payment then either redirect to the success page or the gateway.
392
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
392
+		do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission);
393 393
 	}
394 394
 
395 395
 	/**
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $reason Refund reason.
404 404
 	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
405 405
 	 */
406
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
407
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
406
+	public function process_refund($invoice, $amount = null, $reason = '') {
407
+		return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason);
408 408
 	}
409 409
 
410 410
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * @param int $invoice_id 0 or invoice id.
414 414
 	 * @param GetPaid_Payment_Form $form Current payment form.
415 415
 	 */
416
-	public function payment_fields( $invoice_id, $form ) {
417
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
416
+	public function payment_fields($invoice_id, $form) {
417
+		do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form);
418 418
 	}
419 419
 
420 420
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * 
423 423
 	 * @param array $admin_settings
424 424
 	 */
425
-	public function admin_settings( $admin_settings ) {
425
+	public function admin_settings($admin_settings) {
426 426
 		return $admin_settings;
427 427
 	}
428 428
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * 
432 432
 	 * @param string $option
433 433
 	 */
434
-	public function get_option( $option, $default = false ) {
435
-		return wpinv_get_option( $this->id . '_' . $option, $default );
434
+	public function get_option($option, $default = false) {
435
+		return wpinv_get_option($this->id . '_' . $option, $default);
436 436
 	}
437 437
 
438 438
 	/**
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 * @return bool True if the gateway supports the feature, false otherwise.
446 446
 	 * @since 1.0.19
447 447
 	 */
448
-	public function supports( $feature ) {
449
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
448
+	public function supports($feature) {
449
+		return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this);
450 450
 	}
451 451
 
452 452
 	/**
@@ -454,36 +454,36 @@  discard block
 block discarded – undo
454 454
 	 * 
455 455
 	 * @param bool $save whether or not to display the save button.
456 456
 	 */
457
-    public function get_cc_form( $save = false ) {
457
+    public function get_cc_form($save = false) {
458 458
 
459 459
 		ob_start();
460 460
 
461
-        $id_prefix = esc_attr( uniqid( $this->id ) );
461
+        $id_prefix = esc_attr(uniqid($this->id));
462 462
 
463 463
         $months = array(
464
-            '01' => __( 'January', 'invoicing' ),
465
-            '02' => __( 'February', 'invoicing' ),
466
-            '03' => __( 'March', 'invoicing' ),
467
-            '04' => __( 'April', 'invoicing' ),
468
-            '05' => __( 'May', 'invoicing' ),
469
-            '06' => __( 'June', 'invoicing' ),
470
-            '07' => __( 'July', 'invoicing' ),
471
-            '08' => __( 'August', 'invoicing' ),
472
-            '09' => __( 'September', 'invoicing' ),
473
-            '10' => __( 'October', 'invoicing' ),
474
-            '11' => __( 'November', 'invoicing' ),
475
-            '12' => __( 'December', 'invoicing' ),
464
+            '01' => __('January', 'invoicing'),
465
+            '02' => __('February', 'invoicing'),
466
+            '03' => __('March', 'invoicing'),
467
+            '04' => __('April', 'invoicing'),
468
+            '05' => __('May', 'invoicing'),
469
+            '06' => __('June', 'invoicing'),
470
+            '07' => __('July', 'invoicing'),
471
+            '08' => __('August', 'invoicing'),
472
+            '09' => __('September', 'invoicing'),
473
+            '10' => __('October', 'invoicing'),
474
+            '11' => __('November', 'invoicing'),
475
+            '12' => __('December', 'invoicing'),
476 476
         );
477 477
 
478
-        $year  = (int) date( 'Y', current_time( 'timestamp' ) );
478
+        $year  = (int) date('Y', current_time('timestamp'));
479 479
         $years = array();
480 480
 
481
-        for ( $i = 0; $i <= 10; $i++ ) {
482
-            $years[ $year + $i ] = $year + $i;
481
+        for ($i = 0; $i <= 10; $i++) {
482
+            $years[$year + $i] = $year + $i;
483 483
         }
484 484
 
485 485
         ?>
486
-            <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1">
486
+            <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1">
487 487
 
488 488
 
489 489
                 <div class="getpaid-cc-card-inner">
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
                         <div class="col-12">
493 493
 
494 494
 							<div class="form-group">
495
-								<label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label>
495
+								<label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label>
496 496
 								<div class="input-group input-group-sm">
497 497
 									<div class="input-group-prepend ">
498 498
 										<span class="input-group-text">
499 499
 											<i class="fa fa-credit-card"></i>
500 500
 										</span>
501 501
 									</div>
502
-									<input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm">
502
+									<input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm">
503 503
 								</div>
504 504
 							</div>
505 505
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 
508 508
                         <div class="col-12">
509 509
                             <div class="form-group">
510
-                                <label><?php _e( 'Expiration', 'invoicing' ); ?></label>
510
+                                <label><?php _e('Expiration', 'invoicing'); ?></label>
511 511
                                 <div class="form-row">
512 512
 
513 513
                                     <div class="col">
514
-                                        <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]">
515
-                                            <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option>
514
+                                        <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]">
515
+                                            <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option>
516 516
 
517 517
                                             <?php
518
-                                                foreach ( $months as $key => $month ) {
519
-                                                    $key   = esc_attr( $key );
520
-                                                    $month = wpinv_clean( $month );
518
+                                                foreach ($months as $key => $month) {
519
+                                                    $key   = esc_attr($key);
520
+                                                    $month = wpinv_clean($month);
521 521
                                                     echo "<option value='$key'>$month</option>" . PHP_EOL;
522 522
                                                 }
523 523
                                             ?>
@@ -526,13 +526,13 @@  discard block
 block discarded – undo
526 526
                                     </div>
527 527
 
528 528
                                     <div class="col">
529
-                                        <select class="form-control form-control-sm" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]">
530
-                                            <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option>
529
+                                        <select class="form-control form-control-sm" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]">
530
+                                            <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option>
531 531
 
532 532
                                             <?php
533
-                                                foreach ( $years as $key => $year ) {
534
-                                                    $key   = esc_attr( $key );
535
-                                                    $year  = wpinv_clean( $year );
533
+                                                foreach ($years as $key => $year) {
534
+                                                    $key   = esc_attr($key);
535
+                                                    $year  = wpinv_clean($year);
536 536
                                                     echo "<option value='$key'>$year</option>" . PHP_EOL;
537 537
                                                 }
538 538
                                             ?>
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
                                     array(
551 551
                                         'name'              => $this->id . '[cc_cvv2]',
552 552
                                         'id'                => "$id_prefix-cc-cvv2",
553
-                                        'label'             => __( 'CCV', 'invoicing' ),
553
+                                        'label'             => __('CCV', 'invoicing'),
554 554
 										'label_type'        => 'vertical',
555 555
 										'class'             => 'form-control-sm',
556 556
                                     )
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 					
563 563
 					<?php
564 564
 
565
-						if ( $save ) {
565
+						if ($save) {
566 566
 							echo $this->save_payment_method_checkbox();
567 567
 						}
568 568
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0.19
583 583
 	 */
584
-	public function new_payment_method_entry( $form ) {
584
+	public function new_payment_method_entry($form) {
585 585
 		echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
586 586
 	}
587 587
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 * @since 1.0.19
592 592
 	 */
593 593
 	public function saved_payment_methods() {
594
-		$html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
594
+		$html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">';
595 595
 
596
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
597
-			$html .= $this->get_saved_payment_method_option_html( $token );
596
+		foreach ($this->get_tokens($this->is_sandbox()) as $token) {
597
+			$html .= $this->get_saved_payment_method_option_html($token);
598 598
 		}
599 599
 
600 600
 		$html .= $this->get_new_payment_method_option_html();
601 601
 		$html .= '</ul>';
602 602
 
603
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
603
+		echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this);
604 604
 	}
605 605
 
606 606
 	/**
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 * @param  array $token Payment Token.
611 611
 	 * @return string Generated payment method HTML
612 612
 	 */
613
-	public function get_saved_payment_method_option_html( $token ) {
613
+	public function get_saved_payment_method_option_html($token) {
614 614
 
615 615
 		return sprintf(
616 616
 			'<li class="getpaid-payment-method form-group">
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 					<span>%3$s</span>
620 620
 				</label>
621 621
 			</li>',
622
-			esc_attr( $this->id ),
623
-			esc_attr( $token['id'] ),
624
-			esc_html( $token['name'] ),
625
-			checked( empty( $token['default'] ), false, false )
622
+			esc_attr($this->id),
623
+			esc_attr($token['id']),
624
+			esc_html($token['name']),
625
+			checked(empty($token['default']), false, false)
626 626
 		);
627 627
 
628 628
 	}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	 */
635 635
 	public function get_new_payment_method_option_html() {
636 636
 
637
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
637
+		$label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this);
638 638
 
639 639
 		return sprintf(
640 640
 			'<li class="getpaid-new-payment-method">
@@ -643,8 +643,8 @@  discard block
 block discarded – undo
643 643
 					<span>%2$s</span>
644 644
 				</label>
645 645
 			</li>',
646
-			esc_attr( $this->id ),
647
-			esc_html( $label )
646
+			esc_attr($this->id),
647
+			esc_html($label)
648 648
 		);
649 649
 
650 650
 	}
@@ -663,8 +663,8 @@  discard block
 block discarded – undo
663 663
 					<span>%2$s</span>
664 664
 				</label>
665 665
 			</p>',
666
-			esc_attr( $this->id ),
667
-			esc_html__( 'Save payment method', 'invoicing' )
666
+			esc_attr($this->id),
667
+			esc_html__('Save payment method', 'invoicing')
668 668
 		);
669 669
 
670 670
 	}
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 	 *
675 675
 	 * @return array
676 676
 	 */
677
-	public function register_gateway( $gateways ) {
677
+	public function register_gateway($gateways) {
678 678
 
679
-		$gateways[ $this->id ] = array(
679
+		$gateways[$this->id] = array(
680 680
 
681 681
 			'admin_label'    => $this->method_title,
682 682
             'checkout_label' => $this->title,
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
695 695
 	 * @return bool
696 696
 	 */
697
-	public function is_sandbox( $invoice = null ) {
697
+	public function is_sandbox($invoice = null) {
698 698
 
699
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
699
+		if (!empty($invoice) && !$invoice->needs_payment()) {
700 700
 			return $invoice->get_mode() == 'test';
701 701
 		}
702 702
 
703
-		return wpinv_is_test_mode( $this->id );
703
+		return wpinv_is_test_mode($this->id);
704 704
 
705 705
 	}
706 706
 
@@ -718,15 +718,15 @@  discard block
 block discarded – undo
718 718
 	 *
719 719
 	 * @return bool
720 720
 	 */
721
-	public function validate_currency( $validation, $currency ) {
721
+	public function validate_currency($validation, $currency) {
722 722
 
723 723
 		// Required currencies.
724
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
724
+		if (!empty($this->currencies) && !in_array($currency, $this->currencies)) {
725 725
 			return false;
726 726
 		}
727 727
 
728 728
 		// Excluded currencies.
729
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
729
+		if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) {
730 730
 			return false;
731 731
 		}
732 732
 
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_complete.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-renewal_reminder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print invoice details.
22
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print invoice items.
25
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
26 26
 
27 27
 // Print the billing details.
28
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
28
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
29 29
 
30 30
 // Print the email footer.
31
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
31
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_trial.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_expired.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
templates/emails/wpinv-email-subscription_cancelled.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  * @var WPInv_Subscription $object
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $invoice = $object->get_parent_payment();
14 14
 
15 15
 // Print the email header.
16
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
17 17
 
18 18
 // Generate the custom message body.
19 19
 echo $message_body;
20 20
 
21 21
 // Print the billing details.
22
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
22
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
23 23
 
24 24
 // Print the email footer.
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
25
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
Please login to merge, or discard this patch.
includes/wpinv-payment-functions.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
  */
230 230
 function wpinv_send_back_to_checkout() {
231 231
 
232
-	// Do we have any errors?
232
+    // Do we have any errors?
233 233
     if ( wpinv_get_errors() ) {
234 234
         wp_send_json_error( getpaid_get_errors_html( true, false ) );
235 235
     }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,155 +1,155 @@  discard block
 block discarded – undo
1 1
 <?php
2
-function wpinv_is_subscription_payment( $invoice = '' ) {
3
-    if ( empty( $invoice ) ) {
2
+function wpinv_is_subscription_payment($invoice = '') {
3
+    if (empty($invoice)) {
4 4
         return false;
5 5
     }
6 6
     
7
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
8
-        $invoice = wpinv_get_invoice( $invoice );
7
+    if (!is_object($invoice) && is_scalar($invoice)) {
8
+        $invoice = wpinv_get_invoice($invoice);
9 9
     }
10 10
     
11
-    if ( empty( $invoice ) ) {
11
+    if (empty($invoice)) {
12 12
         return false;
13 13
     }
14 14
         
15
-    if ( $invoice->is_renewal() ) {
15
+    if ($invoice->is_renewal()) {
16 16
         return true;
17 17
     }
18 18
 
19 19
     return false;
20 20
 }
21 21
 
22
-function wpinv_payment_link_transaction_id( $invoice = '' ) {
23
-    if ( empty( $invoice ) ) {
22
+function wpinv_payment_link_transaction_id($invoice = '') {
23
+    if (empty($invoice)) {
24 24
         return false;
25 25
     }
26 26
     
27
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
28
-        $invoice = wpinv_get_invoice( $invoice );
27
+    if (!is_object($invoice) && is_scalar($invoice)) {
28
+        $invoice = wpinv_get_invoice($invoice);
29 29
     }
30 30
     
31
-    if ( empty( $invoice ) ) {
31
+    if (empty($invoice)) {
32 32
         return false;
33 33
     }
34 34
 
35
-    return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
35
+    return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice);
36 36
 }
37 37
 
38
-function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
39
-    $interval   = (int)$interval > 0 ? (int)$interval : 1;
38
+function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) {
39
+    $interval   = (int) $interval > 0 ? (int) $interval : 1;
40 40
     
41
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
42
-        $amount = __( 'Free', 'invoicing' );
41
+    if ($trial_interval > 0 && !empty($trial_period)) {
42
+        $amount = __('Free', 'invoicing');
43 43
         $interval = $trial_interval;
44 44
         $period = $trial_period;
45 45
     }
46 46
     
47 47
     $description = '';
48
-    switch ( $period ) {
48
+    switch ($period) {
49 49
         case 'D' :
50 50
         case 'day' :
51
-            $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval );
51
+            $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval);
52 52
             break;
53 53
         case 'W' :
54 54
         case 'week' :
55
-            $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval );
55
+            $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval);
56 56
             break;
57 57
         case 'M' :
58 58
         case 'month' :
59
-            $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval );
59
+            $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval);
60 60
             break;
61 61
         case 'Y' :
62 62
         case 'year' :
63
-            $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval );
63
+            $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval);
64 64
             break;
65 65
     }
66 66
 
67
-    return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval  );
67
+    return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval);
68 68
 }
69 69
 
70
-function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
71
-    $interval   = (int)$interval > 0 ? (int)$interval : 1;
72
-    $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
70
+function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) {
71
+    $interval   = (int) $interval > 0 ? (int) $interval : 1;
72
+    $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0;
73 73
     
74 74
     $description = '';
75
-    switch ( $period ) {
75
+    switch ($period) {
76 76
         case 'D' :
77 77
         case 'day' :            
78
-            if ( (int)$bill_times > 0 ) {
79
-                if ( $interval > 1 ) {
80
-                    if ( $bill_times > 1 ) {
81
-                        $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
78
+            if ((int) $bill_times > 0) {
79
+                if ($interval > 1) {
80
+                    if ($bill_times > 1) {
81
+                        $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
82 82
                     } else {
83
-                        $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval );
83
+                        $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval);
84 84
                     }
85 85
                 } else {
86
-                    $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
86
+                    $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
87 87
                 }
88 88
             } else {
89
-                $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval );
89
+                $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval);
90 90
             }
91 91
             break;
92 92
         case 'W' :
93 93
         case 'week' :            
94
-            if ( (int)$bill_times > 0 ) {
95
-                if ( $interval > 1 ) {
96
-                    if ( $bill_times > 1 ) {
97
-                        $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
94
+            if ((int) $bill_times > 0) {
95
+                if ($interval > 1) {
96
+                    if ($bill_times > 1) {
97
+                        $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
98 98
                     } else {
99
-                        $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval );
99
+                        $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval);
100 100
                     }
101 101
                 } else {
102
-                    $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
102
+                    $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
103 103
                 }
104 104
             } else {
105
-                $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval );
105
+                $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval);
106 106
             }
107 107
             break;
108 108
         case 'M' :
109 109
         case 'month' :            
110
-            if ( (int)$bill_times > 0 ) {
111
-                if ( $interval > 1 ) {
112
-                    if ( $bill_times > 1 ) {
113
-                        $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
110
+            if ((int) $bill_times > 0) {
111
+                if ($interval > 1) {
112
+                    if ($bill_times > 1) {
113
+                        $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
114 114
                     } else {
115
-                        $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval );
115
+                        $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval);
116 116
                     }
117 117
                 } else {
118
-                    $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
118
+                    $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
119 119
                 }
120 120
             } else {
121
-                $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval );
121
+                $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval);
122 122
             }
123 123
             break;
124 124
         case 'Y' :
125 125
         case 'year' :            
126
-            if ( (int)$bill_times > 0 ) {
127
-                if ( $interval > 1 ) {
128
-                    if ( $bill_times > 1 ) {
129
-                        $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
126
+            if ((int) $bill_times > 0) {
127
+                if ($interval > 1) {
128
+                    if ($bill_times > 1) {
129
+                        $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
130 130
                     } else {
131
-                        $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval );
131
+                        $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval);
132 132
                     }
133 133
                 } else {
134
-                    $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
134
+                    $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
135 135
                 }
136 136
             } else {
137
-                $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval );
137
+                $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval);
138 138
             }
139 139
             break;
140 140
     }
141 141
 
142
-    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
142
+    return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
143 143
 }
144 144
 
145
-function wpinv_subscription_payment_desc( $invoice ) {
146
-    if ( empty( $invoice ) ) {
145
+function wpinv_subscription_payment_desc($invoice) {
146
+    if (empty($invoice)) {
147 147
         return NULL;
148 148
     }
149 149
 
150 150
     $description = '';
151
-    if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
152
-        if ( $item->has_free_trial() ) {
151
+    if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) {
152
+        if ($item->has_free_trial()) {
153 153
             $trial_period = $item->get_trial_period();
154 154
             $trial_interval = $item->get_trial_interval();
155 155
         } else {
@@ -157,40 +157,40 @@  discard block
 block discarded – undo
157 157
             $trial_interval = 0;
158 158
         }
159 159
         
160
-        $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
160
+        $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency());
161 161
     }
162 162
     
163
-    return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
163
+    return apply_filters('wpinv_subscription_payment_desc', $description, $invoice);
164 164
 }
165 165
 
166
-function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
167
-    $initial_total      = wpinv_round_amount( $initial );
168
-    $recurring_total    = wpinv_round_amount( $recurring );
166
+function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') {
167
+    $initial_total      = wpinv_round_amount($initial);
168
+    $recurring_total    = wpinv_round_amount($recurring);
169 169
     
170
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
170
+    if ($trial_interval > 0 && !empty($trial_period)) {
171 171
         // Free trial
172 172
     } else {
173
-        if ( $bill_times == 1 ) {
173
+        if ($bill_times == 1) {
174 174
             $recurring_total = $initial_total;
175
-        } else if ( $bill_times > 1 && $initial_total != $recurring_total ) {
175
+        } else if ($bill_times > 1 && $initial_total != $recurring_total) {
176 176
             $bill_times--;
177 177
         }
178 178
     }
179 179
     
180
-    $initial_amount     = wpinv_price( wpinv_format_amount( $initial_total ), $currency );
181
-    $recurring_amount   = wpinv_price( wpinv_format_amount( $recurring_total ), $currency );
180
+    $initial_amount     = wpinv_price(wpinv_format_amount($initial_total), $currency);
181
+    $recurring_amount   = wpinv_price(wpinv_format_amount($recurring_total), $currency);
182 182
     
183
-    $recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
183
+    $recurring          = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
184 184
         
185
-    if ( $initial_total != $recurring_total ) {
186
-        $initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
185
+    if ($initial_total != $recurring_total) {
186
+        $initial        = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval);
187 187
         
188
-        $description    = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring );
188
+        $description    = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring);
189 189
     } else {
190 190
         $description    = $recurring;
191 191
     }
192 192
     
193
-    return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
193
+    return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency);
194 194
 }
195 195
 
196 196
 /**
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  * @param string $card_number Card number.
201 201
  * @return string
202 202
  */
203
-function getpaid_get_card_name( $card_number ) {
203
+function getpaid_get_card_name($card_number) {
204 204
 
205 205
     // Known regexes.
206 206
     $regexes = array(
207
-        '/^4/'                     => __( 'Visa', 'invoicing' ),
208
-        '/^5[1-5]/'                => __( 'Mastercard', 'invoicing' ),
209
-        '/^3[47]/'                 => __( 'Amex', 'invoicing' ),
210
-        '/^3(?:0[0-5]|[68])/'      => __( 'Diners Club', 'invoicing' ),
211
-        '/^6(?:011|5)/'            => __( 'Discover', 'invoicing' ),
212
-        '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ),
207
+        '/^4/'                     => __('Visa', 'invoicing'),
208
+        '/^5[1-5]/'                => __('Mastercard', 'invoicing'),
209
+        '/^3[47]/'                 => __('Amex', 'invoicing'),
210
+        '/^3(?:0[0-5]|[68])/'      => __('Diners Club', 'invoicing'),
211
+        '/^6(?:011|5)/'            => __('Discover', 'invoicing'),
212
+        '/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'),
213 213
     );
214 214
 
215 215
     // Confirm if one matches.
216
-    foreach ( $regexes as $regex => $card ) {
217
-        if ( preg_match ( $regex, $card_number ) >= 1 ) {
216
+    foreach ($regexes as $regex => $card) {
217
+        if (preg_match($regex, $card_number) >= 1) {
218 218
             return $card;
219 219
         }
220 220
     }
221 221
 
222 222
     // None matched.
223
-    return __( 'Card', 'invoicing' );
223
+    return __('Card', 'invoicing');
224 224
 
225 225
 }
226 226
 
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 function wpinv_send_back_to_checkout() {
231 231
 
232 232
 	// Do we have any errors?
233
-    if ( wpinv_get_errors() ) {
234
-        wp_send_json_error( getpaid_get_errors_html( true, false ) );
233
+    if (wpinv_get_errors()) {
234
+        wp_send_json_error(getpaid_get_errors_html(true, false));
235 235
     }
236 236
 
237
-    wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
237
+    wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
238 238
 }
Please login to merge, or discard this patch.
templates/invoice-receipt.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,55 +7,55 @@  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
-$invoice = new WPInv_Invoice( $invoice );
13
+$invoice = new WPInv_Invoice($invoice);
14 14
 
15 15
 // @deprecated
16
-do_action( 'wpinv_success_content_before', $invoice );
17
-do_action( 'wpinv_before_receipt', $invoice );
16
+do_action('wpinv_success_content_before', $invoice);
17
+do_action('wpinv_before_receipt', $invoice);
18 18
 
19 19
 wpinv_print_errors();
20 20
 
21 21
 // Prepare header text.
22
-if ( $invoice->is_paid() ) {
22
+if ($invoice->is_paid()) {
23 23
 
24 24
     $alert = aui()->alert(
25 25
         array(
26 26
             'type'    => 'success',
27
-            'content' => __( 'Thank you for your payment!', 'invoicing' ),
27
+            'content' => __('Thank you for your payment!', 'invoicing'),
28 28
         )
29 29
     );
30 30
 
31
-} else if ( $invoice->is_refunded() ) {
31
+} else if ($invoice->is_refunded()) {
32 32
 
33 33
     $alert = aui()->alert(
34 34
         array(
35 35
             'type'    => 'info',
36
-            'content' => __( 'This invoice was refunded.', 'invoicing' ),
36
+            'content' => __('This invoice was refunded.', 'invoicing'),
37 37
         )
38 38
     );
39 39
 
40
-} else if ( $invoice->is_held() ) {
40
+} else if ($invoice->is_held()) {
41 41
 
42 42
     $alert = aui()->alert(
43 43
         array(
44 44
             'type'    => 'info',
45
-            'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ),
45
+            'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'),
46 46
         )
47 47
     );
48 48
 
49
-} else if ( $invoice->needs_payment() ) {
49
+} else if ($invoice->needs_payment()) {
50 50
 
51
-    if ( $invoice->is_due() ) {
51
+    if ($invoice->is_due()) {
52 52
 
53 53
         $alert = aui()->alert(
54 54
             array(
55 55
                 'type'    => 'danger',
56 56
                 'content' => sprintf(
57
-                    __( 'This invoice was due on %.', 'invoicing' ),
58
-                    getpaid_format_date_value( $invoice->get_due_date() )
57
+                    __('This invoice was due on %.', 'invoicing'),
58
+                    getpaid_format_date_value($invoice->get_due_date())
59 59
                 ),
60 60
             )
61 61
         );
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $alert = aui()->alert(
66 66
             array(
67 67
                 'type'    => 'warning',
68
-                'content' => __( 'This invoice needs payment.', 'invoicing' ),
68
+                'content' => __('This invoice needs payment.', 'invoicing'),
69 69
             )
70 70
         );
71 71
 
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 
81 81
         'pay' => array(
82 82
             'url'   => $invoice->get_checkout_payment_url(),
83
-            'name'  => __( 'Pay For Invoice', 'invoicing' ),
83
+            'name'  => __('Pay For Invoice', 'invoicing'),
84 84
             'class' => 'btn-success',
85 85
         ),
86 86
 
87 87
         'view' => array(
88 88
             'url'   => $invoice->get_view_url(),
89
-            'name'  => __( 'View Invoice', 'invoicing' ),
89
+            'name'  => __('View Invoice', 'invoicing'),
90 90
             'class' => 'btn-primary',
91 91
         ),
92 92
 
93 93
         'history' => array(
94 94
             'url'   => wpinv_get_history_page_uri(),
95
-            'name'  => __( 'Invoice History', 'invoicing' ),
95
+            'name'  => __('Invoice History', 'invoicing'),
96 96
             'class' => 'btn-warning',
97 97
         ),
98 98
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 
102 102
 );
103 103
 
104
-if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) {
105
-    unset( $actions['pay'] );
104
+if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) {
105
+    unset($actions['pay']);
106 106
 }
107 107
 
108
-if ( ! is_user_logged_in() && isset( $actions['history'] ) ) {
109
-    unset( $actions['history'] );
108
+if (!is_user_logged_in() && isset($actions['history'])) {
109
+    unset($actions['history']);
110 110
 }
111 111
 
112 112
 ?>
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 
116 116
         <?php
117 117
         
118
-            do_action( 'wpinv_receipt_start', $invoice );
118
+            do_action('wpinv_receipt_start', $invoice);
119 119
 
120
-            if ( ! empty( $actions ) ) {
120
+            if (!empty($actions)) {
121 121
 
122 122
                 echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">';
123 123
 
124
-                foreach ( $actions as $key => $action ) {
124
+                foreach ($actions as $key => $action) {
125 125
 
126
-                    $key    = sanitize_html_class( $key );
127
-                    $class  = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] );
128
-                    $url    = empty( $action['url'] ) ? '#' : esc_url( $action['url'] );
129
-                    $attrs  = empty( $action['attrs'] ) ? '' : $action['attrs'];
130
-                    $anchor = sanitize_text_field( $action['name'] );
126
+                    $key    = sanitize_html_class($key);
127
+                    $class  = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']);
128
+                    $url    = empty($action['url']) ? '#' : esc_url($action['url']);
129
+                    $attrs  = empty($action['attrs']) ? '' : $action['attrs'];
130
+                    $anchor = sanitize_text_field($action['name']);
131 131
 
132 132
                     echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>";
133 133
                 }
@@ -143,20 +143,20 @@  discard block
 block discarded – undo
143 143
         <div class="wpinv-receipt-details">
144 144
 
145 145
             <h4 class="wpinv-details-t mb-3 mt-3">
146
-                <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?>
146
+                <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?>
147 147
             </h4>
148 148
 
149
-            <?php getpaid_invoice_meta( $invoice ); ?>
149
+            <?php getpaid_invoice_meta($invoice); ?>
150 150
 
151 151
         </div>
152 152
 
153 153
 
154
-        <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
154
+        <?php do_action('wpinv_receipt_end', $invoice); ?>
155 155
 
156 156
     </div>
157 157
 
158 158
 <?php
159 159
 
160 160
 // @deprecated
161
-do_action( 'wpinv_success_content_after', $invoice );
162
-do_action( 'wpinv_after_receipt', $invoice );
161
+do_action('wpinv_success_content_after', $invoice);
162
+do_action('wpinv_after_receipt', $invoice);
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 2 patches
Indentation   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -12,431 +12,431 @@
 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' );
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' );
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'] );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'] );
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' );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'] );
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' );
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() );
95
-				return $invoice;
96
-			}
97
-
98
-		}
99
-
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.' );
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' );
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' );
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' );
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'] );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'] );
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' );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'] );
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' );
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() );
95
+                return $invoice;
96
+            }
97
+
98
+        }
99
+
100
+        wpinv_error_log( 'Could not retrieve the associated invoice.' );
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' );
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' );
207
-	}
206
+        wpinv_error_log( 'Validated PayPal Email' );
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'] );
240
-		}
239
+            return wpinv_error_log( $posted['reason_code'] );
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.' );
247
-			}
245
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
246
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.' );
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 = '';
252
-
253
-			if ( ! empty( $posted['mc_fee'] ) ) {
254
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
-			}
251
+            $note = '';
252
+
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.' );
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.' );
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".' );
273
-		}
272
+            return wpinv_error_log( 'Invoice marked as "payment held".' );
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' );
298
+        wpinv_error_log( 'Processing subscription signup' );
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' );
305
-		}
303
+        if ( empty( $subscription ) ) {
304
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
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.' );
330
-	}
329
+        wpinv_error_log( 'Subscription started.' );
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' );
345
-		}
343
+        if ( empty( $subscription ) ) {
344
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
345
+        }
346 346
 
347
-		// Abort if this is the first payment.
348
-		if ( date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
349
-			$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
350
-			$invoice->save();
351
-			return;
352
-		}
353
-
354
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id() );
347
+        // Abort if this is the first payment.
348
+        if ( date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
349
+            $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
350
+            $invoice->save();
351
+            return;
352
+        }
353
+
354
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id() );
355 355
 
356
-		// Abort if the payment is already recorded.
357
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
358
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed' );
359
-		}
356
+        // Abort if the payment is already recorded.
357
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
358
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed' );
359
+        }
360 360
 
361
-		$args = array(
362
-			'transaction_id' => $posted['txn_id'],
363
-			'gateway'        => $this->id,
364
-		);
365
-
366
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
367
-
368
-		if ( empty( $invoice ) ) {
369
-			return;
370
-		}
371
-
372
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
373
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
374
-
375
-		$subscription->renew();
376
-		wpinv_error_log( 'Subscription renewed.' );
377
-
378
-	}
379
-
380
-	/**
381
-	 * Handles subscription cancelations.
382
-	 *
383
-	 * @param WPInv_Invoice $invoice  Invoice object.
384
-	 */
385
-	protected function ipn_txn_subscr_cancel( $invoice ) {
386
-
387
-		// Make sure the invoice has a subscription.
388
-		$subscription = wpinv_get_subscription( $invoice );
389
-
390
-		if ( empty( $subscription ) ) {
391
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
392
-		}
393
-
394
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id() );
395
-		$subscription->cancel();
396
-		wpinv_error_log( 'Subscription cancelled.' );
361
+        $args = array(
362
+            'transaction_id' => $posted['txn_id'],
363
+            'gateway'        => $this->id,
364
+        );
365
+
366
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
367
+
368
+        if ( empty( $invoice ) ) {
369
+            return;
370
+        }
371
+
372
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
373
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
374
+
375
+        $subscription->renew();
376
+        wpinv_error_log( 'Subscription renewed.' );
377
+
378
+    }
379
+
380
+    /**
381
+     * Handles subscription cancelations.
382
+     *
383
+     * @param WPInv_Invoice $invoice  Invoice object.
384
+     */
385
+    protected function ipn_txn_subscr_cancel( $invoice ) {
386
+
387
+        // Make sure the invoice has a subscription.
388
+        $subscription = wpinv_get_subscription( $invoice );
389
+
390
+        if ( empty( $subscription ) ) {
391
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
392
+        }
393
+
394
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id() );
395
+        $subscription->cancel();
396
+        wpinv_error_log( 'Subscription cancelled.' );
397 397
 
398
-	}
398
+    }
399 399
 
400
-	/**
401
-	 * Handles subscription completions.
402
-	 *
403
-	 * @param WPInv_Invoice $invoice  Invoice object.
404
-	 * @param array    $posted Posted data.
405
-	 */
406
-	protected function ipn_txn_subscr_eot( $invoice ) {
407
-
408
-		// Make sure the invoice has a subscription.
409
-		$subscription = wpinv_get_subscription( $invoice );
400
+    /**
401
+     * Handles subscription completions.
402
+     *
403
+     * @param WPInv_Invoice $invoice  Invoice object.
404
+     * @param array    $posted Posted data.
405
+     */
406
+    protected function ipn_txn_subscr_eot( $invoice ) {
407
+
408
+        // Make sure the invoice has a subscription.
409
+        $subscription = wpinv_get_subscription( $invoice );
410 410
 
411
-		if ( empty( $subscription ) ) {
412
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
413
-		}
411
+        if ( empty( $subscription ) ) {
412
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
413
+        }
414 414
 
415
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id() );
416
-		$subscription->complete();
417
-		wpinv_error_log( 'Subscription completed.' );
415
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id() );
416
+        $subscription->complete();
417
+        wpinv_error_log( 'Subscription completed.' );
418 418
 
419
-	}
419
+    }
420 420
 
421
-	/**
422
-	 * Handles subscription fails.
423
-	 *
424
-	 * @param WPInv_Invoice $invoice  Invoice object.
425
-	 * @param array    $posted Posted data.
426
-	 */
427
-	protected function ipn_txn_subscr_failed( $invoice ) {
421
+    /**
422
+     * Handles subscription fails.
423
+     *
424
+     * @param WPInv_Invoice $invoice  Invoice object.
425
+     * @param array    $posted Posted data.
426
+     */
427
+    protected function ipn_txn_subscr_failed( $invoice ) {
428 428
 
429
-		// Make sure the invoice has a subscription.
430
-		$subscription = wpinv_get_subscription( $invoice );
429
+        // Make sure the invoice has a subscription.
430
+        $subscription = wpinv_get_subscription( $invoice );
431 431
 
432
-		if ( empty( $subscription ) ) {
433
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
434
-		}
432
+        if ( empty( $subscription ) ) {
433
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
434
+        }
435 435
 
436
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id() );
437
-		$subscription->failing();
438
-		wpinv_error_log( 'Subscription marked as failing.' );
436
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id() );
437
+        $subscription->failing();
438
+        wpinv_error_log( 'Subscription marked as failing.' );
439 439
 
440
-	}
440
+    }
441 441
 
442 442
 }
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 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' );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler');
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' );
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');
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'] );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'] );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status']);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type']);
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' );
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');
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'] );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type']);
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' );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice');
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() );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number());
95 95
 				return $invoice;
96 96
 			}
97 97
 
98 98
 		}
99 99
 
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.' );
101
-		wp_die( 'Could not retrieve the associated invoice.', 500 );
100
+		wpinv_error_log('Could not retrieve the associated invoice.');
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' );
109
+		wpinv_error_log('Validating PayPal IPN response');
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' );
206
+		wpinv_error_log('Validated PayPal Email');
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'] );
239
+			return wpinv_error_log($posted['reason_code']);
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.' );
245
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
246
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.');
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.' );
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.');
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".' );
272
+			return wpinv_error_log('Invoice marked as "payment held".');
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' );
298
+		wpinv_error_log('Processing subscription signup');
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' );
303
+		if (empty($subscription)) {
304
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
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.' );
329
+		wpinv_error_log('Subscription started.');
330 330
 	}
331 331
 
332 332
 	/**
@@ -335,27 +335,27 @@  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' );
343
+		if (empty($subscription)) {
344
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
345 345
 		}
346 346
 
347 347
 		// Abort if this is the first payment.
348
-		if ( date( 'Ynd', $subscription->get_time_created() ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
349
-			$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
348
+		if (date('Ynd', $subscription->get_time_created()) == date('Ynd', strtotime($posted['payment_date']))) {
349
+			$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));
350 350
 			$invoice->save();
351 351
 			return;
352 352
 		}
353 353
 
354
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id() );
354
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id());
355 355
 
356 356
 		// Abort if the payment is already recorded.
357
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
358
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed' );
357
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
358
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed');
359 359
 		}
360 360
 
361 361
 		$args = array(
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 			'gateway'        => $this->id,
364 364
 		);
365 365
 
366
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
366
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
367 367
 
368
-		if ( empty( $invoice ) ) {
368
+		if (empty($invoice)) {
369 369
 			return;
370 370
 		}
371 371
 
372
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
373
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
372
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
373
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
374 374
 
375 375
 		$subscription->renew();
376
-		wpinv_error_log( 'Subscription renewed.' );
376
+		wpinv_error_log('Subscription renewed.');
377 377
 
378 378
 	}
379 379
 
@@ -382,18 +382,18 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @param WPInv_Invoice $invoice  Invoice object.
384 384
 	 */
385
-	protected function ipn_txn_subscr_cancel( $invoice ) {
385
+	protected function ipn_txn_subscr_cancel($invoice) {
386 386
 
387 387
 		// Make sure the invoice has a subscription.
388
-		$subscription = wpinv_get_subscription( $invoice );
388
+		$subscription = wpinv_get_subscription($invoice);
389 389
 
390
-		if ( empty( $subscription ) ) {
391
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
390
+		if (empty($subscription)) {
391
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
392 392
 		}
393 393
 
394
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id() );
394
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id());
395 395
 		$subscription->cancel();
396
-		wpinv_error_log( 'Subscription cancelled.' );
396
+		wpinv_error_log('Subscription cancelled.');
397 397
 
398 398
 	}
399 399
 
@@ -403,18 +403,18 @@  discard block
 block discarded – undo
403 403
 	 * @param WPInv_Invoice $invoice  Invoice object.
404 404
 	 * @param array    $posted Posted data.
405 405
 	 */
406
-	protected function ipn_txn_subscr_eot( $invoice ) {
406
+	protected function ipn_txn_subscr_eot($invoice) {
407 407
 
408 408
 		// Make sure the invoice has a subscription.
409
-		$subscription = wpinv_get_subscription( $invoice );
409
+		$subscription = wpinv_get_subscription($invoice);
410 410
 
411
-		if ( empty( $subscription ) ) {
412
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
411
+		if (empty($subscription)) {
412
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
413 413
 		}
414 414
 
415
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id() );
415
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id());
416 416
 		$subscription->complete();
417
-		wpinv_error_log( 'Subscription completed.' );
417
+		wpinv_error_log('Subscription completed.');
418 418
 
419 419
 	}
420 420
 
@@ -424,18 +424,18 @@  discard block
 block discarded – undo
424 424
 	 * @param WPInv_Invoice $invoice  Invoice object.
425 425
 	 * @param array    $posted Posted data.
426 426
 	 */
427
-	protected function ipn_txn_subscr_failed( $invoice ) {
427
+	protected function ipn_txn_subscr_failed($invoice) {
428 428
 
429 429
 		// Make sure the invoice has a subscription.
430
-		$subscription = wpinv_get_subscription( $invoice );
430
+		$subscription = wpinv_get_subscription($invoice);
431 431
 
432
-		if ( empty( $subscription ) ) {
433
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
432
+		if (empty($subscription)) {
433
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
434 434
 		}
435 435
 
436
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id() );
436
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id());
437 437
 		$subscription->failing();
438
-		wpinv_error_log( 'Subscription marked as failing.' );
438
+		wpinv_error_log('Subscription marked as failing.');
439 439
 
440 440
 	}
441 441
 
Please login to merge, or discard this patch.