Passed
Push — master ( 2975b0...fd42df )
by Brian
05:40 queued 01:38
created
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  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( 'addons' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'addons' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,22 +44,22 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
50 50
 
51 51
     }
52 52
 
53 53
     /**
54
-	 * Process Payment.
55
-	 *
56
-	 *
57
-	 * @param WPInv_Invoice $invoice Invoice.
58
-	 * @param array $submission_data Posted checkout fields.
59
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
60
-	 * @return array
61
-	 */
62
-	public function process_payment( $invoice, $submission_data, $submission ) {
54
+     * Process Payment.
55
+     *
56
+     *
57
+     * @param WPInv_Invoice $invoice Invoice.
58
+     * @param array $submission_data Posted checkout fields.
59
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
60
+     * @return array
61
+     */
62
+    public function process_payment( $invoice, $submission_data, $submission ) {
63 63
 
64 64
         // Add a transaction id.
65 65
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -80,66 +80,66 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
     /**
83
-	 * Output for the order received page.
84
-	 *
85
-	 * @param WPInv_Invoice $invoice Invoice.
86
-	 */
87
-	public function thankyou_page( $invoice ) {
83
+     * Output for the order received page.
84
+     *
85
+     * @param WPInv_Invoice $invoice Invoice.
86
+     */
87
+    public function thankyou_page( $invoice ) {
88 88
 
89 89
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
90 90
 
91
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
91
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
92 92
 
93 93
             if ( ! empty( $this->instructions ) ) {
94 94
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
95
-			}
95
+            }
96 96
 
97
-			$this->bank_details( $invoice );
97
+            $this->bank_details( $invoice );
98 98
 			
99
-			echo '</div>';
99
+            echo '</div>';
100 100
         
101 101
         }
102 102
 
103
-	}
103
+    }
104 104
     
105 105
     /**
106
-	 * Add content to the WPI emails.
107
-	 *
108
-	 * @param WPInv_Invoice $invoice Invoice.
109
-	 * @param string     $email_type Email format: plain text or HTML.
110
-	 * @param bool     $sent_to_admin Sent to admin.
111
-	 */
112
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
106
+     * Add content to the WPI emails.
107
+     *
108
+     * @param WPInv_Invoice $invoice Invoice.
109
+     * @param string     $email_type Email format: plain text or HTML.
110
+     * @param bool     $sent_to_admin Sent to admin.
111
+     */
112
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
113 113
 
114
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
114
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115 115
 
116
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
116
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
117 117
 
118
-			if ( $this->instructions ) {
119
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
118
+            if ( $this->instructions ) {
119
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120 120
             }
121 121
 
122
-			$this->bank_details( $invoice );
122
+            $this->bank_details( $invoice );
123 123
 			
124
-			echo '</div>';
124
+            echo '</div>';
125 125
 
126
-		}
126
+        }
127 127
 
128 128
     }
129 129
     
130 130
     /**
131
-	 * Get bank details and place into a list format.
132
-	 *
133
-	 * @param WPInv_Invoice $invoice Invoice.
134
-	 */
135
-	protected function bank_details( $invoice ) {
131
+     * Get bank details and place into a list format.
132
+     *
133
+     * @param WPInv_Invoice $invoice Invoice.
134
+     */
135
+    protected function bank_details( $invoice ) {
136 136
 
137
-		// Get the invoice country and country $locale.
138
-		$country = $invoice->get_country();
139
-		$locale  = $this->get_country_locale();
137
+        // Get the invoice country and country $locale.
138
+        $country = $invoice->get_country();
139
+        $locale  = $this->get_country_locale();
140 140
 
141
-		// Get sortcode label in the $locale array and use appropriate one.
142
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
141
+        // Get sortcode label in the $locale array and use appropriate one.
142
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143 143
 
144 144
         $bank_fields = array(
145 145
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -168,144 +168,144 @@  discard block
 block discarded – undo
168 168
             return;
169 169
         }
170 170
 
171
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
171
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172 172
 
173
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
173
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
174 174
 
175
-		foreach ( $bank_info as $key => $data ) {
175
+        foreach ( $bank_info as $key => $data ) {
176 176
 
177
-			$key   = sanitize_html_class( $key );
178
-			$label = wp_kses_post( $data['label'] );
179
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
177
+            $key   = sanitize_html_class( $key );
178
+            $label = wp_kses_post( $data['label'] );
179
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
180 180
 
181
-			echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
182
-		}
181
+            echo "<tr class='getpaid-bank-transfer-$key'><th>$label</th><td>$value</td></tr>" . PHP_EOL;
182
+        }
183 183
 
184
-		echo '</table>';
184
+        echo '</table>';
185 185
 
186 186
     }
187 187
     
188 188
     /**
189
-	 * Get country locale if localized.
190
-	 *
191
-	 * @return array
192
-	 */
193
-	public function get_country_locale() {
194
-
195
-		if ( empty( $this->locale ) ) {
196
-
197
-			// Locale information to be used - only those that are not 'Sort Code'.
198
-			$this->locale = apply_filters(
199
-				'getpaid_get_bank_transfer_locale',
200
-				array(
201
-					'AU' => array(
202
-						'sortcode' => array(
203
-							'label' => __( 'BSB', 'invoicing' ),
204
-						),
205
-					),
206
-					'CA' => array(
207
-						'sortcode' => array(
208
-							'label' => __( 'Bank transit number', 'invoicing' ),
209
-						),
210
-					),
211
-					'IN' => array(
212
-						'sortcode' => array(
213
-							'label' => __( 'IFSC', 'invoicing' ),
214
-						),
215
-					),
216
-					'IT' => array(
217
-						'sortcode' => array(
218
-							'label' => __( 'Branch sort', 'invoicing' ),
219
-						),
220
-					),
221
-					'NZ' => array(
222
-						'sortcode' => array(
223
-							'label' => __( 'Bank code', 'invoicing' ),
224
-						),
225
-					),
226
-					'SE' => array(
227
-						'sortcode' => array(
228
-							'label' => __( 'Bank code', 'invoicing' ),
229
-						),
230
-					),
231
-					'US' => array(
232
-						'sortcode' => array(
233
-							'label' => __( 'Routing number', 'invoicing' ),
234
-						),
235
-					),
236
-					'ZA' => array(
237
-						'sortcode' => array(
238
-							'label' => __( 'Branch code', 'invoicing' ),
239
-						),
240
-					),
241
-				)
242
-			);
243
-
244
-		}
245
-
246
-		return $this->locale;
247
-
248
-	}
249
-
250
-	/**
251
-	 * Filters the gateway settings.
252
-	 * 
253
-	 * @param array $admin_settings
254
-	 */
255
-	public function admin_settings( $admin_settings ) {
189
+     * Get country locale if localized.
190
+     *
191
+     * @return array
192
+     */
193
+    public function get_country_locale() {
194
+
195
+        if ( empty( $this->locale ) ) {
196
+
197
+            // Locale information to be used - only those that are not 'Sort Code'.
198
+            $this->locale = apply_filters(
199
+                'getpaid_get_bank_transfer_locale',
200
+                array(
201
+                    'AU' => array(
202
+                        'sortcode' => array(
203
+                            'label' => __( 'BSB', 'invoicing' ),
204
+                        ),
205
+                    ),
206
+                    'CA' => array(
207
+                        'sortcode' => array(
208
+                            'label' => __( 'Bank transit number', 'invoicing' ),
209
+                        ),
210
+                    ),
211
+                    'IN' => array(
212
+                        'sortcode' => array(
213
+                            'label' => __( 'IFSC', 'invoicing' ),
214
+                        ),
215
+                    ),
216
+                    'IT' => array(
217
+                        'sortcode' => array(
218
+                            'label' => __( 'Branch sort', 'invoicing' ),
219
+                        ),
220
+                    ),
221
+                    'NZ' => array(
222
+                        'sortcode' => array(
223
+                            'label' => __( 'Bank code', 'invoicing' ),
224
+                        ),
225
+                    ),
226
+                    'SE' => array(
227
+                        'sortcode' => array(
228
+                            'label' => __( 'Bank code', 'invoicing' ),
229
+                        ),
230
+                    ),
231
+                    'US' => array(
232
+                        'sortcode' => array(
233
+                            'label' => __( 'Routing number', 'invoicing' ),
234
+                        ),
235
+                    ),
236
+                    'ZA' => array(
237
+                        'sortcode' => array(
238
+                            'label' => __( 'Branch code', 'invoicing' ),
239
+                        ),
240
+                    ),
241
+                )
242
+            );
243
+
244
+        }
245
+
246
+        return $this->locale;
247
+
248
+    }
249
+
250
+    /**
251
+     * Filters the gateway settings.
252
+     * 
253
+     * @param array $admin_settings
254
+     */
255
+    public function admin_settings( $admin_settings ) {
256 256
 
257 257
         $admin_settings['worldpay_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' );
258
-		$admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258
+        $admin_settings['worldpay_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
259 259
 
260
-		$locale  = $this->get_country_locale();
260
+        $locale  = $this->get_country_locale();
261 261
 
262
-		// Get sortcode label in the $locale array and use appropriate one.
263
-		$country  = wpinv_default_billing_country();
264
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
262
+        // Get sortcode label in the $locale array and use appropriate one.
263
+        $country  = wpinv_default_billing_country();
264
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
265 265
 
266
-		$admin_settings['bank_transfer_ac_name'] = array(
266
+        $admin_settings['bank_transfer_ac_name'] = array(
267 267
             'type' => 'text',
268 268
             'id'   => 'bank_transfer_ac_name',
269 269
             'name' => __( 'Account Name', 'invoicing' ),
270
-		);
270
+        );
271 271
 		
272
-		$admin_settings['bank_transfer_ac_no'] = array(
272
+        $admin_settings['bank_transfer_ac_no'] = array(
273 273
             'type' => 'text',
274 274
             'id'   => 'bank_transfer_ac_no',
275 275
             'name' => __( 'Account Number', 'invoicing' ),
276
-		);
276
+        );
277 277
 		
278
-		$admin_settings['bank_transfer_bank_name'] = array(
278
+        $admin_settings['bank_transfer_bank_name'] = array(
279 279
             'type' => 'text',
280 280
             'id'   => 'bank_transfer_bank_name',
281 281
             'name' => __( 'Bank Name', 'invoicing' ),
282
-		);
282
+        );
283 283
 
284
-		$admin_settings['bank_transfer_ifsc'] = array(
284
+        $admin_settings['bank_transfer_ifsc'] = array(
285 285
             'type' => 'text',
286 286
             'id'   => 'bank_transfer_ifsc',
287 287
             'name' => __( 'IFSC Code', 'invoicing' ),
288
-		);
288
+        );
289 289
 
290
-		$admin_settings['bank_transfer_iban'] = array(
290
+        $admin_settings['bank_transfer_iban'] = array(
291 291
             'type' => 'text',
292 292
             'id'   => 'bank_transfer_iban',
293 293
             'name' => __( 'IBAN', 'invoicing' ),
294
-		);
294
+        );
295 295
 
296
-		$admin_settings['bank_transfer_bic'] = array(
296
+        $admin_settings['bank_transfer_bic'] = array(
297 297
             'type' => 'text',
298 298
             'id'   => 'bank_transfer_bic',
299 299
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
300
-		);
300
+        );
301 301
 		
302
-		$admin_settings['bank_transfer_sort_code'] = array(
303
-			'type' => 'text',
304
-			'id'   => 'bank_transfer_sort_code',
305
-			'name' => $sortcode,
306
-		);
302
+        $admin_settings['bank_transfer_sort_code'] = array(
303
+            'type' => 'text',
304
+            'id'   => 'bank_transfer_sort_code',
305
+            'name' => $sortcode,
306
+        );
307 307
 
308
-		$admin_settings['bank_transfer_info'] = array(
308
+        $admin_settings['bank_transfer_info'] = array(
309 309
             'id'   => 'bank_transfer_info',
310 310
             'name' => __( 'Instructions', 'invoicing' ),
311 311
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -315,17 +315,17 @@  discard block
 block discarded – undo
315 315
             'rows' => 5
316 316
         );
317 317
 
318
-		return $admin_settings;
319
-	}
318
+        return $admin_settings;
319
+    }
320 320
 
321
-	/**
322
-	 * Processes invoice addons.
323
-	 *
324
-	 * @param WPInv_Invoice $invoice
325
-	 * @param GetPaid_Form_Item[] $items
326
-	 * @return WPInv_Invoice
327
-	 */
328
-	public function process_addons( $invoice, $items ) {
321
+    /**
322
+     * Processes invoice addons.
323
+     *
324
+     * @param WPInv_Invoice $invoice
325
+     * @param GetPaid_Form_Item[] $items
326
+     * @return WPInv_Invoice
327
+     */
328
+    public function process_addons( $invoice, $items ) {
329 329
 
330 330
         foreach ( $items as $item ) {
331 331
             $invoice->add_item( $item );
@@ -333,6 +333,6 @@  discard block
 block discarded – undo
333 333
 
334 334
         $invoice->recalculate_total();
335 335
         $invoice->save();
336
-	}
336
+    }
337 337
 
338 338
 }
Please login to merge, or discard this patch.