Passed
Push — master ( 039fc1...a932b5 )
by Brian
05:54
created
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array(
28
-		'subscription',
29
-		'addons',
30
-		'single_subscription_group',
31
-		'multiple_subscription_groups',
32
-		'subscription_date_change',
33
-		'subscription_bill_times_change',
34
-	);
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array(
28
+        'subscription',
29
+        'addons',
30
+        'single_subscription_group',
31
+        'multiple_subscription_groups',
32
+        'subscription_date_change',
33
+        'subscription_bill_times_change',
34
+    );
35
+
36
+    /**
37
+     * Payment method order.
38
+     *
39
+     * @var int
40
+     */
41
+    public $order = 8;
35 42
 
36 43
     /**
37
-	 * Payment method order.
38
-	 *
39
-	 * @var int
40
-	 */
41
-	public $order = 8;
42
-
43
-	/**
44
-	 * Bank transfer instructions.
45
-	 */
46
-	public $instructions;
47
-
48
-	/**
49
-	 * Locale array.
50
-	 */
51
-	public $locale;
44
+     * Bank transfer instructions.
45
+     */
46
+    public $instructions;
52 47
 
53 48
     /**
54
-	 * Class constructor.
55
-	 */
56
-	public function __construct() {
49
+     * Locale array.
50
+     */
51
+    public $locale;
52
+
53
+    /**
54
+     * Class constructor.
55
+     */
56
+    public function __construct() {
57 57
         parent::__construct();
58 58
 
59 59
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62 62
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
64
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
69
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70 70
 
71 71
     }
72 72
 
73 73
     /**
74
-	 * Process Payment.
75
-	 *
76
-	 * @param WPInv_Invoice $invoice Invoice.
77
-	 * @param array $submission_data Posted checkout fields.
78
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
-	 * @return array
80
-	 */
81
-	public function process_payment( $invoice, $submission_data, $submission ) {
74
+     * Process Payment.
75
+     *
76
+     * @param WPInv_Invoice $invoice Invoice.
77
+     * @param array $submission_data Posted checkout fields.
78
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
+     * @return array
80
+     */
81
+    public function process_payment( $invoice, $submission_data, $submission ) {
82 82
 
83 83
         // Add a transaction id.
84 84
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -99,66 +99,66 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-	 * Output for the order received page.
103
-	 *
104
-	 * @param WPInv_Invoice $invoice Invoice.
105
-	 */
106
-	public function thankyou_page( $invoice ) {
102
+     * Output for the order received page.
103
+     *
104
+     * @param WPInv_Invoice $invoice Invoice.
105
+     */
106
+    public function thankyou_page( $invoice ) {
107 107
 
108 108
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
109 109
 
110
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
110
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
111 111
 
112 112
             if ( ! empty( $this->instructions ) ) {
113 113
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
114
-			}
114
+            }
115 115
 
116
-			$this->bank_details( $invoice );
116
+            $this->bank_details( $invoice );
117 117
 
118
-			echo '</div>';
118
+            echo '</div>';
119 119
 
120 120
         }
121 121
 
122
-	}
122
+    }
123 123
 
124 124
     /**
125
-	 * Add content to the WPI emails.
126
-	 *
127
-	 * @param WPInv_Invoice $invoice Invoice.
128
-	 * @param string     $email_type Email format: plain text or HTML.
129
-	 * @param bool     $sent_to_admin Sent to admin.
130
-	 */
131
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
125
+     * Add content to the WPI emails.
126
+     *
127
+     * @param WPInv_Invoice $invoice Invoice.
128
+     * @param string     $email_type Email format: plain text or HTML.
129
+     * @param bool     $sent_to_admin Sent to admin.
130
+     */
131
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
132 132
 
133
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
133
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
134 134
 
135
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
135
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
136 136
 
137
-			if ( $this->instructions ) {
138
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
137
+            if ( $this->instructions ) {
138
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
139 139
             }
140 140
 
141
-			$this->bank_details( $invoice );
141
+            $this->bank_details( $invoice );
142 142
 
143
-			echo '</div>';
143
+            echo '</div>';
144 144
 
145
-		}
145
+        }
146 146
 
147 147
     }
148 148
 
149 149
     /**
150
-	 * Get bank details and place into a list format.
151
-	 *
152
-	 * @param WPInv_Invoice $invoice Invoice.
153
-	 */
154
-	protected function bank_details( $invoice ) {
150
+     * Get bank details and place into a list format.
151
+     *
152
+     * @param WPInv_Invoice $invoice Invoice.
153
+     */
154
+    protected function bank_details( $invoice ) {
155 155
 
156
-		// Get the invoice country and country $locale.
157
-		$country = $invoice->get_country();
158
-		$locale  = $this->get_country_locale();
156
+        // Get the invoice country and country $locale.
157
+        $country = $invoice->get_country();
158
+        $locale  = $this->get_country_locale();
159 159
 
160
-		// Get sortcode label in the $locale array and use appropriate one.
161
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
160
+        // Get sortcode label in the $locale array and use appropriate one.
161
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
162 162
 
163 163
         $bank_fields = array(
164 164
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
             if ( ! empty( $value ) ) {
179 179
                 $bank_info[ $field ] = array(
180
-					'label' => $label,
181
-					'value' => $value,
182
-				);
180
+                    'label' => $label,
181
+                    'value' => $value,
182
+                );
183 183
             }
184
-		}
184
+        }
185 185
 
186 186
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
187 187
 
@@ -189,139 +189,139 @@  discard block
 block discarded – undo
189 189
             return;
190 190
         }
191 191
 
192
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
192
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
193
+
194
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
195
+
196
+        foreach ( $bank_info as $key => $data ) {
197
+            echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
+        }
199
+
200
+        echo '</table>';
201
+
202
+    }
193 203
 
194
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
204
+    /**
205
+     * Get country locale if localized.
206
+     *
207
+     * @return array
208
+     */
209
+    public function get_country_locale() {
210
+
211
+        if ( empty( $this->locale ) ) {
212
+
213
+            // Locale information to be used - only those that are not 'Sort Code'.
214
+            $this->locale = apply_filters(
215
+                'getpaid_get_bank_transfer_locale',
216
+                array(
217
+                    'AU' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'BSB', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'CA' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank transit number', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'IN' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'IFSC', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'IT' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Branch sort', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'NZ' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Bank code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                    'SE' => array(
243
+                        'sortcode' => array(
244
+                            'label' => __( 'Bank code', 'invoicing' ),
245
+                        ),
246
+                    ),
247
+                    'US' => array(
248
+                        'sortcode' => array(
249
+                            'label' => __( 'Routing number', 'invoicing' ),
250
+                        ),
251
+                    ),
252
+                    'ZA' => array(
253
+                        'sortcode' => array(
254
+                            'label' => __( 'Branch code', 'invoicing' ),
255
+                        ),
256
+                    ),
257
+                )
258
+            );
195 259
 
196
-		foreach ( $bank_info as $key => $data ) {
197
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
-		}
260
+        }
199 261
 
200
-		echo '</table>';
262
+        return $this->locale;
201 263
 
202 264
     }
203 265
 
204 266
     /**
205
-	 * Get country locale if localized.
206
-	 *
207
-	 * @return array
208
-	 */
209
-	public function get_country_locale() {
210
-
211
-		if ( empty( $this->locale ) ) {
212
-
213
-			// Locale information to be used - only those that are not 'Sort Code'.
214
-			$this->locale = apply_filters(
215
-				'getpaid_get_bank_transfer_locale',
216
-				array(
217
-					'AU' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'BSB', 'invoicing' ),
220
-						),
221
-					),
222
-					'CA' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank transit number', 'invoicing' ),
225
-						),
226
-					),
227
-					'IN' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'IFSC', 'invoicing' ),
230
-						),
231
-					),
232
-					'IT' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Branch sort', 'invoicing' ),
235
-						),
236
-					),
237
-					'NZ' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Bank code', 'invoicing' ),
240
-						),
241
-					),
242
-					'SE' => array(
243
-						'sortcode' => array(
244
-							'label' => __( 'Bank code', 'invoicing' ),
245
-						),
246
-					),
247
-					'US' => array(
248
-						'sortcode' => array(
249
-							'label' => __( 'Routing number', 'invoicing' ),
250
-						),
251
-					),
252
-					'ZA' => array(
253
-						'sortcode' => array(
254
-							'label' => __( 'Branch code', 'invoicing' ),
255
-						),
256
-					),
257
-				)
258
-			);
259
-
260
-		}
261
-
262
-		return $this->locale;
263
-
264
-	}
265
-
266
-	/**
267
-	 * Filters the gateway settings.
268
-	 *
269
-	 * @param array $admin_settings
270
-	 */
271
-	public function admin_settings( $admin_settings ) {
267
+     * Filters the gateway settings.
268
+     *
269
+     * @param array $admin_settings
270
+     */
271
+    public function admin_settings( $admin_settings ) {
272 272
 
273 273
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
274
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
274
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
275 275
 
276
-		$locale  = $this->get_country_locale();
276
+        $locale  = $this->get_country_locale();
277 277
 
278
-		// Get sortcode label in the $locale array and use appropriate one.
279
-		$country  = wpinv_default_billing_country();
280
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
278
+        // Get sortcode label in the $locale array and use appropriate one.
279
+        $country  = wpinv_default_billing_country();
280
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
281 281
 
282
-		$admin_settings['bank_transfer_ac_name'] = array(
282
+        $admin_settings['bank_transfer_ac_name'] = array(
283 283
             'type' => 'text',
284 284
             'id'   => 'bank_transfer_ac_name',
285 285
             'name' => __( 'Account Name', 'invoicing' ),
286
-		);
286
+        );
287 287
 
288
-		$admin_settings['bank_transfer_ac_no'] = array(
288
+        $admin_settings['bank_transfer_ac_no'] = array(
289 289
             'type' => 'text',
290 290
             'id'   => 'bank_transfer_ac_no',
291 291
             'name' => __( 'Account Number', 'invoicing' ),
292
-		);
292
+        );
293 293
 
294
-		$admin_settings['bank_transfer_bank_name'] = array(
294
+        $admin_settings['bank_transfer_bank_name'] = array(
295 295
             'type' => 'text',
296 296
             'id'   => 'bank_transfer_bank_name',
297 297
             'name' => __( 'Bank Name', 'invoicing' ),
298
-		);
298
+        );
299 299
 
300
-		$admin_settings['bank_transfer_ifsc'] = array(
300
+        $admin_settings['bank_transfer_ifsc'] = array(
301 301
             'type' => 'text',
302 302
             'id'   => 'bank_transfer_ifsc',
303 303
             'name' => __( 'IFSC Code', 'invoicing' ),
304
-		);
304
+        );
305 305
 
306
-		$admin_settings['bank_transfer_iban'] = array(
306
+        $admin_settings['bank_transfer_iban'] = array(
307 307
             'type' => 'text',
308 308
             'id'   => 'bank_transfer_iban',
309 309
             'name' => __( 'IBAN', 'invoicing' ),
310
-		);
310
+        );
311 311
 
312
-		$admin_settings['bank_transfer_bic'] = array(
312
+        $admin_settings['bank_transfer_bic'] = array(
313 313
             'type' => 'text',
314 314
             'id'   => 'bank_transfer_bic',
315 315
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
316
-		);
316
+        );
317 317
 
318
-		$admin_settings['bank_transfer_sort_code'] = array(
319
-			'type' => 'text',
320
-			'id'   => 'bank_transfer_sort_code',
321
-			'name' => $sortcode,
322
-		);
318
+        $admin_settings['bank_transfer_sort_code'] = array(
319
+            'type' => 'text',
320
+            'id'   => 'bank_transfer_sort_code',
321
+            'name' => $sortcode,
322
+        );
323 323
 
324
-		$admin_settings['bank_transfer_info'] = array(
324
+        $admin_settings['bank_transfer_info'] = array(
325 325
             'id'   => 'bank_transfer_info',
326 326
             'name' => __( 'Instructions', 'invoicing' ),
327 327
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
             'rows' => 5,
332 332
         );
333 333
 
334
-		return $admin_settings;
335
-	}
334
+        return $admin_settings;
335
+    }
336 336
 
337
-	/**
338
-	 * Processes invoice addons.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice
341
-	 * @param GetPaid_Form_Item[] $items
342
-	 * @return WPInv_Invoice
343
-	 */
344
-	public function process_addons( $invoice, $items ) {
337
+    /**
338
+     * Processes invoice addons.
339
+     *
340
+     * @param WPInv_Invoice $invoice
341
+     * @param GetPaid_Form_Item[] $items
342
+     * @return WPInv_Invoice
343
+     */
344
+    public function process_addons( $invoice, $items ) {
345 345
 
346 346
         foreach ( $items as $item ) {
347 347
             $invoice->add_item( $item );
@@ -349,67 +349,67 @@  discard block
 block discarded – undo
349 349
 
350 350
         $invoice->recalculate_total();
351 351
         $invoice->save();
352
-	}
352
+    }
353 353
 
354
-	/**
355
-	 * (Maybe) renews a bank transfer subscription profile.
356
-	 *
357
-	 *
354
+    /**
355
+     * (Maybe) renews a bank transfer subscription profile.
356
+     *
357
+     *
358 358
      * @param WPInv_Subscription $subscription
359
-	 */
360
-	public function maybe_renew_subscription( $subscription ) {
359
+     */
360
+    public function maybe_renew_subscription( $subscription ) {
361 361
 
362 362
         // Ensure its our subscription && it's active.
363 363
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
364
-			$subscription->create_payment();
364
+            $subscription->create_payment();
365 365
         }
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Process a bank transfer payment.
371
-	 *
372
-	 *
369
+    /**
370
+     * Process a bank transfer payment.
371
+     *
372
+     *
373 373
      * @param WPInv_Invoice $invoice
374
-	 */
375
-	public function invoice_paid( $invoice ) {
376
-
377
-		// Abort if not paid by bank transfer.
378
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
379
-			return;
380
-		}
381
-
382
-		// Is it a parent payment?
383
-		if ( 0 == $invoice->get_parent_id() ) {
384
-
385
-			// (Maybe) activate subscriptions.
386
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
387
-
388
-			if ( ! empty( $subscriptions ) ) {
389
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
390
-
391
-				foreach ( $subscriptions as $subscription ) {
392
-					if ( $subscription->exists() ) {
393
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
394
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
395
-
396
-						$subscription->set_next_renewal_date( $expiry );
397
-						$subscription->set_date_created( current_time( 'mysql' ) );
398
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
399
-						$subscription->activate();
400
-					}
401
-				}
402
-			}
403
-		} else {
404
-
405
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
406
-
407
-			// Renew the subscription.
408
-			if ( $subscription && $subscription->exists() ) {
409
-				$subscription->add_payment( array(), $invoice );
410
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
411
-			}
412
-		}
374
+     */
375
+    public function invoice_paid( $invoice ) {
376
+
377
+        // Abort if not paid by bank transfer.
378
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
379
+            return;
380
+        }
381
+
382
+        // Is it a parent payment?
383
+        if ( 0 == $invoice->get_parent_id() ) {
384
+
385
+            // (Maybe) activate subscriptions.
386
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
387
+
388
+            if ( ! empty( $subscriptions ) ) {
389
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
390
+
391
+                foreach ( $subscriptions as $subscription ) {
392
+                    if ( $subscription->exists() ) {
393
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
394
+                        $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
395
+
396
+                        $subscription->set_next_renewal_date( $expiry );
397
+                        $subscription->set_date_created( current_time( 'mysql' ) );
398
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
399
+                        $subscription->activate();
400
+                    }
401
+                }
402
+            }
403
+        } else {
404
+
405
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
406
+
407
+            // Renew the subscription.
408
+            if ( $subscription && $subscription->exists() ) {
409
+                $subscription->add_payment( array(), $invoice );
410
+                $subscription->renew( strtotime( $invoice->get_date_created() ) );
411
+            }
412
+        }
413 413
 
414 414
     }
415 415
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-gateway.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'authorizenet';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array(
28 28
         'subscription',
29 29
         'sandbox',
@@ -36,44 +36,44 @@  discard block
 block discarded – undo
36 36
     );
37 37
 
38 38
     /**
39
-	 * Payment method order.
40
-	 *
41
-	 * @var int
42
-	 */
39
+     * Payment method order.
40
+     *
41
+     * @var int
42
+     */
43 43
     public $order = 4;
44 44
 
45 45
     /**
46
-	 * Endpoint for requests from Authorize.net.
47
-	 *
48
-	 * @var string
49
-	 */
50
-	protected $notify_url;
51
-
52
-	/**
53
-	 * Endpoint for requests to Authorize.net.
54
-	 *
55
-	 * @var string
56
-	 */
46
+     * Endpoint for requests from Authorize.net.
47
+     *
48
+     * @var string
49
+     */
50
+    protected $notify_url;
51
+
52
+    /**
53
+     * Endpoint for requests to Authorize.net.
54
+     *
55
+     * @var string
56
+     */
57 57
     protected $endpoint;
58 58
 
59 59
     /**
60
-	 * Currencies this gateway is allowed for.
61
-	 *
62
-	 * @var array
63
-	 */
64
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
60
+     * Currencies this gateway is allowed for.
61
+     *
62
+     * @var array
63
+     */
64
+    public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
65 65
 
66 66
     /**
67
-	 * URL to view a transaction.
68
-	 *
69
-	 * @var string
70
-	 */
67
+     * URL to view a transaction.
68
+     *
69
+     * @var string
70
+     */
71 71
     public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s';
72 72
 
73 73
     /**
74
-	 * Class constructor.
75
-	 */
76
-	public function __construct() {
74
+     * Class constructor.
75
+     */
76
+    public function __construct() {
77 77
 
78 78
         $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
79 79
         $this->method_title         = __( 'Authorize.Net', 'invoicing' );
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-	 * Displays the payment method select field.
89
-	 *
90
-	 * @param int $invoice_id 0 or invoice id.
91
-	 * @param GetPaid_Payment_Form $form Current payment form.
92
-	 */
88
+     * Displays the payment method select field.
89
+     *
90
+     * @param int $invoice_id 0 or invoice id.
91
+     * @param GetPaid_Payment_Form $form Current payment form.
92
+     */
93 93
     public function payment_fields( $invoice_id, $form ) {
94 94
 
95 95
         // Let the user select a payment method.
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
     }
101 101
 
102 102
     /**
103
-	 * Creates a customer profile.
104
-	 *
105
-	 *
106
-	 * @param WPInv_Invoice $invoice Invoice.
103
+     * Creates a customer profile.
104
+     *
105
+     *
106
+     * @param WPInv_Invoice $invoice Invoice.
107 107
      * @param array $submission_data Posted checkout fields.
108 108
      * @param bool $save Whether or not to save the payment as a token.
109 109
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
110
-	 * @return string|WP_Error Payment profile id.
111
-	 */
112
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
110
+     * @return string|WP_Error Payment profile id.
111
+     */
112
+    public function create_customer_profile( $invoice, $submission_data, $save = true ) {
113 113
 
114 114
         // Remove non-digits from the number
115 115
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     /**
194
-	 * Retrieves a customer profile.
195
-	 *
196
-	 *
197
-	 * @param string $profile_id profile id.
198
-	 * @return string|WP_Error Profile id.
194
+     * Retrieves a customer profile.
195
+     *
196
+     *
197
+     * @param string $profile_id profile id.
198
+     * @return string|WP_Error Profile id.
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
200
-	 */
201
-	public function get_customer_profile( $profile_id ) {
200
+     */
201
+    public function get_customer_profile( $profile_id ) {
202 202
 
203 203
         // Generate args.
204 204
         $args = array(
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
     }
214 214
 
215 215
     /**
216
-	 * Creates a customer profile.
217
-	 *
218
-	 *
216
+     * Creates a customer profile.
217
+     *
218
+     *
219 219
      * @param string $profile_id profile id.
220
-	 * @param WPInv_Invoice $invoice Invoice.
220
+     * @param WPInv_Invoice $invoice Invoice.
221 221
      * @param array $submission_data Posted checkout fields.
222 222
      * @param bool $save Whether or not to save the payment as a token.
223 223
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
224
-	 * @return string|WP_Error Profile id.
225
-	 */
226
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
224
+     * @return string|WP_Error Profile id.
225
+     */
226
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
227 227
 
228 228
         // Remove non-digits from the number
229 229
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
     }
312 312
 
313 313
     /**
314
-	 * Retrieves payment details from cache.
315
-	 *
316
-	 *
314
+     * Retrieves payment details from cache.
315
+     *
316
+     *
317 317
      * @param array $payment_details.
318
-	 * @return array|false Profile id.
319
-	 */
320
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
318
+     * @return array|false Profile id.
319
+     */
320
+    public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
321 321
 
322 322
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
323 323
         $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
     }
343 343
 
344 344
     /**
345
-	 * Securely adds payment details to cache.
346
-	 *
347
-	 *
345
+     * Securely adds payment details to cache.
346
+     *
347
+     *
348 348
      * @param array $payment_details.
349 349
      * @param string $payment_profile_id.
350
-	 */
351
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
350
+     */
351
+    public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
352 352
 
353 353
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
354 354
         $cached_information = is_array( $cached_information ) ? $cached_information : array();
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
     }
361 361
 
362 362
     /**
363
-	 * Retrieves a customer payment profile.
364
-	 *
365
-	 *
366
-	 * @param string $customer_profile_id customer profile id.
363
+     * Retrieves a customer payment profile.
364
+     *
365
+     *
366
+     * @param string $customer_profile_id customer profile id.
367 367
      * @param string $payment_profile_id payment profile id.
368
-	 * @return string|WP_Error Profile id.
368
+     * @return string|WP_Error Profile id.
369 369
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
370
-	 */
371
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
370
+     */
371
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
372 372
 
373 373
         // Generate args.
374 374
         $args = array(
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-	 * Charges a customer payment profile.
388
-	 *
387
+     * Charges a customer payment profile.
388
+     *
389 389
      * @param string $customer_profile_id customer profile id.
390 390
      * @param string $payment_profile_id payment profile id.
391
-	 * @param WPInv_Invoice $invoice Invoice.
391
+     * @param WPInv_Invoice $invoice Invoice.
392 392
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
393
-	 * @return WP_Error|object
394
-	 */
395
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
393
+     * @return WP_Error|object
394
+     */
395
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
396 396
 
397 397
         // Generate args.
398 398
         $args = array(
@@ -438,41 +438,41 @@  discard block
 block discarded – undo
438 438
     }
439 439
 
440 440
     /**
441
-	 * Processes a customer charge.
442
-	 *
441
+     * Processes a customer charge.
442
+     *
443 443
      * @param stdClass $result Api response.
444
-	 * @param WPInv_Invoice $invoice Invoice.
445
-	 */
446
-	public function process_charge_response( $result, $invoice ) {
444
+     * @param WPInv_Invoice $invoice Invoice.
445
+     */
446
+    public function process_charge_response( $result, $invoice ) {
447 447
 
448 448
         wpinv_clear_errors();
449
-		$response_code = (int) $result->transactionResponse->responseCode;
449
+        $response_code = (int) $result->transactionResponse->responseCode;
450 450
 
451
-		// Succeeded.
452
-		if ( 1 == $response_code || 4 == $response_code ) {
451
+        // Succeeded.
452
+        if ( 1 == $response_code || 4 == $response_code ) {
453 453
 
454
-			// Maybe set a transaction id.
455
-			if ( ! empty( $result->transactionResponse->transId ) ) {
456
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
457
-			}
454
+            // Maybe set a transaction id.
455
+            if ( ! empty( $result->transactionResponse->transId ) ) {
456
+                $invoice->set_transaction_id( $result->transactionResponse->transId );
457
+            }
458 458
 
459
-			$invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
459
+            $invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
460 460
 
461
-			if ( 1 == $response_code ) {
462
-				return $invoice->mark_paid();
463
-			}
461
+            if ( 1 == $response_code ) {
462
+                return $invoice->mark_paid();
463
+            }
464 464
 
465
-			$invoice->set_status( 'wpi-onhold' );
466
-        	$invoice->add_note(
465
+            $invoice->set_status( 'wpi-onhold' );
466
+            $invoice->add_note(
467 467
                 sprintf(
468 468
                     __( 'Held for review: %s', 'invoicing' ),
469 469
                     $result->transactionResponse->messages->message[0]->description
470 470
                 )
471
-			);
471
+            );
472 472
 
473
-			return $invoice->save();
473
+            return $invoice->save();
474 474
 
475
-		}
475
+        }
476 476
 
477 477
         wpinv_set_error( 'card_declined' );
478 478
 
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
     }
485 485
 
486 486
     /**
487
-	 * Returns payment information.
488
-	 *
489
-	 *
490
-	 * @param array $card Card details.
491
-	 * @return array
492
-	 */
493
-	public function get_payment_information( $card ) {
487
+     * Returns payment information.
488
+     *
489
+     *
490
+     * @param array $card Card details.
491
+     * @return array
492
+     */
493
+    public function get_payment_information( $card ) {
494 494
         return array(
495 495
 
496 496
             'creditCard' => array(
@@ -503,25 +503,25 @@  discard block
 block discarded – undo
503 503
     }
504 504
 
505 505
     /**
506
-	 * Returns the customer profile meta name.
507
-	 *
508
-	 *
509
-	 * @param WPInv_Invoice $invoice Invoice.
510
-	 * @return string
511
-	 */
512
-	public function get_customer_profile_meta_name( $invoice ) {
506
+     * Returns the customer profile meta name.
507
+     *
508
+     *
509
+     * @param WPInv_Invoice $invoice Invoice.
510
+     * @return string
511
+     */
512
+    public function get_customer_profile_meta_name( $invoice ) {
513 513
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
514 514
     }
515 515
 
516 516
     /**
517
-	 * Validates the submitted data.
518
-	 *
519
-	 *
520
-	 * @param array $submission_data Posted checkout fields.
517
+     * Validates the submitted data.
518
+     *
519
+     *
520
+     * @param array $submission_data Posted checkout fields.
521 521
      * @param WPInv_Invoice $invoice
522
-	 * @return WP_Error|string The payment profile id
523
-	 */
524
-	public function validate_submission_data( $submission_data, $invoice ) {
522
+     * @return WP_Error|string The payment profile id
523
+     */
524
+    public function validate_submission_data( $submission_data, $invoice ) {
525 525
 
526 526
         // Validate authentication details.
527 527
         $auth = $this->get_auth_params();
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
     }
554 554
 
555 555
     /**
556
-	 * Returns invoice line items.
557
-	 *
558
-	 *
559
-	 * @param WPInv_Invoice $invoice Invoice.
560
-	 * @return array
561
-	 */
562
-	public function get_line_items( $invoice ) {
556
+     * Returns invoice line items.
557
+     *
558
+     *
559
+     * @param WPInv_Invoice $invoice Invoice.
560
+     * @return array
561
+     */
562
+    public function get_line_items( $invoice ) {
563 563
         $items = array();
564 564
 
565 565
         foreach ( $invoice->get_items() as $item ) {
@@ -596,15 +596,15 @@  discard block
 block discarded – undo
596 596
     }
597 597
 
598 598
     /**
599
-	 * Process Payment.
600
-	 *
601
-	 *
602
-	 * @param WPInv_Invoice $invoice Invoice.
603
-	 * @param array $submission_data Posted checkout fields.
604
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
605
-	 * @return array
606
-	 */
607
-	public function process_payment( $invoice, $submission_data, $submission ) {
599
+     * Process Payment.
600
+     *
601
+     *
602
+     * @param WPInv_Invoice $invoice Invoice.
603
+     * @param array $submission_data Posted checkout fields.
604
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
605
+     * @return array
606
+     */
607
+    public function process_payment( $invoice, $submission_data, $submission ) {
608 608
 
609 609
         // Validate the submitted data.
610 610
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -637,45 +637,45 @@  discard block
 block discarded – undo
637 637
 
638 638
         exit;
639 639
 
640
-	}
640
+    }
641 641
 
642
-	/**
643
-	 * Processes the initial payment.
644
-	 *
642
+    /**
643
+     * Processes the initial payment.
644
+     *
645 645
      * @param WPInv_Invoice $invoice Invoice.
646
-	 */
647
-	protected function process_initial_payment( $invoice ) {
646
+     */
647
+    protected function process_initial_payment( $invoice ) {
648 648
 
649
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
649
+        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
650 650
         $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
651
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
651
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
652 652
 
653
-		// Do we have an error?
654
-		if ( is_wp_error( $result ) ) {
655
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
656
-			wpinv_send_back_to_checkout( $invoice );
657
-		}
653
+        // Do we have an error?
654
+        if ( is_wp_error( $result ) ) {
655
+            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
656
+            wpinv_send_back_to_checkout( $invoice );
657
+        }
658 658
 
659
-		// Process the response.
660
-		$this->process_charge_response( $result, $invoice );
659
+        // Process the response.
660
+        $this->process_charge_response( $result, $invoice );
661 661
 
662
-		if ( wpinv_get_errors() ) {
663
-			wpinv_send_back_to_checkout( $invoice );
664
-		}
662
+        if ( wpinv_get_errors() ) {
663
+            wpinv_send_back_to_checkout( $invoice );
664
+        }
665 665
 
666
-	}
666
+    }
667 667
 
668 668
     /**
669
-	 * Processes recurring payments.
670
-	 *
669
+     * Processes recurring payments.
670
+     *
671 671
      * @param WPInv_Invoice $invoice Invoice.
672 672
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
673
-	 */
674
-	public function process_subscription( $invoice, $subscriptions ) {
673
+     */
674
+    public function process_subscription( $invoice, $subscriptions ) {
675 675
 
676 676
         // Check if there is an initial amount to charge.
677 677
         if ( (float) $invoice->get_total() > 0 ) {
678
-			$this->process_initial_payment( $invoice );
678
+            $this->process_initial_payment( $invoice );
679 679
         }
680 680
 
681 681
         // Activate the subscriptions.
@@ -693,36 +693,36 @@  discard block
 block discarded – undo
693 693
             }
694 694
         }
695 695
 
696
-		// Redirect to the success page.
696
+        // Redirect to the success page.
697 697
         wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
698 698
 
699 699
     }
700 700
 
701
-	/**
702
-	 * (Maybe) renews an authorize.net subscription profile.
703
-	 *
704
-	 *
701
+    /**
702
+     * (Maybe) renews an authorize.net subscription profile.
703
+     *
704
+     *
705 705
      * @param WPInv_Subscription $subscription
706
-	 */
707
-	public function maybe_renew_subscription( $subscription ) {
706
+     */
707
+    public function maybe_renew_subscription( $subscription ) {
708 708
 
709 709
         // Ensure its our subscription && it's active.
710 710
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
711 711
             $this->renew_subscription( $subscription );
712 712
         }
713 713
 
714
-	}
714
+    }
715 715
 
716 716
     /**
717
-	 * Renews a subscription.
718
-	 *
717
+     * Renews a subscription.
718
+     *
719 719
      * @param WPInv_Subscription $subscription
720
-	 */
721
-	public function renew_subscription( $subscription ) {
720
+     */
721
+    public function renew_subscription( $subscription ) {
722 722
 
723
-		// Generate the renewal invoice.
724
-		$new_invoice = $subscription->create_payment();
725
-		$old_invoice = $subscription->get_parent_payment();
723
+        // Generate the renewal invoice.
724
+        $new_invoice = $subscription->create_payment();
725
+        $old_invoice = $subscription->get_parent_payment();
726 726
 
727 727
         if ( empty( $new_invoice ) ) {
728 728
             $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
@@ -731,37 +731,37 @@  discard block
 block discarded – undo
731 731
         }
732 732
 
733 733
         // Charge the payment method.
734
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
735
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
736
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
737
-
738
-		// Do we have an error?
739
-		if ( is_wp_error( $result ) ) {
740
-
741
-			$old_invoice->add_note(
742
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
743
-				true,
744
-				false,
745
-				true
746
-			);
747
-			$subscription->failing();
748
-			return;
749
-
750
-		}
751
-
752
-		// Process the response.
753
-		$this->process_charge_response( $result, $new_invoice );
754
-
755
-		if ( wpinv_get_errors() ) {
756
-
757
-			$old_invoice->add_note(
758
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
759
-				true,
760
-				false,
761
-				true
762
-			);
763
-			$subscription->failing();
764
-			return;
734
+        $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
735
+        $customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
736
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
737
+
738
+        // Do we have an error?
739
+        if ( is_wp_error( $result ) ) {
740
+
741
+            $old_invoice->add_note(
742
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
743
+                true,
744
+                false,
745
+                true
746
+            );
747
+            $subscription->failing();
748
+            return;
749
+
750
+        }
751
+
752
+        // Process the response.
753
+        $this->process_charge_response( $result, $new_invoice );
754
+
755
+        if ( wpinv_get_errors() ) {
756
+
757
+            $old_invoice->add_note(
758
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
759
+                true,
760
+                false,
761
+                true
762
+            );
763
+            $subscription->failing();
764
+            return;
765 765
 
766 766
         }
767 767
 
@@ -770,13 +770,13 @@  discard block
 block discarded – undo
770 770
     }
771 771
 
772 772
     /**
773
-	 * Processes invoice addons.
774
-	 *
775
-	 * @param WPInv_Invoice $invoice
776
-	 * @param GetPaid_Form_Item[] $items
777
-	 * @return WPInv_Invoice
778
-	 */
779
-	public function process_addons( $invoice, $items ) {
773
+     * Processes invoice addons.
774
+     *
775
+     * @param WPInv_Invoice $invoice
776
+     * @param GetPaid_Form_Item[] $items
777
+     * @return WPInv_Invoice
778
+     */
779
+    public function process_addons( $invoice, $items ) {
780 780
 
781 781
         global $getpaid_authorize_addons;
782 782
 
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $invoice->recalculate_total();
796 796
 
797 797
         $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
798
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
798
+        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
799 799
 
800 800
         add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
801 801
         $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
@@ -810,11 +810,11 @@  discard block
 block discarded – undo
810 810
     }
811 811
 
812 812
     /**
813
-	 * Processes invoice addons.
814
-	 *
813
+     * Processes invoice addons.
814
+     *
815 815
      * @param array $args
816
-	 * @return array
817
-	 */
816
+     * @return array
817
+     */
818 818
     public function filter_addons_request( $args ) {
819 819
 
820 820
         global $getpaid_authorize_addons;
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
     }
849 849
 
850 850
     /**
851
-	 * Filters the gateway settings.
852
-	 *
853
-	 * @param array $admin_settings
854
-	 */
855
-	public function admin_settings( $admin_settings ) {
851
+     * Filters the gateway settings.
852
+     *
853
+     * @param array $admin_settings
854
+     */
855
+    public function admin_settings( $admin_settings ) {
856 856
 
857 857
         $currencies = sprintf(
858 858
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
             'readonly' => true,
893 893
         );
894 894
 
895
-		return $admin_settings;
896
-	}
895
+        return $admin_settings;
896
+    }
897 897
 
898 898
 }
Please login to merge, or discard this patch.