Passed
Push — master ( 4aba8a...3509e3 )
by Brian
13:31
created
templates/subscriptions/subscription-details.php 3 patches
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.
Switch Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php
1
+    <?php
2 2
 
3 3
 /**
4 4
  * Template that prints a single subscription's details
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
  * @var WPInv_Subscriptions_Widget $widget
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+    defined( 'ABSPATH' ) || exit;
14 14
 
15
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
15
+    do_action( 'getpaid_single_subscription_before_notices', $subscription );
16 16
 
17
-// Display errors and notices.
18
-wpinv_print_errors();
17
+    // Display errors and notices.
18
+    wpinv_print_errors();
19 19
 
20
-$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
-$subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
20
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
+    $subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
22 22
 
23
-do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
23
+    do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
24 24
 
25
-?>
25
+    ?>
26 26
 
27 27
 <h2 class="mb-1 h4"><?php esc_html_e( 'Subscription Details', 'invoicing' ); ?></h2>
28 28
 <table class="table table-bordered">
@@ -39,59 +39,59 @@  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
-						}
94
+						    }
95 95
 						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
96 96
 
97 97
 					?>
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,58 +10,58 @@  discard block
 block discarded – undo
10 10
  * @var WPInv_Subscriptions_Widget $widget
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
15
+do_action('getpaid_single_subscription_before_notices', $subscription);
16 16
 
17 17
 // Display errors and notices.
18 18
 wpinv_print_errors();
19 19
 
20
-$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
-$subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
20
+$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id());
21
+$subscription_group  = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id());
22 22
 
23
-do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
23
+do_action('getpaid_before_single_subscription', $subscription, $subscription_groups);
24 24
 
25 25
 ?>
26 26
 
27
-<h2 class="mb-1 h4"><?php esc_html_e( 'Subscription Details', 'invoicing' ); ?></h2>
27
+<h2 class="mb-1 h4"><?php esc_html_e('Subscription Details', 'invoicing'); ?></h2>
28 28
 <table class="table table-bordered">
29 29
 	<tbody>
30 30
 
31
-		<?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?>
31
+		<?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?>
32 32
 
33
-			<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
33
+			<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
34 34
 
35 35
 				<th class="font-weight-bold" style="width: 35%">
36
-					<?php echo esc_html( $label ); ?>
36
+					<?php echo esc_html($label); ?>
37 37
 				</th>
38 38
 
39 39
 				<td style="width: 65%">
40 40
 					<?php
41 41
 
42
-						switch ( $key ) {
42
+						switch ($key) {
43 43
 
44 44
 						case 'status':
45
-							echo esc_html( $subscription->get_status_label() );
45
+							echo esc_html($subscription->get_status_label());
46 46
 							break;
47 47
 
48 48
 						case 'start_date':
49
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
49
+							echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
50 50
 							break;
51 51
 
52 52
 						case 'expiry_date':
53
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
53
+							echo esc_html(getpaid_format_date_value($subscription->get_next_renewal_date()));
54 54
 							break;
55 55
 
56 56
 						case 'initial_amount':
57
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
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 61
 								echo "<small class='text-muted'>&nbsp;";
62 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() )
63
+									esc_html_x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'),
64
+									esc_html($subscription->get_trial_period())
65 65
 								);
66 66
 								echo '</small>';
67 67
 
@@ -70,29 +70,29 @@  discard block
 block discarded – undo
70 70
 							break;
71 71
 
72 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>" ) );
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 76
 							break;
77 77
 
78 78
 						case 'item':
79
-							if ( empty( $subscription_group ) ) {
80
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
79
+							if (empty($subscription_group)) {
80
+								echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
81 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 ) );
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 84
 							}
85 85
 
86 86
 							break;
87 87
 
88 88
 						case 'payments':
89 89
 							$max_activations = (int) $subscription->get_bill_times();
90
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
90
+							echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_activations) ? '&infin;' : (int) $max_activations);
91 91
 
92 92
 							break;
93 93
 
94 94
 						}
95
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
95
+						do_action("getpaid_render_single_subscription_column_$key", $subscription);
96 96
 
97 97
 					?>
98 98
 				</td>
@@ -104,34 +104,34 @@  discard block
 block discarded – undo
104 104
 	</tbody>
105 105
 </table>
106 106
 
107
-<?php if ( ! empty( $subscription_group ) ) : ?>
108
-	<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Subscription Items', 'invoicing' ); ?></h2>
109
-	<?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?>
107
+<?php if (!empty($subscription_group)) : ?>
108
+	<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Subscription Items', 'invoicing'); ?></h2>
109
+	<?php getpaid_admin_subscription_item_details_metabox($subscription); ?>
110 110
 <?php endif; ?>
111 111
 
112
-<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Invoices', 'invoicing' ); ?></h2>
112
+<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Invoices', 'invoicing'); ?></h2>
113 113
 
114
-<?php echo wp_kses_post( getpaid_admin_subscription_invoice_details_metabox( $subscription ) ); ?>
114
+<?php echo wp_kses_post(getpaid_admin_subscription_invoice_details_metabox($subscription)); ?>
115 115
 
116
-<?php if ( 1 < count( $subscription_groups ) ) : ?>
117
-	<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Subscriptions', 'invoicing' ); ?></h2>
118
-	<?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?>
116
+<?php if (1 < count($subscription_groups)) : ?>
117
+	<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Subscriptions', 'invoicing'); ?></h2>
118
+	<?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?>
119 119
 <?php endif; ?>
120 120
 
121 121
 <span class="form-text">
122 122
 
123 123
 	<?php
124
-		if ( $subscription->can_cancel() ) {
124
+		if ($subscription->can_cancel()) {
125 125
 		printf(
126 126
             '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
127
-            esc_url( $subscription->get_cancel_url() ),
128
-            esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
129
-            esc_html__( 'Cancel Subscription', 'invoicing' )
127
+            esc_url($subscription->get_cancel_url()),
128
+            esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'),
129
+            esc_html__('Cancel Subscription', 'invoicing')
130 130
         );
131 131
 		}
132 132
 
133
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
133
+		do_action('getpaid-single-subscription-page-actions', $subscription);
134 134
 	?>
135 135
 
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>
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 2 patches
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.
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
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 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 		}
98 98
 
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
99
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
100
+		wp_die('Could not retrieve the associated invoice.', 200);
101 101
 	}
102 102
 
103 103
 	/**
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	protected function validate_ipn() {
107 107
 
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
108
+		wpinv_error_log('Validating PayPal IPN response', false);
109 109
 
110 110
 		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
111
+		$posted  = wp_unslash($_POST);
112
+		$invoice = $this->get_ipn_invoice($posted);
113 113
 
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
114
+		if ($this->gateway->is_sandbox($invoice)) {
115
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
116 116
 		}
117 117
 
118 118
 		// Validate the IPN.
@@ -129,25 +129,25 @@  discard block
 block discarded – undo
129 129
 		);
130 130
 
131 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 );
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 133
 
134 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 );
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 138
 			return true;
139 139
 		}
140 140
 
141
-		$invoice->add_note( 'IPN message:' . wp_json_encode( $posted ), false, false, true );
141
+		$invoice->add_note('IPN message:' . wp_json_encode($posted), false, false, true);
142 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' );
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 146
 			return false;
147 147
 		}
148 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' );
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 151
 		return false;
152 152
 
153 153
 	}
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 	 * @param WPInv_Invoice $invoice          Invoice object.
159 159
 	 * @param string   $currency currency to validate.
160 160
 	 */
161
-	protected function validate_ipn_currency( $invoice, $currency ) {
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 165
 			/* translators: %s: currency code. */
166
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
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 );
168
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
169 169
 		}
170 170
 
171
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
171
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
172 172
 	}
173 173
 
174 174
 	/**
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	 * @param WPInv_Invoice $invoice          Invoice object.
178 178
 	 * @param float   $amount amount to validate.
179 179
 	 */
180
-	protected function validate_ipn_amount( $invoice, $amount ) {
181
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
180
+	protected function validate_ipn_amount($invoice, $amount) {
181
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
182 182
 
183 183
 			/* translators: %s: Amount. */
184
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $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 );
186
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
187 187
 		}
188 188
 
189
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
189
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
190 190
 	}
191 191
 
192 192
 	/**
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
 	 * @param WPInv_Invoice $invoice          Invoice object.
196 196
 	 * @param string   $receiver_email Email to validate.
197 197
 	 */
198
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
199
-		$paypal_email = wpinv_get_option( 'paypal_email' );
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 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 ) );
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 );
207
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
208 208
 		}
209 209
 
210
-		wpinv_error_log( 'Validated PayPal Email', false );
210
+		wpinv_error_log('Validated PayPal Email', false);
211 211
 	}
212 212
 
213 213
 	/**
@@ -216,70 +216,70 @@  discard block
 block discarded – undo
216 216
 	 * @param WPInv_Invoice $invoice  Invoice object.
217 217
 	 * @param array    $posted Posted data.
218 218
 	 */
219
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
219
+	protected function ipn_txn_web_accept($invoice, $posted) {
220 220
 
221 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'] );
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 228
 		// Update the transaction id.
229
-		if ( ! empty( $posted['txn_id'] ) ) {
230
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
229
+		if (!empty($posted['txn_id'])) {
230
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
231 231
 			$invoice->save();
232 232
 		}
233 233
 
234
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
234
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
235 235
 
236 236
 		// Process a refund.
237
-		if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) {
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'] );
241
+			if (!$invoice->is_refunded()) {
242
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
243 243
 			}
244 244
 
245
-			return wpinv_error_log( $posted['reason_code'], false );
245
+			return wpinv_error_log($posted['reason_code'], false);
246 246
 		}
247 247
 
248 248
 		// Process payments.
249
-		if ( 'completed' === $payment_status ) {
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 );
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 253
 			}
254 254
 
255
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
255
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
256 256
 
257 257
 			$note = '';
258 258
 
259
-			if ( ! empty( $posted['mc_fee'] ) ) {
260
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
259
+			if (!empty($posted['mc_fee'])) {
260
+				$note = sprintf(__('PayPal Transaction Fee %s.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
261 261
 			}
262 262
 
263
-			if ( ! empty( $posted['payer_status'] ) ) {
264
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
263
+			if (!empty($posted['payer_status'])) {
264
+				$note = ' ' . sprintf(__('Buyer status %s.', 'invoicing'), sanitize_text_field($posted['payer_status']));
265 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 272
 		// Pending payments.
273
-		if ( 'pending' === $payment_status ) {
273
+		if ('pending' === $payment_status) {
274 274
 
275 275
 			/* translators: %s: pending reason. */
276
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['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 );
278
+			return wpinv_error_log('Invoice marked as "payment held".', false);
279 279
 		}
280 280
 
281 281
 		/* translators: %s: payment status. */
282
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['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
 
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param WPInv_Invoice $invoice  Invoice object.
290 290
 	 * @param array    $posted Posted data.
291 291
 	 */
292
-	protected function ipn_txn_cart( $invoice, $posted ) {
293
-		$this->ipn_txn_web_accept( $invoice, $posted );
292
+	protected function ipn_txn_cart($invoice, $posted) {
293
+		$this->ipn_txn_web_accept($invoice, $posted);
294 294
 	}
295 295
 
296 296
 	/**
@@ -299,43 +299,43 @@  discard block
 block discarded – undo
299 299
 	 * @param WPInv_Invoice $invoice  Invoice object.
300 300
 	 * @param array    $posted Posted data.
301 301
 	 */
302
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
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 306
 		// Make sure the invoice has a subscription.
307
-		$subscription = getpaid_get_invoice_subscription( $invoice );
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 );
309
+		if (empty($subscription)) {
310
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
311 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 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'] );
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 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'] ) );
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 325
 		$subscription->activate();
326 326
 
327 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'] );
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 331
 		}
332 332
 
333 333
 		// Update the payment status.
334 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 );
338
+		wpinv_error_log('Subscription started.', false);
339 339
 	}
340 340
 
341 341
 	/**
@@ -344,45 +344,45 @@  discard block
 block discarded – undo
344 344
 	 * @param WPInv_Invoice $invoice  Invoice object.
345 345
 	 * @param array    $posted Posted data.
346 346
 	 */
347
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
347
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
348 348
 
349 349
 		// Make sure the invoice has a subscription.
350
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
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 );
352
+		if (empty($subscription)) {
353
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
354 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 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' ) );
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 ) {
368
+			if ($date !== $today_date && $date !== $payment_date) {
369 369
 				continue;
370 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 );
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 375
 			}
376 376
 
377 377
 			return $invoice->mark_paid();
378 378
 
379 379
 		}
380 380
 
381
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
381
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
382 382
 
383 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 );
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 386
 		}
387 387
 
388 388
 		$args = array(
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 			'gateway'        => $this->id,
391 391
 		);
392 392
 
393
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
393
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
394 394
 
395
-		if ( empty( $invoice ) ) {
395
+		if (empty($invoice)) {
396 396
 			return;
397 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 402
 		$subscription->renew();
403
-		wpinv_error_log( 'Subscription renewed.', false );
403
+		wpinv_error_log('Subscription renewed.', false);
404 404
 
405 405
 	}
406 406
 
@@ -409,18 +409,18 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @param WPInv_Invoice $invoice  Invoice object.
411 411
 	 */
412
-	protected function ipn_txn_subscr_cancel( $invoice ) {
412
+	protected function ipn_txn_subscr_cancel($invoice) {
413 413
 
414 414
 		// Make sure the invoice has a subscription.
415
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
415
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
416 416
 
417
-		if ( empty( $subscription ) ) {
418
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
417
+		if (empty($subscription)) {
418
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
419 419
 		}
420 420
 
421
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
421
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
422 422
 		$subscription->cancel();
423
-		wpinv_error_log( 'Subscription cancelled.', false );
423
+		wpinv_error_log('Subscription cancelled.', false);
424 424
 
425 425
 	}
426 426
 
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
 	 * @param WPInv_Invoice $invoice  Invoice object.
431 431
 	 * @param array    $posted Posted data.
432 432
 	 */
433
-	protected function ipn_txn_subscr_eot( $invoice ) {
433
+	protected function ipn_txn_subscr_eot($invoice) {
434 434
 
435 435
 		// Make sure the invoice has a subscription.
436
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
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 );
438
+		if (empty($subscription)) {
439
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
440 440
 		}
441 441
 
442
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
442
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
443 443
 		$subscription->complete();
444
-		wpinv_error_log( 'Subscription completed.', false );
444
+		wpinv_error_log('Subscription completed.', false);
445 445
 
446 446
 	}
447 447
 
@@ -451,18 +451,18 @@  discard block
 block discarded – undo
451 451
 	 * @param WPInv_Invoice $invoice  Invoice object.
452 452
 	 * @param array    $posted Posted data.
453 453
 	 */
454
-	protected function ipn_txn_subscr_failed( $invoice ) {
454
+	protected function ipn_txn_subscr_failed($invoice) {
455 455
 
456 456
 		// Make sure the invoice has a subscription.
457
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
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 );
459
+		if (empty($subscription)) {
460
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
461 461
 		}
462 462
 
463
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
463
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
464 464
 		$subscription->failing();
465
-		wpinv_error_log( 'Subscription marked as failing.', false );
465
+		wpinv_error_log('Subscription marked as failing.', false);
466 466
 
467 467
 	}
468 468
 
@@ -472,18 +472,18 @@  discard block
 block discarded – undo
472 472
 	 * @param WPInv_Invoice $invoice  Invoice object.
473 473
 	 * @param array    $posted Posted data.
474 474
 	 */
475
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
475
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
476 476
 
477 477
 		// Make sure the invoice has a subscription.
478
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
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 );
480
+		if (empty($subscription)) {
481
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
482 482
 		}
483 483
 
484
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
484
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
485 485
 		$subscription->cancel();
486
-		wpinv_error_log( 'Subscription cancelled.', false );
486
+		wpinv_error_log('Subscription cancelled.', false);
487 487
 	}
488 488
 
489 489
 }
Please login to merge, or discard this patch.