Passed
Pull Request — master (#37)
by Kiran
03:38
created
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetARB.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
      */
117 117
     protected function _setPostString()
118 118
     {
119
-        $this->_post_string =<<<XML
119
+        $this->_post_string = <<<XML
120 120
 <?xml version="1.0" encoding="utf-8"?>
121 121
 <ARB{$this->_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd">
122 122
     <merchantAuthentication>
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCIM.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
     {
310 310
         $this->_validationMode = $validationMode;
311 311
         $this->_constructXml("validateCustomerPaymentProfileRequest");
312
-        $this->_xml->addChild("customerProfileId",$customerProfileId);
313
-        $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId);
314
-        $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId);
315
-        $this->_xml->addChild("cardCode",$cardCode);
312
+        $this->_xml->addChild("customerProfileId", $customerProfileId);
313
+        $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);
314
+        $this->_xml->addChild("customerShippingAddressId", $customerShippingAddressId);
315
+        $this->_xml->addChild("cardCode", $cardCode);
316 316
         return $this->_sendRequest();
317 317
     }
318 318
     
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
      */
342 342
     protected function _setPostString()
343 343
     {
344
-        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : "");
344
+        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode', $this->_validationMode) : "");
345 345
         $this->_post_string = $this->_xml->asXML();
346 346
         
347 347
         // Add extraOptions CDATA
348 348
         if ($this->_extraOptions) {
349 349
             $this->_xml->addChild("extraOptions");
350
-            $this->_post_string = str_replace("<extraOptions></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
350
+            $this->_post_string = str_replace("<extraOptions></extraOptions>", '<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
351 351
             $this->_extraOptions = false;
352 352
         }
353 353
         // Blank out our validation mode, so that we don't include it in calls that
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
      */
363 363
     private function _constructXml($request_type)
364 364
     {
365
-        $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
365
+        $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>';
366 366
         $this->_xml = @new SimpleXMLElement($string);
367 367
         $merchant = $this->_xml->addChild('merchantAuthentication');
368
-        $merchant->addChild('name',$this->_api_login);
369
-        $merchant->addChild('transactionKey',$this->_transaction_key);
370
-        ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : "");
368
+        $merchant->addChild('name', $this->_api_login);
369
+        $merchant->addChild('transactionKey', $this->_transaction_key);
370
+        ($this->_refId ? $this->_xml->addChild('refId', $this->_refId) : "");
371 371
     }
372 372
     
373 373
     /**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                         $this->_addObject($items, $item);
388 388
                     }
389 389
                 } else {
390
-                    $destination->addChild($key,$value);
390
+                    $destination->addChild($key, $value);
391 391
                 }
392 392
             } elseif (is_object($value) && self::_notEmpty($value)) {
393 393
                 $dest = $destination->addChild($key);
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCP.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 
117 117
                 $this->xml = @simplexml_load_string($response);
118 118
                 // Set all fields
119
-                $this->version              = array_pop(array_slice(explode('"', $response), 1,1));
119
+                $this->version              = array_pop(array_slice(explode('"', $response), 1, 1));
120 120
                 $this->response_code        = (string)$this->xml->ResponseCode;
121 121
                 
122 122
                 if ($this->response_code == 1) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 // Split Array
145 145
                 $this->response = $response;
146 146
                 if ($encap_char) {
147
-                    $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
147
+                    $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
148 148
                 } else {
149 149
                     $this->_response_array = explode($delimiter, $response);
150 150
                 }
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
             
191 191
             if ($this->error) {
192 192
                 $this->error_message = "AuthorizeNet Error:
193
-                Response Code: ".$this->response_code."
194
-                Response Reason Code: ".$this->response_reason_code."
195
-                Response Reason Text: ".$this->response_reason_text."
193
+                Response Code: ".$this->response_code . "
194
+                Response Reason Code: ".$this->response_reason_code . "
195
+                Response Reason Text: ".$this->response_reason_text . "
196 196
                 ";
197 197
             }
198 198
             
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetTD.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $month = ($month ? $month : date('m'));
66 66
         $year = ($year ? $year : date('Y'));
67
-        $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6);
68
-        $lastSettlementDate  = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6);
67
+        $firstSettlementDate = substr(date('c', mktime(0, 0, 0, $month, 1, $year)), 0, -6);
68
+        $lastSettlementDate  = substr(date('c', mktime(0, 0, 0, $month + 1, 0, $year)), 0, -6);
69 69
         return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate);
70 70
     }
71 71
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
         $month = ($month ? $month : date('m'));
99 99
         $day = ($day ? $day : date('d'));
100 100
         $year = ($year ? $year : date('Y'));
101
-        $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6);
102
-        $lastSettlementDate  = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6);
101
+        $firstSettlementDate = substr(date('c', mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)), 0, -6);
102
+        $lastSettlementDate  = substr(date('c', mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)), 0, -6);
103 103
         $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate);
104 104
         $batches = $response->xpath("batchList/batch");
105 105
         foreach ($batches as $batch) {
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
      */
188 188
     private function _constructXml($request_type)
189 189
     {
190
-        $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
190
+        $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>';
191 191
         $this->_xml = @new SimpleXMLElement($string);
192 192
         $merchant = $this->_xml->addChild('merchantAuthentication');
193
-        $merchant->addChild('name',$this->_api_login);
194
-        $merchant->addChild('transactionKey',$this->_transaction_key);
193
+        $merchant->addChild('name', $this->_api_login);
194
+        $merchant->addChild('transactionKey', $this->_transaction_key);
195 195
     }
196 196
     
197 197
 }
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetSOAP.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
         $string = "";
52 52
         $types = $this->__getTypes();
53 53
         foreach ($types as $type) {
54
-            if (preg_match("/struct /",$type)) {
55
-                $type = preg_replace("/struct /","class ",$type);
56
-                $type = preg_replace("/ (\w+) (\w+);/","    // $1\n    public \$$2;",$type);
57
-                $string .= $type ."\n";
54
+            if (preg_match("/struct /", $type)) {
55
+                $type = preg_replace("/struct /", "class ", $type);
56
+                $type = preg_replace("/ (\w+) (\w+);/", "    // $1\n    public \$$2;", $type);
57
+                $string .= $type . "\n";
58 58
             }
59 59
         }
60 60
         return $string;
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function saveSoapDocumentation($path)
86 86
     {
87
-        $string =  "<?php\n";
87
+        $string = "<?php\n";
88 88
         $string .= "/**\n";
89 89
         $string .= " * Auto generated documentation for the AuthorizeNetSOAP API.\n";
90 90
         $string .= " * Generated " . date("m/d/Y") . "\n";
91 91
         $string .= " */\n";
92 92
         $string .= "class AuthorizeNetSOAP\n";
93
-        $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() ."\n\n ?>";
93
+        $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() . "\n\n ?>";
94 94
         return file_put_contents($path, $string);
95 95
     }
96 96
     
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetDPM.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 else
58 58
                 {
59 59
                     // Redirect to error page.
60
-                    $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text;
60
+                    $redirect_url = $url . '?response_code=' . $response->response_code . '&response_reason_text=' . $response->response_reason_text;
61 61
                 }
62 62
                 // Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
63 63
                 echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
@@ -179,54 +179,54 @@  discard block
 block discarded – undo
179 179
             -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
180 180
             box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); }
181 181
         </style>
182
-        <form method="post" action="'.$post_url.'">
183
-                '.$hidden_fields.'
182
+        <form method="post" action="'.$post_url . '">
183
+                '.$hidden_fields . '
184 184
             <fieldset>
185 185
                 <div>
186 186
                     <label>Credit Card Number</label>
187
-                    <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input>
187
+                    <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '') . '"></input>
188 188
                 </div>
189 189
                 <div>
190 190
                     <label>Exp.</label>
191
-                    <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input>
191
+                    <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '') . '"></input>
192 192
                 </div>
193 193
                 <div>
194 194
                     <label>CCV</label>
195
-                    <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input>
195
+                    <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '') . '"></input>
196 196
                 </div>
197 197
             </fieldset>
198 198
             <fieldset>
199 199
                 <div>
200 200
                     <label>First Name</label>
201
-                    <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input>
201
+                    <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '') . '"></input>
202 202
                 </div>
203 203
                 <div>
204 204
                     <label>Last Name</label>
205
-                    <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input>
205
+                    <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '') . '"></input>
206 206
                 </div>
207 207
             </fieldset>
208 208
             <fieldset>
209 209
                 <div>
210 210
                     <label>Address</label>
211
-                    <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input>
211
+                    <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '') . '"></input>
212 212
                 </div>
213 213
                 <div>
214 214
                     <label>City</label>
215
-                    <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input>
215
+                    <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '') . '"></input>
216 216
                 </div>
217 217
             </fieldset>
218 218
             <fieldset>
219 219
                 <div>
220 220
                     <label>State</label>
221
-                    <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input>
221
+                    <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '') . '"></input>
222 222
                 </div>
223 223
                 <div>
224 224
                     <label>Zip Code</label>
225
-                    <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input>
225
+                    <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '') . '"></input>
226 226
                 </div>
227 227
                 <div>
228 228
                     <label>Country</label>
229
-                    <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input>
229
+                    <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '') . '"></input>
230 230
                 </div>
231 231
             </fieldset>
232 232
             <input type="submit" value="BUY" class="submit buy">
Please login to merge, or discard this patch.
includes/gateways/authorizenet.php 1 patch
Spacing   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -1,60 +1,60 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_filter( 'wpinv_authorizenet_support_subscription', '__return_true' );
5
+add_filter('wpinv_authorizenet_support_subscription', '__return_true');
6 6
 
7
-function wpinv_authorizenet_cc_form( $invoice_id ) {
8
-    $invoice = wpinv_get_invoice( $invoice_id );
9
-    $cc_owner = !empty( $invoice ) ? esc_attr( $invoice->get_user_full_name() ) : '';
7
+function wpinv_authorizenet_cc_form($invoice_id) {
8
+    $invoice = wpinv_get_invoice($invoice_id);
9
+    $cc_owner = !empty($invoice) ? esc_attr($invoice->get_user_full_name()) : '';
10 10
     ?>
11 11
     <div id="authorizenet_cc_form" class="form-horizontal wpi-cc-form panel panel-default">
12
-        <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Card Details', 'invoicing' ) ;?></h3></div>
12
+        <div class="panel-heading"><h3 class="panel-title"><?php _e('Card Details', 'invoicing'); ?></h3></div>
13 13
         <div class="panel-body">
14 14
             <div class="form-group required">
15
-              <label for="auth-input-cc-owner" class="col-sm-4 control-label"><?php _e( 'Card Owner', 'invoicing' ) ;?></label>
15
+              <label for="auth-input-cc-owner" class="col-sm-4 control-label"><?php _e('Card Owner', 'invoicing'); ?></label>
16 16
               <div class="col-sm-8">
17
-                <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e( 'Card Owner', 'invoicing' ) ;?>" value="<?php echo $cc_owner;?>" name="authorizenet[cc_owner]">
17
+                <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e('Card Owner', 'invoicing'); ?>" value="<?php echo $cc_owner; ?>" name="authorizenet[cc_owner]">
18 18
               </div>
19 19
             </div>
20 20
             <div class="form-group required">
21
-              <label for="auth-input-cc-number" class="col-sm-4 control-label"><?php _e( 'Card Number', 'invoicing' ) ;?></label>
21
+              <label for="auth-input-cc-number" class="col-sm-4 control-label"><?php _e('Card Number', 'invoicing'); ?></label>
22 22
               <div class="col-sm-8">
23
-                <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e( 'Card Number', 'invoicing' ) ;?>" value="" name="authorizenet[cc_number]">
23
+                <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e('Card Number', 'invoicing'); ?>" value="" name="authorizenet[cc_number]">
24 24
               </div>
25 25
             </div>
26 26
             <div class="form-group required">
27
-              <label for="auth-input-cc-expire-date" class="col-sm-4 control-label"><?php _e( 'Card Expiry Date', 'invoicing' ) ;?></label>
27
+              <label for="auth-input-cc-expire-date" class="col-sm-4 control-label"><?php _e('Card Expiry Date', 'invoicing'); ?></label>
28 28
               <div class="col-sm-2">
29 29
                 <select class="form-control" id="auth-input-cc-expire-date" name="authorizenet[cc_expire_month]">
30
-                    <?php for ( $i = 1; $i <= 12; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
31
-                    <option value="<?php echo $value;?>"><?php echo $value;?></option>
30
+                    <?php for ($i = 1; $i <= 12; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
31
+                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
32 32
                     <?php } ?>
33 33
                 </select>
34 34
                </div>
35 35
                <div class="col-sm-2">
36 36
                 <select class="form-control" name="authorizenet[cc_expire_year]">
37
-                    <?php $year = date( 'Y' ); for ( $i = $year; $i <= ( $year + 10 ); $i++ ) { ?>
38
-                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
37
+                    <?php $year = date('Y'); for ($i = $year; $i <= ($year + 10); $i++) { ?>
38
+                    <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
39 39
                     <?php } ?>
40 40
                 </select>
41 41
               </div>
42 42
             </div>
43 43
             <div class="form-group required">
44
-              <label for="auth-input-cc-cvv2" class="col-sm-4 control-label"><?php _e( 'Card Security Code (CVV2)', 'invoicing' ) ;?></label>
44
+              <label for="auth-input-cc-cvv2" class="col-sm-4 control-label"><?php _e('Card Security Code (CVV2)', 'invoicing'); ?></label>
45 45
               <div class="col-sm-8">
46
-                <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e( 'Card Security Code (CVV2)', 'invoicing' ) ;?>" value="" name="authorizenet[cc_cvv2]"">
46
+                <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e('Card Security Code (CVV2)', 'invoicing'); ?>" value="" name="authorizenet[cc_cvv2]"">
47 47
               </div>
48 48
             </div>
49 49
       </div>
50 50
     </div>
51 51
     <?php
52 52
 }
53
-add_action( 'wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1 );
53
+add_action('wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1);
54 54
 
55
-function wpinv_process_authorizenet_payment( $purchase_data ) {
56
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
57
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
55
+function wpinv_process_authorizenet_payment($purchase_data) {
56
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
57
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
58 58
     }
59 59
     
60 60
     // Collect payment data
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
     );
73 73
 
74 74
     // Record the pending payment
75
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
75
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
76 76
 
77
-    if ( !empty( $invoice ) ) {
78
-        $authorizenet_card  = !empty( $_POST['authorizenet'] ) ? $_POST['authorizenet'] : array();
77
+    if (!empty($invoice)) {
78
+        $authorizenet_card  = !empty($_POST['authorizenet']) ? $_POST['authorizenet'] : array();
79 79
         $card_defaults      = array(
80 80
             'cc_owner'          => $invoice->get_user_full_name(),
81 81
             'cc_number'         => false,
@@ -83,27 +83,27 @@  discard block
 block discarded – undo
83 83
             'cc_expire_year'    => false,
84 84
             'cc_cvv2'           => false,
85 85
         );
86
-        $authorizenet_card = wp_parse_args( $authorizenet_card, $card_defaults );
86
+        $authorizenet_card = wp_parse_args($authorizenet_card, $card_defaults);
87 87
         
88
-        if ( empty( $authorizenet_card['cc_owner'] ) ) {
89
-            wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing'));
88
+        if (empty($authorizenet_card['cc_owner'])) {
89
+            wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing'));
90 90
         }
91
-        if ( empty( $authorizenet_card['cc_number'] ) ) {
92
-            wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing'));
91
+        if (empty($authorizenet_card['cc_number'])) {
92
+            wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing'));
93 93
         }
94
-        if ( empty( $authorizenet_card['cc_expire_month'] ) ) {
95
-            wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing'));
94
+        if (empty($authorizenet_card['cc_expire_month'])) {
95
+            wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing'));
96 96
         }
97
-        if ( empty( $authorizenet_card['cc_expire_year'] ) ) {
98
-            wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing'));
97
+        if (empty($authorizenet_card['cc_expire_year'])) {
98
+            wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing'));
99 99
         }
100
-        if ( empty( $authorizenet_card['cc_cvv2'] ) ) {
101
-            wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) );
100
+        if (empty($authorizenet_card['cc_cvv2'])) {
101
+            wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing'));
102 102
         }
103 103
         
104 104
         $errors = wpinv_get_errors();
105 105
     
106
-        if ( empty( $errors ) ) {
106
+        if (empty($errors)) {
107 107
             $invoice_id = $invoice->ID;
108 108
             $quantities_enabled = wpinv_item_quantities_enabled();
109 109
             $use_taxes          = wpinv_use_taxes();
@@ -112,141 +112,141 @@  discard block
 block discarded – undo
112 112
             $authorizeAIM->first_name       = $invoice->get_first_name();
113 113
             $authorizeAIM->last_name        = $invoice->get_last_name();
114 114
             $authorizeAIM->company          = $invoice->company;
115
-            $authorizeAIM->address          = wp_strip_all_tags( $invoice->get_address(), true );
115
+            $authorizeAIM->address          = wp_strip_all_tags($invoice->get_address(), true);
116 116
             $authorizeAIM->city             = $invoice->city;
117 117
             $authorizeAIM->state            = $invoice->state;
118 118
             $authorizeAIM->zip              = $invoice->zip;
119 119
             $authorizeAIM->country          = $invoice->country;
120 120
             $authorizeAIM->phone            = $invoice->phone;
121 121
             $authorizeAIM->email            = $invoice->get_email();
122
-            $authorizeAIM->amount           = wpinv_sanitize_amount( $invoice->get_total() );
123
-            $authorizeAIM->card_num         = str_replace( ' ', '', sanitize_text_field( $authorizenet_card['cc_number'] ) );
124
-            $authorizeAIM->exp_date         = sanitize_text_field( $authorizenet_card['cc_expire_month'] ) . sanitize_text_field( $authorizenet_card['cc_expire_year'] );
125
-            $authorizeAIM->card_code        = sanitize_text_field( $authorizenet_card['cc_cvv2'] );
122
+            $authorizeAIM->amount           = wpinv_sanitize_amount($invoice->get_total());
123
+            $authorizeAIM->card_num         = str_replace(' ', '', sanitize_text_field($authorizenet_card['cc_number']));
124
+            $authorizeAIM->exp_date         = sanitize_text_field($authorizenet_card['cc_expire_month']) . sanitize_text_field($authorizenet_card['cc_expire_year']);
125
+            $authorizeAIM->card_code        = sanitize_text_field($authorizenet_card['cc_cvv2']);
126 126
             $authorizeAIM->invoice_num      = $invoice->ID;
127 127
             
128 128
             $item_desc = array();
129
-            foreach ( $invoice->get_cart_details() as $item ) {            
130
-                $quantity       = $quantities_enabled && !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1;
131
-                $item_desc[]    = $item['name'] . ' (' . $quantity . 'x ' . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')';
129
+            foreach ($invoice->get_cart_details() as $item) {            
130
+                $quantity       = $quantities_enabled && !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
131
+                $item_desc[]    = $item['name'] . ' (' . $quantity . 'x ' . wpinv_price(wpinv_format_amount($item['item_price'])) . ')';
132 132
                 
133
-                $authorizeAIM->addLineItem( $item['id'], $item['name'], '', $quantity, $item['item_price'], ( $use_taxes && !empty( $item['tax'] ) && $item['tax'] > 0 ? 'Y' : 'N' ) );
133
+                $authorizeAIM->addLineItem($item['id'], $item['name'], '', $quantity, $item['item_price'], ($use_taxes && !empty($item['tax']) && $item['tax'] > 0 ? 'Y' : 'N'));
134 134
             }
135 135
             
136
-            $item_desc = '#' . $invoice->get_number() . ': ' . implode( ', ', $item_desc );
136
+            $item_desc = '#' . $invoice->get_number() . ': ' . implode(', ', $item_desc);
137 137
             
138
-            if ( $use_taxes && $invoice->get_tax() > 0 ) {
139
-                $authorizeAIM->tax  = $invoice->get_tax();
138
+            if ($use_taxes && $invoice->get_tax() > 0) {
139
+                $authorizeAIM->tax = $invoice->get_tax();
140 140
                 
141
-                $item_desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) );
141
+                $item_desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true));
142 142
             }
143 143
             
144
-            if ( $invoice->get_discount() > 0 ) {
145
-                $item_desc .= ', ' . wp_sprintf( __( 'Discount: %s', 'invoicing' ), $invoice->get_discount( true ) );
144
+            if ($invoice->get_discount() > 0) {
145
+                $item_desc .= ', ' . wp_sprintf(__('Discount: %s', 'invoicing'), $invoice->get_discount(true));
146 146
             }
147 147
             
148
-            $authorizeAIM->description  = html_entity_decode( $item_desc , ENT_QUOTES, 'UTF-8' );
148
+            $authorizeAIM->description = html_entity_decode($item_desc, ENT_QUOTES, 'UTF-8');
149 149
             
150 150
             $is_recurring = $invoice->is_recurring(); // Recurring payment.
151 151
             
152
-            if ( $is_recurring ) {
152
+            if ($is_recurring) {
153 153
                 $authorizeAIM->recurring_billing = true;
154 154
             }
155 155
             
156 156
             try {
157
-                if ( $is_recurring ) {
157
+                if ($is_recurring) {
158 158
                     $response = $authorizeAIM->authorizeOnly();
159 159
                 } else {
160 160
                     $response = $authorizeAIM->authorizeAndCapture();
161 161
                 }
162 162
                 
163
-                if ( $response->approved || $response->held ) {
164
-                    if ( $response->approved ) {
165
-                        wpinv_update_payment_status( $invoice_id, 'publish' );
163
+                if ($response->approved || $response->held) {
164
+                    if ($response->approved) {
165
+                        wpinv_update_payment_status($invoice_id, 'publish');
166 166
                     }
167
-                    wpinv_set_payment_transaction_id( $invoice_id, $response->transaction_id );
167
+                    wpinv_set_payment_transaction_id($invoice_id, $response->transaction_id);
168 168
                     
169
-                    $message = wp_sprintf( __( 'Authorize.Net Payment: %s with transaction id %s using %s and authorization code %s', 'invoicing' ), $response->response_reason_text, $response->transaction_id, strtoupper( $response->transaction_type ), $response->authorization_code );
169
+                    $message = wp_sprintf(__('Authorize.Net Payment: %s with transaction id %s using %s and authorization code %s', 'invoicing'), $response->response_reason_text, $response->transaction_id, strtoupper($response->transaction_type), $response->authorization_code);
170 170
                     
171
-                    wpinv_insert_payment_note( $invoice_id, $message );
171
+                    wpinv_insert_payment_note($invoice_id, $message);
172 172
                     
173
-                    do_action( 'wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card );
173
+                    do_action('wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card);
174 174
                     
175 175
                     wpinv_clear_errors();
176 176
                     wpinv_empty_cart();
177 177
                     
178
-                    wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
178
+                    wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
179 179
                 } else {
180
-                    if ( !empty( $response->response_reason_text ) ) {
181
-                        $error = __( $response->response_reason_text, 'invoicing' );
182
-                    } else if ( !empty( $response->error_message ) ) {
183
-                        $error = __( $response->error_message, 'invoicing' );
180
+                    if (!empty($response->response_reason_text)) {
181
+                        $error = __($response->response_reason_text, 'invoicing');
182
+                    } else if (!empty($response->error_message)) {
183
+                        $error = __($response->error_message, 'invoicing');
184 184
                     } else {
185
-                        $error = wp_sprintf( __( 'Error data: %s', 'invoicing' ), print_r( $response, true ) );
185
+                        $error = wp_sprintf(__('Error data: %s', 'invoicing'), print_r($response, true));
186 186
                     } 
187 187
                     
188
-                    $error = wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $error );
188
+                    $error = wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $error);
189 189
                     
190
-                    wpinv_set_error( 'payment_error', $error );
191
-                    wpinv_record_gateway_error( $error, $response );
192
-                    wpinv_insert_payment_note( $invoice_id, $error );
190
+                    wpinv_set_error('payment_error', $error);
191
+                    wpinv_record_gateway_error($error, $response);
192
+                    wpinv_insert_payment_note($invoice_id, $error);
193 193
                     
194
-                    wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
194
+                    wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
195 195
                 }
196
-            } catch ( AuthorizeNetException $e ) {
197
-                wpinv_set_error( 'request_error', $e->getMessage() );
198
-                wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $e->getMessage() ) );
199
-                wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
196
+            } catch (AuthorizeNetException $e) {
197
+                wpinv_set_error('request_error', $e->getMessage());
198
+                wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $e->getMessage()));
199
+                wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
200 200
             }
201 201
         } else {
202
-            wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
202
+            wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
203 203
         }
204 204
     } else {
205
-        wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.net payment. Payment data: %s', 'invoicing' ), print_r( $payment_data, true ) ), $invoice );
206
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
205
+        wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.net payment. Payment data: %s', 'invoicing'), print_r($payment_data, true)), $invoice);
206
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
207 207
     }
208 208
 }
209
-add_action( 'wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment' );
209
+add_action('wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment');
210 210
 
211
-function wpinv_authorizenet_cancel_subscription( $subscription_id = '' ) {
212
-    if ( empty( $subscription_id ) ) {
211
+function wpinv_authorizenet_cancel_subscription($subscription_id = '') {
212
+    if (empty($subscription_id)) {
213 213
         return false;
214 214
     }
215 215
     
216 216
     try {
217 217
         $authnetXML = wpinv_authorizenet_XML();
218
-        $authnetXML->ARBCancelSubscriptionRequest( array( 'subscriptionId' => $subscription_id ) );
218
+        $authnetXML->ARBCancelSubscriptionRequest(array('subscriptionId' => $subscription_id));
219 219
 
220 220
         return $authnetXML->isSuccessful();
221
-    } catch( Exception $e ) {
222
-        wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) );
221
+    } catch (Exception $e) {
222
+        wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing'));
223 223
     }
224 224
     
225 225
     return false;
226 226
 }
227 227
 
228
-function wpinv_authorizenet_valid_ipn( $md5_hash, $transaction_id, $amount ) {
229
-    $authorizenet_md5_hash = wpinv_get_option( 'authorizenet_md5_hash' );
230
-    if ( empty( $authorizenet_md5_hash ) ) {
228
+function wpinv_authorizenet_valid_ipn($md5_hash, $transaction_id, $amount) {
229
+    $authorizenet_md5_hash = wpinv_get_option('authorizenet_md5_hash');
230
+    if (empty($authorizenet_md5_hash)) {
231 231
         return true;
232 232
     }
233 233
     
234
-    $compare_md5 = strtoupper( md5( $authorizenet_md5_hash . $transaction_id . $amount ) );
234
+    $compare_md5 = strtoupper(md5($authorizenet_md5_hash . $transaction_id . $amount));
235 235
     
236
-    return hash_equals( $compare_md5, $md5_hash );
236
+    return hash_equals($compare_md5, $md5_hash);
237 237
 }
238 238
 
239 239
 function wpinv_authorizenet_AIM() {
240
-    if ( !class_exists( 'AuthorizeNetException' ) ) {
241
-        require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php';
240
+    if (!class_exists('AuthorizeNetException')) {
241
+        require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php';
242 242
     }
243 243
     
244
-    $authorizeAIM = new AuthorizeNetAIM( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ) );
244
+    $authorizeAIM = new AuthorizeNetAIM(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'));
245 245
     
246
-    if ( wpinv_is_test_mode( 'authorizenet' ) ) {
247
-        $authorizeAIM->setSandbox( true );
246
+    if (wpinv_is_test_mode('authorizenet')) {
247
+        $authorizeAIM->setSandbox(true);
248 248
     } else {
249
-        $authorizeAIM->setSandbox( false );
249
+        $authorizeAIM->setSandbox(false);
250 250
     }
251 251
     
252 252
     $authorizeAIM->customer_ip = wpinv_get_ip();
@@ -255,164 +255,164 @@  discard block
 block discarded – undo
255 255
 }
256 256
 
257 257
 function wpinv_authorizenet_XML() {
258
-    if ( !class_exists( 'AuthnetXML' ) ) {
259
-        require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php';
258
+    if (!class_exists('AuthnetXML')) {
259
+        require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php';
260 260
     }
261 261
     
262
-    $authnetXML = new AuthnetXML( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ), (bool)wpinv_is_test_mode( 'authorizenet' ) );
262
+    $authnetXML = new AuthnetXML(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'), (bool)wpinv_is_test_mode('authorizenet'));
263 263
     
264 264
     return $authnetXML;
265 265
 }
266 266
 
267
-function wpinv_authorizenet_handle_response( $response, $invoice, $card_info = array() ) {
268
-    if ( empty( $response ) || empty( $invoice ) ) {
267
+function wpinv_authorizenet_handle_response($response, $invoice, $card_info = array()) {
268
+    if (empty($response) || empty($invoice)) {
269 269
         return false;
270 270
     }
271 271
     
272
-    if ( !empty( $response->approved ) ) {
273
-        $subscription = wpinv_authorizenet_create_new_subscription( $invoice, $response, $card_info );
272
+    if (!empty($response->approved)) {
273
+        $subscription = wpinv_authorizenet_create_new_subscription($invoice, $response, $card_info);
274 274
 
275
-        if ( !empty( $subscription ) && $subscription->isSuccessful() ) {
276
-            do_action( 'wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet' );
275
+        if (!empty($subscription) && $subscription->isSuccessful()) {
276
+            do_action('wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet');
277 277
             
278
-            wpinv_authorizenet_subscription_record_signup( $subscription, $invoice );
278
+            wpinv_authorizenet_subscription_record_signup($subscription, $invoice);
279 279
             
280
-            do_action( 'wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet' );
280
+            do_action('wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet');
281 281
         } else {
282
-            if ( isset( $subscription->messages->message ) ) {
282
+            if (isset($subscription->messages->message)) {
283 283
                 $error = $subscription->messages->message->code . ': ' . $subscription->messages->message->text;
284
-                wpinv_set_error( 'wpinv_authorize_recurring_error', $error, 'invoicing' );
284
+                wpinv_set_error('wpinv_authorize_recurring_error', $error, 'invoicing');
285 285
             } else {
286
-                $error = __( 'Your subscription cannot be created due to an error.', 'invoicing' );
287
-                wpinv_set_error( 'wpinv_authorize_recurring_error', $error );
286
+                $error = __('Your subscription cannot be created due to an error.', 'invoicing');
287
+                wpinv_set_error('wpinv_authorize_recurring_error', $error);
288 288
             }
289 289
             
290
-            wpinv_record_gateway_error( $error, $subscription );
290
+            wpinv_record_gateway_error($error, $subscription);
291 291
             
292
-            wpinv_insert_payment_note( $invoice->ID, wp_sprintf( __( 'Authorize.Net subscription error occurred. %s', 'invoicing' ), $error ) );
292
+            wpinv_insert_payment_note($invoice->ID, wp_sprintf(__('Authorize.Net subscription error occurred. %s', 'invoicing'), $error));
293 293
         }
294 294
     }
295 295
 }
296
-add_action( 'wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3 );
296
+add_action('wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3);
297 297
 
298
-function wpinv_authorizenet_create_new_subscription( $invoice, $response = array(), $card_info = array() ) {
299
-    if ( empty( $invoice ) ) {
298
+function wpinv_authorizenet_create_new_subscription($invoice, $response = array(), $card_info = array()) {
299
+    if (empty($invoice)) {
300 300
         return false;
301 301
     }
302 302
     
303
-    $params = wpinv_authorizenet_generate_subscription_params( $invoice, $card_info, $response );
303
+    $params = wpinv_authorizenet_generate_subscription_params($invoice, $card_info, $response);
304 304
     
305 305
     try {
306 306
         $authnetXML = wpinv_authorizenet_XML();
307
-        $authnetXML->ARBCreateSubscriptionRequest( $params );
308
-    } catch( Exception $e ) {
307
+        $authnetXML->ARBCreateSubscriptionRequest($params);
308
+    } catch (Exception $e) {
309 309
         $authnetXML = array();
310
-        wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) );
310
+        wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing'));
311 311
     }
312 312
     
313 313
     return $authnetXML;
314 314
 }
315 315
 
316
-function wpinv_authorizenet_generate_subscription_params( $invoice, $card_info = array(), $response = array() ) {
317
-    if ( empty( $invoice ) ) {
316
+function wpinv_authorizenet_generate_subscription_params($invoice, $card_info = array(), $response = array()) {
317
+    if (empty($invoice)) {
318 318
         return false;
319 319
     }
320 320
     
321
-    $subscription_item = $invoice->get_recurring( true );
322
-    if ( empty( $subscription_item ) ) {
321
+    $subscription_item = $invoice->get_recurring(true);
322
+    if (empty($subscription_item)) {
323 323
         return false;
324 324
     }
325 325
     
326
-    $card_details       = wpinv_authorizenet_generate_card_info( $card_info );
326
+    $card_details       = wpinv_authorizenet_generate_card_info($card_info);
327 327
     $subscription_name  = $invoice->get_subscription_name();
328
-    $initial_amount     = wpinv_format_amount( $invoice->get_total() );
329
-    $recurring_amount   = wpinv_format_amount( $invoice->get_recurring_details( 'total' ) );
328
+    $initial_amount     = wpinv_format_amount($invoice->get_total());
329
+    $recurring_amount   = wpinv_format_amount($invoice->get_recurring_details('total'));
330 330
     $interval           = $subscription_item->get_recurring_interval();
331 331
     $period             = $subscription_item->get_recurring_period();
332 332
     $bill_times         = (int)$subscription_item->get_recurring_limit();
333 333
     $bill_times         = $bill_times > 0 ? $bill_times : 9999;
334 334
     
335
-    $time_period        = wpinv_authorizenet_get_time_period( $interval, $period );
335
+    $time_period        = wpinv_authorizenet_get_time_period($interval, $period);
336 336
     $interval           = $time_period['interval'];
337 337
     $period             = $time_period['period'];
338 338
     
339 339
     $current_tz = date_default_timezone_get();
340
-    date_default_timezone_set( 'America/Denver' ); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts.
341
-    $today = date( 'Y-m-d' );
342
-    date_default_timezone_set( $current_tz );
340
+    date_default_timezone_set('America/Denver'); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts.
341
+    $today = date('Y-m-d');
342
+    date_default_timezone_set($current_tz);
343 343
     
344 344
     $free_trial = $invoice->is_free_trial();
345
-    if ( $free_trial && $subscription_item->has_free_trial() ) {
345
+    if ($free_trial && $subscription_item->has_free_trial()) {
346 346
         $trial_interval    = $subscription_item->get_trial_interval();
347
-        $trial_period      = $subscription_item->get_trial_period( true );
347
+        $trial_period      = $subscription_item->get_trial_period(true);
348 348
     }
349 349
     
350 350
     $subscription = array();
351 351
     $subscription['name'] = $subscription_name;
352 352
     
353 353
     $subscription['paymentSchedule'] = array(
354
-        'interval'         => array( 'length' => $interval, 'unit' => $period ),
354
+        'interval'         => array('length' => $interval, 'unit' => $period),
355 355
         'startDate'        => $today,
356 356
         'totalOccurrences' => $bill_times,
357
-        'trialOccurrences' => $free_trial || ( $initial_amount != $recurring_amount ) ? 1 : 0,
357
+        'trialOccurrences' => $free_trial || ($initial_amount != $recurring_amount) ? 1 : 0,
358 358
     );
359 359
     
360 360
     $subscription['amount'] = $recurring_amount;
361 361
     $subscription['trialAmount'] = $initial_amount;
362
-    $subscription['payment'] = array( 'creditCard' => $card_details );
363
-    $subscription['order'] = array( 'invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number() );
364
-    $subscription['customer'] = array( 'id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone );
362
+    $subscription['payment'] = array('creditCard' => $card_details);
363
+    $subscription['order'] = array('invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number());
364
+    $subscription['customer'] = array('id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone);
365 365
     
366 366
     $subscription['billTo'] = array(
367 367
         'firstName' => $invoice->get_first_name(),
368 368
         'lastName'  => $invoice->get_last_name(),
369 369
         'company'   => $invoice->company,
370
-        'address'   => wp_strip_all_tags( $invoice->get_address(), true ),
370
+        'address'   => wp_strip_all_tags($invoice->get_address(), true),
371 371
         'city'      => $invoice->city,
372 372
         'state'     => $invoice->state,
373 373
         'zip'       => $invoice->zip,
374 374
         'country'   => $invoice->country,
375 375
     );
376 376
     
377
-    $params = array( 'subscription' => $subscription );
377
+    $params = array('subscription' => $subscription);
378 378
     
379
-    return apply_filters( 'wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response );
379
+    return apply_filters('wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response);
380 380
 }
381 381
 
382
-function wpinv_authorizenet_generate_card_info( $card_info = array() ) {
383
-    $card_defaults      = array(
382
+function wpinv_authorizenet_generate_card_info($card_info = array()) {
383
+    $card_defaults = array(
384 384
         'cc_owner'          => null,
385 385
         'cc_number'         => null,
386 386
         'cc_expire_month'   => null,
387 387
         'cc_expire_year'    => null,
388 388
         'cc_cvv2'           => null,
389 389
     );
390
-    $card_info = wp_parse_args( $card_info, $card_defaults );
390
+    $card_info = wp_parse_args($card_info, $card_defaults);
391 391
         
392 392
     $card_details = array(
393
-        'cardNumber'     => str_replace( ' ', '', sanitize_text_field( $card_info['cc_number'] ) ),
394
-        'expirationDate' => sanitize_text_field( $card_info['cc_expire_month'] ) . sanitize_text_field( $card_info['cc_expire_year'] ),
395
-        'cardCode'       => sanitize_text_field( $card_info['cc_cvv2'] ),
393
+        'cardNumber'     => str_replace(' ', '', sanitize_text_field($card_info['cc_number'])),
394
+        'expirationDate' => sanitize_text_field($card_info['cc_expire_month']) . sanitize_text_field($card_info['cc_expire_year']),
395
+        'cardCode'       => sanitize_text_field($card_info['cc_cvv2']),
396 396
     );
397 397
 
398 398
     return $card_details;
399 399
 }
400 400
 
401
-function wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ) {
402
-    if ( empty( $invoice ) || empty( $subscription ) ) {
401
+function wpinv_authorizenet_subscription_record_signup($subscription, $invoice) {
402
+    if (empty($invoice) || empty($subscription)) {
403 403
         return false;
404 404
     }
405 405
     
406
-    $subscription_item = $invoice->get_recurring( true );
407
-    if ( empty( $subscription_item ) ) {
406
+    $subscription_item = $invoice->get_recurring(true);
407
+    if (empty($subscription_item)) {
408 408
         return false;
409 409
     }
410 410
     
411 411
     $invoice_id         = $invoice->ID;
412 412
     $subscriptionId     = (array)$subscription->subscriptionId;
413
-    $subscription_id    = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $invoice_id;
413
+    $subscription_id    = !empty($subscriptionId[0]) ? $subscriptionId[0] : $invoice_id;
414 414
 
415
-    wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Authorize.Net Subscription ID: %s', 'invoicing' ) , $subscription_id ) );
415
+    wpinv_insert_payment_note($invoice_id, sprintf(__('Authorize.Net Subscription ID: %s', 'invoicing'), $subscription_id));
416 416
     
417 417
     $status = $invoice->is_free_trial() && $subscription_item->has_free_trial() ? 'trialing' : 'active';
418 418
     
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
         'profile_id'        => $subscription_id,
421 421
         'item_id'           => $subscription_item->ID,
422 422
         'initial_amount'    => $invoice->get_total(),
423
-        'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
423
+        'recurring_amount'  => $invoice->get_recurring_details('total'),
424 424
         'period'            => $subscription_item->get_recurring_period(),
425 425
         'interval'          => $subscription_item->get_recurring_interval(),
426 426
         'bill_times'        => $subscription_item->get_recurring_limit(),
427
-        'expiration'        => $invoice->get_new_expiration( $subscription_item->ID ),
427
+        'expiration'        => $invoice->get_new_expiration($subscription_item->ID),
428 428
         'status'            => $status,
429
-        'created'           => current_time( 'mysql', 0 )
429
+        'created'           => current_time('mysql', 0)
430 430
     );
431 431
     
432
-    if ( $invoice->is_free_trial() && $subscription_item->has_free_trial() ) {
432
+    if ($invoice->is_free_trial() && $subscription_item->has_free_trial()) {
433 433
         $args['trial_period']      = $subscription_item->get_trial_period();
434 434
         $args['trial_interval']    = $subscription_item->get_trial_interval();
435 435
     } else {
@@ -437,58 +437,58 @@  discard block
 block discarded – undo
437 437
         $args['trial_interval']    = 0;
438 438
     }
439 439
     
440
-    return $invoice->update_subscription( $args );
440
+    return $invoice->update_subscription($args);
441 441
 }
442 442
 
443
-function wpinv_authorizenet_validate_checkout( $valid_data, $post ) {
444
-    if ( !empty( $post['wpi-gateway'] ) && $post['wpi-gateway'] == 'authorizenet' ) {
443
+function wpinv_authorizenet_validate_checkout($valid_data, $post) {
444
+    if (!empty($post['wpi-gateway']) && $post['wpi-gateway'] == 'authorizenet') {
445 445
         $error = false;
446 446
         
447
-        if ( empty( $post['authorizenet']['cc_owner'] ) ) {
447
+        if (empty($post['authorizenet']['cc_owner'])) {
448 448
             $error = true;
449
-            wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing'));
449
+            wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing'));
450 450
         }
451
-        if ( empty( $post['authorizenet']['cc_number'] ) ) {
451
+        if (empty($post['authorizenet']['cc_number'])) {
452 452
             $error = true;
453
-            wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing'));
453
+            wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing'));
454 454
         }
455
-        if ( empty( $post['authorizenet']['cc_expire_month'] ) ) {
455
+        if (empty($post['authorizenet']['cc_expire_month'])) {
456 456
             $error = true;
457
-            wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing'));
457
+            wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing'));
458 458
         }
459
-        if ( empty( $post['authorizenet']['cc_expire_year'] ) ) {
459
+        if (empty($post['authorizenet']['cc_expire_year'])) {
460 460
             $error = true;
461
-            wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing'));
461
+            wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing'));
462 462
         }
463
-        if ( empty( $post['authorizenet']['cc_cvv2'] ) ) {
463
+        if (empty($post['authorizenet']['cc_cvv2'])) {
464 464
             $error = true;
465
-            wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) );
465
+            wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing'));
466 466
         }
467 467
         
468
-        if ( $error ) {
468
+        if ($error) {
469 469
             return;
470 470
         }
471 471
         
472 472
         $invoice = wpinv_get_invoice_cart();
473 473
         
474
-        if ( !empty( $invoice ) && $subscription_item = $invoice->get_recurring( true ) ) {
475
-            $subscription_item = $invoice->get_recurring( true );
474
+        if (!empty($invoice) && $subscription_item = $invoice->get_recurring(true)) {
475
+            $subscription_item = $invoice->get_recurring(true);
476 476
             
477 477
             $interval   = $subscription_item->get_recurring_interval();
478 478
             $period     = $subscription_item->get_recurring_period();
479 479
             
480
-            if ( $period == 'D' && ( $interval < 7 || $interval > 365 ) ) {
481
-                wpinv_set_error( 'authorizenet_subscription_error', __( 'Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing' ) );
480
+            if ($period == 'D' && ($interval < 7 || $interval > 365)) {
481
+                wpinv_set_error('authorizenet_subscription_error', __('Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing'));
482 482
             }
483 483
         }
484 484
     }
485 485
 }
486
-add_action( 'wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2 );
486
+add_action('wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2);
487 487
 
488
-function wpinv_authorizenet_get_time_period( $subscription_interval, $subscription_period ) {
489
-    $subscription_interval = absint( $subscription_interval );
488
+function wpinv_authorizenet_get_time_period($subscription_interval, $subscription_period) {
489
+    $subscription_interval = absint($subscription_interval);
490 490
 
491
-    switch( $subscription_period ) {
491
+    switch ($subscription_period) {
492 492
         case 'W':
493 493
         case 'week':
494 494
         case 'weeks':
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
         case 'M':
499 499
         case 'month':
500 500
         case 'months':
501
-            if ( $subscription_interval > 12 ) {
501
+            if ($subscription_interval > 12) {
502 502
                 $subscription_interval = 12;
503 503
             }
504 504
             
505 505
             $interval = $subscription_interval;
506 506
             $period   = 'months';
507 507
             
508
-            if ( !( $subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12 ) ) {
508
+            if (!($subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12)) {
509 509
                 $interval = $subscription_interval * 30;
510 510
                 $period   = 'days';
511 511
             }
@@ -522,40 +522,40 @@  discard block
 block discarded – undo
522 522
             break;
523 523
     }
524 524
 
525
-    return compact( 'interval', 'period' );
525
+    return compact('interval', 'period');
526 526
 }
527 527
 
528 528
 function wpinv_authorizenet_process_ipn() {
529
-    if ( !( !empty( $_REQUEST['wpi-gateway'] ) && $_REQUEST['wpi-gateway'] == 'authorizenet' ) ) {
529
+    if (!(!empty($_REQUEST['wpi-gateway']) && $_REQUEST['wpi-gateway'] == 'authorizenet')) {
530 530
         return;
531 531
     }
532 532
     
533
-    $subscription_id = intval( $_POST['x_subscription_id'] );
533
+    $subscription_id = intval($_POST['x_subscription_id']);
534 534
     
535
-    if ( $subscription_id ) {
536
-        $transaction_id = sanitize_text_field( $_POST['x_trans_id'] );
537
-        $renewal_amount = sanitize_text_field( $_POST['x_amount'] );
538
-        $response_code  = intval( $_POST['x_response_code'] );
539
-        $reason_code    = intval( $_POST['x_response_reason_code'] );
535
+    if ($subscription_id) {
536
+        $transaction_id = sanitize_text_field($_POST['x_trans_id']);
537
+        $renewal_amount = sanitize_text_field($_POST['x_amount']);
538
+        $response_code  = intval($_POST['x_response_code']);
539
+        $reason_code    = intval($_POST['x_response_reason_code']);
540 540
 
541
-        if ( 1 == $response_code ) {
541
+        if (1 == $response_code) {
542 542
             // Approved
543
-            do_action( 'wpinv_authorizenet_renewal_payment', $transaction_id );
544
-        } else if ( 2 == $response_code ) {
543
+            do_action('wpinv_authorizenet_renewal_payment', $transaction_id);
544
+        } else if (2 == $response_code) {
545 545
             // Declined
546
-            do_action( 'wpinv_authorizenet_renewal_payment_failed', $transaction_id );
547
-            do_action( 'wpinv_authorizenet_renewal_error', $transaction_id );
548
-        } else if ( 3 == $response_code || 8 == $reason_code ) {
546
+            do_action('wpinv_authorizenet_renewal_payment_failed', $transaction_id);
547
+            do_action('wpinv_authorizenet_renewal_error', $transaction_id);
548
+        } else if (3 == $response_code || 8 == $reason_code) {
549 549
             // An expired card
550
-            do_action( 'wpinv_authorizenet_renewal_payment_failed', $transaction_id );
551
-            do_action( 'wpinv_authorizenet_renewal_payment_error', $transaction_id );
550
+            do_action('wpinv_authorizenet_renewal_payment_failed', $transaction_id);
551
+            do_action('wpinv_authorizenet_renewal_payment_error', $transaction_id);
552 552
 
553 553
         } else {
554 554
             // Other Error
555
-            do_action( 'wpinv_authorizenet_renewal_payment_error', $subscription );
555
+            do_action('wpinv_authorizenet_renewal_payment_error', $subscription);
556 556
         }
557 557
         
558 558
         exit;
559 559
     }
560 560
 }
561
-add_action( 'wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn' );
562 561
\ No newline at end of file
562
+add_action('wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn');
563 563
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_manual_cc_form', '__return_false' );
5
+add_action('wpinv_manual_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_manual_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_manual_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     /*
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
     );
42 42
 
43 43
     // Record the pending payment
44
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
44
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
45 45
     
46
-    if ( !empty( $invoice ) ) {        
47
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
48
-        wpinv_update_payment_status( $invoice, 'publish' );
46
+    if (!empty($invoice)) {        
47
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
48
+        wpinv_update_payment_status($invoice, 'publish');
49 49
         
50 50
         // Empty the shopping cart
51 51
         wpinv_empty_cart();
52 52
         
53
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
53
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
54 54
     } else {
55
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
55
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
56 56
         // If errors are present, send the user back to the purchase page so they can be corrected
57
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
57
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
58 58
     }
59 59
 }
60
-add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' );
61 60
\ No newline at end of file
61
+add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment');
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/bank_transfer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_bank_transfer_cc_form', '__return_false' );
5
+add_action('wpinv_bank_transfer_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_bank_transfer_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_bank_transfer_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     // Collect payment data
@@ -24,37 +24,37 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
30
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
31
-        wpinv_update_payment_status( $invoice, 'pending' );
29
+    if (!empty($invoice)) {
30
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
31
+        wpinv_update_payment_status($invoice, 'pending');
32 32
         
33 33
         // Empty the shopping cart
34 34
         wpinv_empty_cart();
35 35
         
36
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
36
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
37 37
     } else {
38
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
38
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
39 39
         // If errors are present, send the user back to the purchase page so they can be corrected
40
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
40
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
41 41
     }
42 42
 }
43
-add_action( 'wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment' );
43
+add_action('wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment');
44 44
 
45
-function wpinv_show_bank_info( $invoice ) {
46
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) {
47
-        $bank_info = wpinv_get_bank_info( true );
45
+function wpinv_show_bank_info($invoice) {
46
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') {
47
+        $bank_info = wpinv_get_bank_info(true);
48 48
         ?>
49 49
         <div class="wpinv-bank-details">
50
-            <?php if ( $instructions = wpinv_get_bank_instructions() ) { ?>
51
-            <div class="alert bg-info"><?php echo wpautop( wp_kses_post( $instructions ) ); ?></div>
50
+            <?php if ($instructions = wpinv_get_bank_instructions()) { ?>
51
+            <div class="alert bg-info"><?php echo wpautop(wp_kses_post($instructions)); ?></div>
52 52
             <?php } ?>
53
-            <?php if ( !empty( $bank_info ) ) { ?>
54
-            <h3 class="wpinv-bank-t"><?php echo apply_filters( 'wpinv_receipt_bank_details_title', __( 'Our Bank Details', 'invoicing' ) ); ?></h3>
53
+            <?php if (!empty($bank_info)) { ?>
54
+            <h3 class="wpinv-bank-t"><?php echo apply_filters('wpinv_receipt_bank_details_title', __('Our Bank Details', 'invoicing')); ?></h3>
55 55
             <table class="table table-bordered table-sm wpi-bank-details">
56
-                <?php foreach ( $bank_info as $key => $info ) { ?>
57
-                <tr class="wpi-<?php echo sanitize_html_class( $key );?>"><th class="text-left"><?php echo $info['label'] ;?></th><td><?php echo $info['value'] ;?></td></tr>
56
+                <?php foreach ($bank_info as $key => $info) { ?>
57
+                <tr class="wpi-<?php echo sanitize_html_class($key); ?>"><th class="text-left"><?php echo $info['label']; ?></th><td><?php echo $info['value']; ?></td></tr>
58 58
                 <?php } ?>
59 59
             </table>
60 60
             <?php } ?>
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
         <?php
63 63
     }
64 64
 }
65
-add_action( 'wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1 );
65
+add_action('wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1);
66 66
 
67
-function wpinv_invoice_print_bank_info( $invoice ) {
68
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending' ) {
67
+function wpinv_invoice_print_bank_info($invoice) {
68
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'pending') {
69 69
         ?>
70 70
         <div class="row wpinv-bank-info">
71
-            <?php echo wpinv_show_bank_info( $invoice ); ?>
71
+            <?php echo wpinv_show_bank_info($invoice); ?>
72 72
         </div>
73 73
         <?php
74 74
     }
75 75
 }
76
-add_action( 'wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1 );
77 76
\ No newline at end of file
77
+add_action('wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1);
78 78
\ No newline at end of file
Please login to merge, or discard this patch.