Passed
Push — master ( 4aba8a...3509e3 )
by Brian
13:31
created
templates/subscriptions/subscription-details.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -39,62 +39,62 @@  discard block
 block discarded – undo
39 39
 				<td style="width: 65%">
40 40
 					<?php
41 41
 
42
-						switch ( $key ) {
42
+                        switch ( $key ) {
43 43
 
44
-						case 'status':
45
-							echo esc_html( $subscription->get_status_label() );
46
-							break;
44
+                        case 'status':
45
+                            echo esc_html( $subscription->get_status_label() );
46
+                            break;
47 47
 
48
-						case 'start_date':
49
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
-							break;
48
+                        case 'start_date':
49
+                            echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
+                            break;
51 51
 
52
-						case 'expiry_date':
53
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
-							break;
52
+                        case 'expiry_date':
53
+                            echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
+                            break;
55 55
 
56
-						case 'initial_amount':
57
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
56
+                        case 'initial_amount':
57
+                            echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
58 58
 
59
-							if ( $subscription->has_trial_period() ) {
59
+                            if ( $subscription->has_trial_period() ) {
60 60
 
61
-								echo "<small class='text-muted'>&nbsp;";
62
-								printf(
63
-									esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
-									esc_html( $subscription->get_trial_period() )
65
-								);
66
-								echo '</small>';
61
+                                echo "<small class='text-muted'>&nbsp;";
62
+                                printf(
63
+                                    esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
+                                    esc_html( $subscription->get_trial_period() )
65
+                                );
66
+                                echo '</small>';
67 67
 
68
-							}
68
+                            }
69 69
 
70
-							break;
70
+                            break;
71 71
 
72
-						case 'recurring_amount':
73
-							$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
-							$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
-							echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
-							break;
72
+                        case 'recurring_amount':
73
+                            $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
+                            $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
+                            echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
+                            break;
77 77
 
78
-						case 'item':
79
-							if ( empty( $subscription_group ) ) {
80
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
-							} else {
82
-								$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
-								echo wp_kses_post( implode( ' | ', $markup ) );
84
-							}
78
+                        case 'item':
79
+                            if ( empty( $subscription_group ) ) {
80
+                                echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
+                            } else {
82
+                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
+                                echo wp_kses_post( implode( ' | ', $markup ) );
84
+                            }
85 85
 
86
-							break;
86
+                            break;
87 87
 
88
-						case 'payments':
89
-							$max_activations = (int) $subscription->get_bill_times();
90
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
88
+                        case 'payments':
89
+                            $max_activations = (int) $subscription->get_bill_times();
90
+                            echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
91 91
 
92
-							break;
92
+                            break;
93 93
 
94
-						}
95
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
94
+                        }
95
+                        do_action( "getpaid_render_single_subscription_column_$key", $subscription );
96 96
 
97
-					?>
97
+                    ?>
98 98
 				</td>
99 99
 
100 100
 			</tr>
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
 <span class="form-text">
122 122
 
123 123
 	<?php
124
-		if ( $subscription->can_cancel() ) {
125
-		printf(
124
+        if ( $subscription->can_cancel() ) {
125
+        printf(
126 126
             '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
127 127
             esc_url( $subscription->get_cancel_url() ),
128 128
             esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
129 129
             esc_html__( 'Cancel Subscription', 'invoicing' )
130 130
         );
131
-		}
131
+        }
132 132
 
133
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
134
-	?>
133
+        do_action( 'getpaid-single-subscription-page-actions', $subscription );
134
+    ?>
135 135
 
136 136
 	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></a>
137 137
 </span>
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 1 patch
Indentation   +396 added lines, -396 removed lines patch added patch discarded remove patch
@@ -12,478 +12,478 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-		}
98
-
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
101
-	}
102
-
103
-	/**
104
-	 * Check PayPal IPN validity.
105
-	 */
106
-	protected function validate_ipn() {
107
-
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
-
110
-		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
113
-
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
-		}
117
-
118
-		// Validate the IPN.
119
-		$posted['cmd'] = '_notify-validate';
120
-
121
-		// Send back post vars to paypal.
122
-		$params = array(
123
-			'body'        => $posted,
124
-			'timeout'     => 60,
125
-			'httpversion' => '1.1',
126
-			'compress'    => false,
127
-			'decompress'  => false,
128
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
-		);
130
-
131
-		// Post back to get a response.
132
-		$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
-
134
-		// Check to see if the request was valid.
135
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
-			$invoice->add_note( 'Received valid response from PayPal IPN: ' . $response['body'], false, false, true );
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
-			return true;
139
-		}
140
-
141
-		$invoice->add_note( 'IPN message:' . wp_json_encode( $posted ), false, false, true );
142
-
143
-		if ( is_wp_error( $response ) ) {
144
-			$invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response->get_error_message(), false, false, true );
145
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
146
-			return false;
147
-		}
148
-
149
-		$invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response['body'], false, false, true );
150
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
151
-		return false;
152
-
153
-	}
154
-
155
-	/**
156
-	 * Check currency from IPN matches the invoice.
157
-	 *
158
-	 * @param WPInv_Invoice $invoice          Invoice object.
159
-	 * @param string   $currency currency to validate.
160
-	 */
161
-	protected function validate_ipn_currency( $invoice, $currency ) {
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+        }
98
+
99
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
101
+    }
102
+
103
+    /**
104
+     * Check PayPal IPN validity.
105
+     */
106
+    protected function validate_ipn() {
107
+
108
+        wpinv_error_log( 'Validating PayPal IPN response', false );
109
+
110
+        // Retrieve the associated invoice.
111
+        $posted  = wp_unslash( $_POST );
112
+        $invoice = $this->get_ipn_invoice( $posted );
113
+
114
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
115
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
+        }
117
+
118
+        // Validate the IPN.
119
+        $posted['cmd'] = '_notify-validate';
120
+
121
+        // Send back post vars to paypal.
122
+        $params = array(
123
+            'body'        => $posted,
124
+            'timeout'     => 60,
125
+            'httpversion' => '1.1',
126
+            'compress'    => false,
127
+            'decompress'  => false,
128
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
+        );
130
+
131
+        // Post back to get a response.
132
+        $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
+
134
+        // Check to see if the request was valid.
135
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
+            $invoice->add_note( 'Received valid response from PayPal IPN: ' . $response['body'], false, false, true );
137
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
+            return true;
139
+        }
140
+
141
+        $invoice->add_note( 'IPN message:' . wp_json_encode( $posted ), false, false, true );
142
+
143
+        if ( is_wp_error( $response ) ) {
144
+            $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response->get_error_message(), false, false, true );
145
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
146
+            return false;
147
+        }
148
+
149
+        $invoice->add_note( 'Received invalid response from PayPal IPN: ' . $response['body'], false, false, true );
150
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
151
+        return false;
152
+
153
+    }
154
+
155
+    /**
156
+     * Check currency from IPN matches the invoice.
157
+     *
158
+     * @param WPInv_Invoice $invoice          Invoice object.
159
+     * @param string   $currency currency to validate.
160
+     */
161
+    protected function validate_ipn_currency( $invoice, $currency ) {
162 162
 
163
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
163
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
164 164
 
165
-			/* translators: %s: currency code. */
166
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
165
+            /* translators: %s: currency code. */
166
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
167 167
 
168
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
169
-		}
168
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
169
+        }
170 170
 
171
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
172
-	}
171
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
172
+    }
173 173
 
174
-	/**
175
-	 * Check payment amount from IPN matches the invoice.
176
-	 *
177
-	 * @param WPInv_Invoice $invoice          Invoice object.
178
-	 * @param float   $amount amount to validate.
179
-	 */
180
-	protected function validate_ipn_amount( $invoice, $amount ) {
181
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
174
+    /**
175
+     * Check payment amount from IPN matches the invoice.
176
+     *
177
+     * @param WPInv_Invoice $invoice          Invoice object.
178
+     * @param float   $amount amount to validate.
179
+     */
180
+    protected function validate_ipn_amount( $invoice, $amount ) {
181
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
182 182
 
183
-			/* translators: %s: Amount. */
184
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
183
+            /* translators: %s: Amount. */
184
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
185 185
 
186
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
187
-		}
186
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
187
+        }
188 188
 
189
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
190
-	}
189
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
190
+    }
191 191
 
192
-	/**
193
-	 * Verify receiver email from PayPal.
194
-	 *
195
-	 * @param WPInv_Invoice $invoice          Invoice object.
196
-	 * @param string   $receiver_email Email to validate.
197
-	 */
198
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
199
-		$paypal_email = wpinv_get_option( 'paypal_email' );
192
+    /**
193
+     * Verify receiver email from PayPal.
194
+     *
195
+     * @param WPInv_Invoice $invoice          Invoice object.
196
+     * @param string   $receiver_email Email to validate.
197
+     */
198
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
199
+        $paypal_email = wpinv_get_option( 'paypal_email' );
200 200
 
201
-		if ( $receiver_email && strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
202
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
201
+        if ( $receiver_email && strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
202
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
203 203
 
204
-			/* translators: %s: email address . */
205
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
204
+            /* translators: %s: email address . */
205
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
206 206
 
207
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
208
-		}
207
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
208
+        }
209 209
 
210
-		wpinv_error_log( 'Validated PayPal Email', false );
211
-	}
210
+        wpinv_error_log( 'Validated PayPal Email', false );
211
+    }
212 212
 
213
-	/**
214
-	 * Handles one time payments.
215
-	 *
216
-	 * @param WPInv_Invoice $invoice  Invoice object.
217
-	 * @param array    $posted Posted data.
218
-	 */
219
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
213
+    /**
214
+     * Handles one time payments.
215
+     *
216
+     * @param WPInv_Invoice $invoice  Invoice object.
217
+     * @param array    $posted Posted data.
218
+     */
219
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
220 220
 
221
-		// Collect payment details
222
-		$payment_status = strtolower( $posted['payment_status'] );
223
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
221
+        // Collect payment details
222
+        $payment_status = strtolower( $posted['payment_status'] );
223
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
224 224
 
225
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
226
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
225
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
226
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
227 227
 
228
-		// Update the transaction id.
229
-		if ( ! empty( $posted['txn_id'] ) ) {
230
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
231
-			$invoice->save();
232
-		}
228
+        // Update the transaction id.
229
+        if ( ! empty( $posted['txn_id'] ) ) {
230
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
231
+            $invoice->save();
232
+        }
233 233
 
234
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
234
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
235 235
 
236
-		// Process a refund.
237
-		if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) {
236
+        // Process a refund.
237
+        if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) {
238 238
 
239
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
239
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
240 240
 
241
-			if ( ! $invoice->is_refunded() ) {
242
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
243
-			}
241
+            if ( ! $invoice->is_refunded() ) {
242
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
243
+            }
244 244
 
245
-			return wpinv_error_log( $posted['reason_code'], false );
246
-		}
245
+            return wpinv_error_log( $posted['reason_code'], false );
246
+        }
247 247
 
248
-		// Process payments.
249
-		if ( 'completed' === $payment_status ) {
248
+        // Process payments.
249
+        if ( 'completed' === $payment_status ) {
250 250
 
251
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
252
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
253
-			}
251
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
252
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
253
+            }
254 254
 
255
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
255
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
256 256
 
257
-			$note = '';
257
+            $note = '';
258 258
 
259
-			if ( ! empty( $posted['mc_fee'] ) ) {
260
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
261
-			}
259
+            if ( ! empty( $posted['mc_fee'] ) ) {
260
+                $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
261
+            }
262 262
 
263
-			if ( ! empty( $posted['payer_status'] ) ) {
264
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
265
-			}
263
+            if ( ! empty( $posted['payer_status'] ) ) {
264
+                $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
265
+            }
266 266
 
267
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
268
-			return wpinv_error_log( 'Invoice marked as paid.', false );
267
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
268
+            return wpinv_error_log( 'Invoice marked as paid.', false );
269 269
 
270
-		}
270
+        }
271 271
 
272
-		// Pending payments.
273
-		if ( 'pending' === $payment_status ) {
272
+        // Pending payments.
273
+        if ( 'pending' === $payment_status ) {
274 274
 
275
-			/* translators: %s: pending reason. */
276
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
275
+            /* translators: %s: pending reason. */
276
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
277 277
 
278
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
279
-		}
278
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
279
+        }
280 280
 
281
-		/* translators: %s: payment status. */
282
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
281
+        /* translators: %s: payment status. */
282
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
283 283
 
284
-	}
284
+    }
285 285
 
286
-	/**
287
-	 * Handles one time payments.
288
-	 *
289
-	 * @param WPInv_Invoice $invoice  Invoice object.
290
-	 * @param array    $posted Posted data.
291
-	 */
292
-	protected function ipn_txn_cart( $invoice, $posted ) {
293
-		$this->ipn_txn_web_accept( $invoice, $posted );
294
-	}
286
+    /**
287
+     * Handles one time payments.
288
+     *
289
+     * @param WPInv_Invoice $invoice  Invoice object.
290
+     * @param array    $posted Posted data.
291
+     */
292
+    protected function ipn_txn_cart( $invoice, $posted ) {
293
+        $this->ipn_txn_web_accept( $invoice, $posted );
294
+    }
295 295
 
296
-	/**
297
-	 * Handles subscription sign ups.
298
-	 *
299
-	 * @param WPInv_Invoice $invoice  Invoice object.
300
-	 * @param array    $posted Posted data.
301
-	 */
302
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
296
+    /**
297
+     * Handles subscription sign ups.
298
+     *
299
+     * @param WPInv_Invoice $invoice  Invoice object.
300
+     * @param array    $posted Posted data.
301
+     */
302
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
303 303
 
304
-		wpinv_error_log( 'Processing subscription signup', false );
304
+        wpinv_error_log( 'Processing subscription signup', false );
305 305
 
306
-		// Make sure the invoice has a subscription.
307
-		$subscription = getpaid_get_invoice_subscription( $invoice );
306
+        // Make sure the invoice has a subscription.
307
+        $subscription = getpaid_get_invoice_subscription( $invoice );
308 308
 
309
-		if ( empty( $subscription ) ) {
310
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
311
-		}
309
+        if ( empty( $subscription ) ) {
310
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
311
+        }
312 312
 
313
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
313
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
314 314
 
315
-		// Validate the IPN.
316
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
317
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
318
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
315
+        // Validate the IPN.
316
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
317
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
318
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
319 319
 
320
-		// Activate the subscription.
321
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
322
-		$subscription->set_date_created( current_time( 'mysql' ) );
323
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
324
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
325
-		$subscription->activate();
320
+        // Activate the subscription.
321
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
322
+        $subscription->set_date_created( current_time( 'mysql' ) );
323
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
324
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
325
+        $subscription->activate();
326 326
 
327
-		// Set the transaction id.
328
-		if ( ! empty( $posted['txn_id'] ) ) {
329
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
330
-			$invoice->set_transaction_id( $posted['txn_id'] );
331
-		}
327
+        // Set the transaction id.
328
+        if ( ! empty( $posted['txn_id'] ) ) {
329
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
330
+            $invoice->set_transaction_id( $posted['txn_id'] );
331
+        }
332 332
 
333
-		// Update the payment status.
334
-		$invoice->mark_paid();
333
+        // Update the payment status.
334
+        $invoice->mark_paid();
335 335
 
336
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
336
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
337 337
 
338
-		wpinv_error_log( 'Subscription started.', false );
339
-	}
338
+        wpinv_error_log( 'Subscription started.', false );
339
+    }
340 340
 
341
-	/**
342
-	 * Handles subscription renewals.
343
-	 *
344
-	 * @param WPInv_Invoice $invoice  Invoice object.
345
-	 * @param array    $posted Posted data.
346
-	 */
347
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
341
+    /**
342
+     * Handles subscription renewals.
343
+     *
344
+     * @param WPInv_Invoice $invoice  Invoice object.
345
+     * @param array    $posted Posted data.
346
+     */
347
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
348 348
 
349
-		// Make sure the invoice has a subscription.
350
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
349
+        // Make sure the invoice has a subscription.
350
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
351 351
 
352
-		if ( empty( $subscription ) ) {
353
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
354
-		}
352
+        if ( empty( $subscription ) ) {
353
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
354
+        }
355 355
 
356
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
356
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
357 357
 
358
-		// PayPal sends a subscr_payment for the first payment too.
359
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
360
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
361
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
362
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
363
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
364
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
358
+        // PayPal sends a subscr_payment for the first payment too.
359
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
360
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
361
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
362
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
363
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
364
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
365 365
 
366
-		foreach ( $dates as $date ) {
366
+        foreach ( $dates as $date ) {
367 367
 
368
-			if ( $date !== $today_date && $date !== $payment_date ) {
369
-				continue;
370
-			}
368
+            if ( $date !== $today_date && $date !== $payment_date ) {
369
+                continue;
370
+            }
371 371
 
372
-			if ( ! empty( $posted['txn_id'] ) ) {
373
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
374
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
375
-			}
372
+            if ( ! empty( $posted['txn_id'] ) ) {
373
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
374
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
375
+            }
376 376
 
377
-			return $invoice->mark_paid();
378
-
379
-		}
377
+            return $invoice->mark_paid();
378
+
379
+        }
380 380
 
381
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
382
-
383
-		// Abort if the payment is already recorded.
384
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
385
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
386
-		}
387
-
388
-		$args = array(
389
-			'transaction_id' => $posted['txn_id'],
390
-			'gateway'        => $this->id,
391
-		);
392
-
393
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
381
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
382
+
383
+        // Abort if the payment is already recorded.
384
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
385
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
386
+        }
387
+
388
+        $args = array(
389
+            'transaction_id' => $posted['txn_id'],
390
+            'gateway'        => $this->id,
391
+        );
392
+
393
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
394 394
 
395
-		if ( empty( $invoice ) ) {
396
-			return;
397
-		}
395
+        if ( empty( $invoice ) ) {
396
+            return;
397
+        }
398 398
 
399
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
400
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
399
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
400
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
401 401
 
402
-		$subscription->renew();
403
-		wpinv_error_log( 'Subscription renewed.', false );
402
+        $subscription->renew();
403
+        wpinv_error_log( 'Subscription renewed.', false );
404 404
 
405
-	}
405
+    }
406 406
 
407
-	/**
408
-	 * Handles subscription cancelations.
409
-	 *
410
-	 * @param WPInv_Invoice $invoice  Invoice object.
411
-	 */
412
-	protected function ipn_txn_subscr_cancel( $invoice ) {
407
+    /**
408
+     * Handles subscription cancelations.
409
+     *
410
+     * @param WPInv_Invoice $invoice  Invoice object.
411
+     */
412
+    protected function ipn_txn_subscr_cancel( $invoice ) {
413 413
 
414
-		// Make sure the invoice has a subscription.
415
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
416
-
417
-		if ( empty( $subscription ) ) {
418
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
419
-		}
420
-
421
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
422
-		$subscription->cancel();
423
-		wpinv_error_log( 'Subscription cancelled.', false );
414
+        // Make sure the invoice has a subscription.
415
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
416
+
417
+        if ( empty( $subscription ) ) {
418
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
419
+        }
420
+
421
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
422
+        $subscription->cancel();
423
+        wpinv_error_log( 'Subscription cancelled.', false );
424 424
 
425
-	}
425
+    }
426 426
 
427
-	/**
428
-	 * Handles subscription completions.
429
-	 *
430
-	 * @param WPInv_Invoice $invoice  Invoice object.
431
-	 * @param array    $posted Posted data.
432
-	 */
433
-	protected function ipn_txn_subscr_eot( $invoice ) {
427
+    /**
428
+     * Handles subscription completions.
429
+     *
430
+     * @param WPInv_Invoice $invoice  Invoice object.
431
+     * @param array    $posted Posted data.
432
+     */
433
+    protected function ipn_txn_subscr_eot( $invoice ) {
434 434
 
435
-		// Make sure the invoice has a subscription.
436
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
435
+        // Make sure the invoice has a subscription.
436
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
437 437
 
438
-		if ( empty( $subscription ) ) {
439
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
440
-		}
438
+        if ( empty( $subscription ) ) {
439
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
440
+        }
441 441
 
442
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
443
-		$subscription->complete();
444
-		wpinv_error_log( 'Subscription completed.', false );
442
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
443
+        $subscription->complete();
444
+        wpinv_error_log( 'Subscription completed.', false );
445 445
 
446
-	}
446
+    }
447 447
 
448
-	/**
449
-	 * Handles subscription fails.
450
-	 *
451
-	 * @param WPInv_Invoice $invoice  Invoice object.
452
-	 * @param array    $posted Posted data.
453
-	 */
454
-	protected function ipn_txn_subscr_failed( $invoice ) {
448
+    /**
449
+     * Handles subscription fails.
450
+     *
451
+     * @param WPInv_Invoice $invoice  Invoice object.
452
+     * @param array    $posted Posted data.
453
+     */
454
+    protected function ipn_txn_subscr_failed( $invoice ) {
455 455
 
456
-		// Make sure the invoice has a subscription.
457
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
456
+        // Make sure the invoice has a subscription.
457
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
458 458
 
459
-		if ( empty( $subscription ) ) {
460
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
461
-		}
459
+        if ( empty( $subscription ) ) {
460
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
461
+        }
462 462
 
463
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
464
-		$subscription->failing();
465
-		wpinv_error_log( 'Subscription marked as failing.', false );
463
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
464
+        $subscription->failing();
465
+        wpinv_error_log( 'Subscription marked as failing.', false );
466 466
 
467
-	}
467
+    }
468 468
 
469
-	/**
470
-	 * Handles subscription suspensions.
471
-	 *
472
-	 * @param WPInv_Invoice $invoice  Invoice object.
473
-	 * @param array    $posted Posted data.
474
-	 */
475
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
469
+    /**
470
+     * Handles subscription suspensions.
471
+     *
472
+     * @param WPInv_Invoice $invoice  Invoice object.
473
+     * @param array    $posted Posted data.
474
+     */
475
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
476 476
 
477
-		// Make sure the invoice has a subscription.
478
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
477
+        // Make sure the invoice has a subscription.
478
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
479 479
 
480
-		if ( empty( $subscription ) ) {
481
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
482
-		}
483
-
484
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
485
-		$subscription->cancel();
486
-		wpinv_error_log( 'Subscription cancelled.', false );
487
-	}
480
+        if ( empty( $subscription ) ) {
481
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
482
+        }
483
+
484
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
485
+        $subscription->cancel();
486
+        wpinv_error_log( 'Subscription cancelled.', false );
487
+    }
488 488
 
489 489
 }
Please login to merge, or discard this patch.