@@ -10,66 +10,66 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<p class='small'>$description</p>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item price. |
47 | - if ( 'price' == $column ) { |
|
47 | + if ('price' == $column) { |
|
48 | 48 | |
49 | 49 | // Display the item price (or recurring price if this is a renewal invoice) |
50 | 50 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
51 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
51 | + echo wpinv_price($price, $invoice->get_currency()); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo (float) $item->get_quantity(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Tax rate. |
61 | - if ( 'tax_rate' == $column ) { |
|
62 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
61 | + if ('tax_rate' == $column) { |
|
62 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
68 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
68 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Fires when printing a line item column. |
72 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
72 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
73 | 73 | |
74 | 74 | ?> |
75 | 75 | |
@@ -79,4 +79,4 @@ discard block |
||
79 | 79 | |
80 | 80 | </tr> |
81 | 81 | |
82 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
82 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'> |
|
19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'> |
|
20 | 20 | |
21 | 21 | <div class="form-row"> |
22 | 22 | |
23 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
23 | + <?php foreach (array_keys($columns) as $column): ?> |
|
24 | 24 | |
25 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
25 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | 29 | // Fires before printing a line item column. |
30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
31 | 31 | |
32 | 32 | // Item name. |
33 | - if ( 'name' == $column ) { |
|
33 | + if ('name' == $column) { |
|
34 | 34 | |
35 | 35 | // Display the name. |
36 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
36 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
37 | 37 | |
38 | 38 | // And an optional description. |
39 | 39 | $description = $item->get_description(); |
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - $description = wp_kses_post( $description ); |
|
41 | + if (!empty($description)) { |
|
42 | + $description = wp_kses_post($description); |
|
43 | 43 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Fires before printing the line item actions. |
47 | - do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice ); |
|
47 | + do_action("getpaid_before_invoice_line_item_actions", $item, $invoice); |
|
48 | 48 | |
49 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
49 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
50 | 50 | |
51 | - if ( ! empty( $actions ) ) { |
|
51 | + if (!empty($actions)) { |
|
52 | 52 | |
53 | - $sanitized = array(); |
|
54 | - foreach ( $actions as $key => $action ) { |
|
55 | - $key = sanitize_html_class( $key ); |
|
56 | - $action = wp_kses_post( $action ); |
|
53 | + $sanitized = array(); |
|
54 | + foreach ($actions as $key => $action) { |
|
55 | + $key = sanitize_html_class($key); |
|
56 | + $action = wp_kses_post($action); |
|
57 | 57 | $sanitized[] = "<span class='$key'>$action</span>"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | echo "<small class='form-text getpaid-line-item-actions'>"; |
61 | - echo implode( ' | ', $sanitized ); |
|
61 | + echo implode(' | ', $sanitized); |
|
62 | 62 | echo '</small>'; |
63 | 63 | |
64 | 64 | } |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Item price. |
69 | - if ( 'price' == $column ) { |
|
69 | + if ('price' == $column) { |
|
70 | 70 | |
71 | 71 | // Display the item price (or recurring price if this is a renewal invoice) |
72 | 72 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
73 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
73 | + echo wpinv_price($price, $invoice->get_currency()); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Tax rate. |
78 | - if ( 'tax_rate' == $column ) { |
|
79 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
78 | + if ('tax_rate' == $column) { |
|
79 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Item quantity. |
83 | - if ( 'quantity' == $column ) { |
|
83 | + if ('quantity' == $column) { |
|
84 | 84 | echo (float) $item->get_quantity(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Item sub total. |
88 | - if ( 'subtotal' == $column ) { |
|
88 | + if ('subtotal' == $column) { |
|
89 | 89 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
90 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
90 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Fires when printing a line item column. |
94 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
94 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
95 | 95 | |
96 | 96 | // Fires after printing a line item column. |
97 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
97 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
98 | 98 | |
99 | 99 | ?> |
100 | 100 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'tokens', 'addons', 'single_subscription_group', 'multiple_subscription_groups'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | 68 | |
69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
71 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
71 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
72 | 72 | |
73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
74 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
74 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
75 | 75 | parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @param int $invoice_id 0 or invoice id. |
82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
83 | 83 | */ |
84 | - public function payment_fields( $invoice_id, $form ) { |
|
84 | + public function payment_fields($invoice_id, $form) { |
|
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
87 | 87 | echo $this->saved_payment_methods(); |
88 | 88 | |
89 | 89 | // Show the credit card entry form. |
90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,72 +100,72 @@ discard block |
||
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | 101 | * @return string|WP_Error Payment profile id. |
102 | 102 | */ |
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
107 | 107 | |
108 | 108 | // Generate args. |
109 | 109 | $args = array( |
110 | 110 | 'createCustomerProfileRequest' => array( |
111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
112 | 112 | 'profile' => array( |
113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
116 | 116 | 'paymentProfiles' => array( |
117 | 117 | 'customerType' => 'individual', |
118 | 118 | |
119 | 119 | // Billing information. |
120 | 120 | 'billTo' => array( |
121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
123 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
123 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
128 | 128 | ), |
129 | 129 | |
130 | 130 | // Payment information. |
131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
132 | 132 | ) |
133 | 133 | ), |
134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | |
138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
139 | 139 | |
140 | - if ( is_wp_error( $response ) ) { |
|
140 | + if (is_wp_error($response)) { |
|
141 | 141 | |
142 | 142 | // In case the customer profile already exists remotely. |
143 | - if ( 'E00039' == $response->get_error_code() ) { |
|
144 | - $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() ); |
|
145 | - $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id ); |
|
146 | - return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save ); |
|
143 | + if ('E00039' == $response->get_error_code()) { |
|
144 | + $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message()); |
|
145 | + $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id); |
|
146 | + return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $response; |
150 | 150 | } |
151 | 151 | |
152 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
152 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
153 | 153 | |
154 | 154 | // Save the payment token. |
155 | - if ( $save ) { |
|
155 | + if ($save) { |
|
156 | 156 | $this->save_token( |
157 | 157 | array( |
158 | 158 | 'id' => $response->customerPaymentProfileIdList[0], |
159 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
159 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
160 | 160 | 'default' => true, |
161 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
161 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
162 | 162 | ) |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | 166 | // Add a note about the validation response. |
167 | 167 | $invoice->add_note( |
168 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
168 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
169 | 169 | false, |
170 | 170 | false, |
171 | 171 | true |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return string|WP_Error Profile id. |
183 | 183 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
184 | 184 | */ |
185 | - public function get_customer_profile( $profile_id ) { |
|
185 | + public function get_customer_profile($profile_id) { |
|
186 | 186 | |
187 | 187 | // Generate args. |
188 | 188 | $args = array( |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ) |
193 | 193 | ); |
194 | 194 | |
195 | - return $this->post( $args, false ); |
|
195 | + return $this->post($args, false); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
208 | 208 | * @return string|WP_Error Profile id. |
209 | 209 | */ |
210 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
210 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
211 | 211 | |
212 | 212 | // Remove non-digits from the number |
213 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
213 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
214 | 214 | |
215 | 215 | // Prepare card details. |
216 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
216 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
217 | 217 | |
218 | 218 | // Authorize.NET does not support saving the same card twice. |
219 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
219 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
220 | 220 | |
221 | - if ( $cached_information ) { |
|
221 | + if ($cached_information) { |
|
222 | 222 | return $cached_information; |
223 | 223 | } |
224 | 224 | |
@@ -231,52 +231,52 @@ discard block |
||
231 | 231 | |
232 | 232 | // Billing information. |
233 | 233 | 'billTo' => array( |
234 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
235 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
236 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
237 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
238 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
239 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
240 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
234 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
235 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
236 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
237 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
238 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
239 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
240 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
241 | 241 | ), |
242 | 242 | |
243 | 243 | // Payment information. |
244 | 244 | 'payment' => $payment_information |
245 | 245 | ), |
246 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
246 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
247 | 247 | ) |
248 | 248 | ); |
249 | 249 | |
250 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
250 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
251 | 251 | |
252 | - if ( is_wp_error( $response ) ) { |
|
252 | + if (is_wp_error($response)) { |
|
253 | 253 | return $response; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Save the payment token. |
257 | - if ( $save ) { |
|
257 | + if ($save) { |
|
258 | 258 | $this->save_token( |
259 | 259 | array( |
260 | 260 | 'id' => $response->customerPaymentProfileId, |
261 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
261 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
262 | 262 | 'default' => true, |
263 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
263 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Cache payment profile id. |
269 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
269 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
270 | 270 | |
271 | 271 | // Add a note about the validation response. |
272 | 272 | $invoice->add_note( |
273 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
273 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
274 | 274 | false, |
275 | 275 | false, |
276 | 276 | true |
277 | 277 | ); |
278 | 278 | |
279 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile ); |
|
279 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile); |
|
280 | 280 | |
281 | 281 | return $response->customerPaymentProfileId; |
282 | 282 | } |
@@ -288,12 +288,12 @@ discard block |
||
288 | 288 | * @param array $payment_details. |
289 | 289 | * @return array|false Profile id. |
290 | 290 | */ |
291 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
291 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
292 | 292 | |
293 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
294 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
293 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
294 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
295 | 295 | |
296 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
296 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | 'getCustomerPaymentProfileRequest' => array( |
303 | 303 | 'merchantAuthentication' => $this->get_auth_params(), |
304 | 304 | 'customerProfileId' => $customer_profile, |
305 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
305 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
306 | 306 | ) |
307 | 307 | ); |
308 | 308 | |
309 | - $response = $this->post( $args, $invoice ); |
|
309 | + $response = $this->post($args, $invoice); |
|
310 | 310 | |
311 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
311 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | * @param array $payment_details. |
320 | 320 | * @param string $payment_profile_id. |
321 | 321 | */ |
322 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
322 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
323 | 323 | |
324 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
325 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
326 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
324 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
325 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
326 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
327 | 327 | |
328 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
329 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
328 | + $cached_information[$payment_details] = $payment_profile_id; |
|
329 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
330 | 330 | |
331 | 331 | } |
332 | 332 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return string|WP_Error Profile id. |
340 | 340 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
341 | 341 | */ |
342 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
342 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
343 | 343 | |
344 | 344 | // Generate args. |
345 | 345 | $args = array( |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | |
353 | - return $this->post( $args, false ); |
|
353 | + return $this->post($args, false); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
364 | 364 | * @return WP_Error|object |
365 | 365 | */ |
366 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
366 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
367 | 367 | |
368 | 368 | // Generate args. |
369 | 369 | $args = array( |
@@ -383,28 +383,28 @@ discard block |
||
383 | 383 | ) |
384 | 384 | ), |
385 | 385 | 'order' => array( |
386 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
386 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
387 | 387 | ), |
388 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
388 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
389 | 389 | 'tax' => array( |
390 | 390 | 'amount' => $invoice->get_total_tax(), |
391 | - 'name' => __( 'TAX', 'invoicing' ), |
|
391 | + 'name' => __('TAX', 'invoicing'), |
|
392 | 392 | ), |
393 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
393 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
394 | 394 | 'customer' => array( |
395 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
396 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
395 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
396 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
397 | 397 | ), |
398 | 398 | 'customerIP' => $invoice->get_ip(), |
399 | 399 | ) |
400 | 400 | ) |
401 | 401 | ); |
402 | 402 | |
403 | - if ( 0 == $invoice->get_total_tax() ) { |
|
404 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
403 | + if (0 == $invoice->get_total_tax()) { |
|
404 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
405 | 405 | } |
406 | 406 | |
407 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
407 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
@@ -414,29 +414,29 @@ discard block |
||
414 | 414 | * @param stdClass $result Api response. |
415 | 415 | * @param WPInv_Invoice $invoice Invoice. |
416 | 416 | */ |
417 | - public function process_charge_response( $result, $invoice ) { |
|
417 | + public function process_charge_response($result, $invoice) { |
|
418 | 418 | |
419 | 419 | wpinv_clear_errors(); |
420 | 420 | $response_code = (int) $result->transactionResponse->responseCode; |
421 | 421 | |
422 | 422 | // Succeeded. |
423 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
423 | + if (1 == $response_code || 4 == $response_code) { |
|
424 | 424 | |
425 | 425 | // Maybe set a transaction id. |
426 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
427 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
426 | + if (!empty($result->transactionResponse->transId)) { |
|
427 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
428 | 428 | } |
429 | 429 | |
430 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
430 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
431 | 431 | |
432 | - if ( 1 == $response_code ) { |
|
432 | + if (1 == $response_code) { |
|
433 | 433 | return $invoice->mark_paid(); |
434 | 434 | } |
435 | 435 | |
436 | - $invoice->set_status( 'wpi-onhold' ); |
|
436 | + $invoice->set_status('wpi-onhold'); |
|
437 | 437 | $invoice->add_note( |
438 | 438 | sprintf( |
439 | - __( 'Held for review: %s', 'invoicing' ), |
|
439 | + __('Held for review: %s', 'invoicing'), |
|
440 | 440 | $result->transactionResponse->messages->message[0]->description |
441 | 441 | ) |
442 | 442 | ); |
@@ -445,11 +445,11 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
448 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
449 | 449 | |
450 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
450 | + if (!empty($result->transactionResponse->errors)) { |
|
451 | 451 | $errors = (object) $result->transactionResponse->errors; |
452 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
452 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | } |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | * @param array $card Card details. |
462 | 462 | * @return array |
463 | 463 | */ |
464 | - public function get_payment_information( $card ) { |
|
464 | + public function get_payment_information($card) { |
|
465 | 465 | return array( |
466 | 466 | |
467 | - 'creditCard' => array ( |
|
467 | + 'creditCard' => array( |
|
468 | 468 | 'cardNumber' => $card['cc_number'], |
469 | 469 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
470 | 470 | 'cardCode' => $card['cc_cvv2'], |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | * @param WPInv_Invoice $invoice Invoice. |
481 | 481 | * @return string |
482 | 482 | */ |
483 | - public function get_customer_profile_meta_name( $invoice ) { |
|
484 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
483 | + public function get_customer_profile_meta_name($invoice) { |
|
484 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -492,34 +492,34 @@ discard block |
||
492 | 492 | * @param WPInv_Invoice $invoice |
493 | 493 | * @return WP_Error|string The payment profile id |
494 | 494 | */ |
495 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
495 | + public function validate_submission_data($submission_data, $invoice) { |
|
496 | 496 | |
497 | 497 | // Validate authentication details. |
498 | 498 | $auth = $this->get_auth_params(); |
499 | 499 | |
500 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
501 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
500 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
501 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | // Validate the payment method. |
505 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
506 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
505 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
506 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | // Are we adding a new payment method? |
510 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
510 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
511 | 511 | return $submission_data['getpaid-authorizenet-payment-method']; |
512 | 512 | } |
513 | 513 | |
514 | 514 | // Retrieve the customer profile id. |
515 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
515 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
516 | 516 | |
517 | 517 | // Create payment method. |
518 | - if ( empty( $profile_id ) ) { |
|
519 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
518 | + if (empty($profile_id)) { |
|
519 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
520 | 520 | } |
521 | 521 | |
522 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
522 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
523 | 523 | |
524 | 524 | } |
525 | 525 | |
@@ -530,32 +530,32 @@ discard block |
||
530 | 530 | * @param WPInv_Invoice $invoice Invoice. |
531 | 531 | * @return array |
532 | 532 | */ |
533 | - public function get_line_items( $invoice ) { |
|
533 | + public function get_line_items($invoice) { |
|
534 | 534 | $items = array(); |
535 | 535 | |
536 | - foreach ( $invoice->get_items() as $item ) { |
|
536 | + foreach ($invoice->get_items() as $item) { |
|
537 | 537 | |
538 | 538 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
539 | 539 | $items[] = array( |
540 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
541 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
542 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
543 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
540 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
541 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
542 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
543 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
544 | 544 | 'unitPrice' => (float) $amount, |
545 | 545 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
546 | 546 | ); |
547 | 547 | |
548 | 548 | } |
549 | 549 | |
550 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
550 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
551 | 551 | |
552 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
552 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
553 | 553 | |
554 | - if ( $amount > 0 ) { |
|
554 | + if ($amount > 0) { |
|
555 | 555 | $items[] = array( |
556 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
557 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
558 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
556 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
557 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
558 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
559 | 559 | 'quantity' => '1', |
560 | 560 | 'unitPrice' => (float) $amount, |
561 | 561 | 'taxable' => false, |
@@ -576,36 +576,36 @@ discard block |
||
576 | 576 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
577 | 577 | * @return array |
578 | 578 | */ |
579 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
579 | + public function process_payment($invoice, $submission_data, $submission) { |
|
580 | 580 | |
581 | 581 | // Validate the submitted data. |
582 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
582 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
583 | 583 | |
584 | 584 | // Do we have an error? |
585 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
586 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
587 | - wpinv_send_back_to_checkout( $invoice ); |
|
585 | + if (is_wp_error($payment_profile_id)) { |
|
586 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
587 | + wpinv_send_back_to_checkout($invoice); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | // Save the payment method to the order. |
591 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
591 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
592 | 592 | |
593 | 593 | // Check if this is a subscription or not. |
594 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
595 | - if ( ! empty( $subscriptions ) ) { |
|
596 | - $this->process_subscription( $invoice, $subscriptions ); |
|
594 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
595 | + if (!empty($subscriptions)) { |
|
596 | + $this->process_subscription($invoice, $subscriptions); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | // If it is free, send to the success page. |
600 | - if ( ! $invoice->needs_payment() ) { |
|
600 | + if (!$invoice->needs_payment()) { |
|
601 | 601 | $invoice->mark_paid(); |
602 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
602 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | // Charge the payment profile. |
606 | - $this->process_initial_payment( $invoice ); |
|
606 | + $this->process_initial_payment($invoice); |
|
607 | 607 | |
608 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
608 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
609 | 609 | |
610 | 610 | exit; |
611 | 611 | |
@@ -616,23 +616,23 @@ discard block |
||
616 | 616 | * |
617 | 617 | * @param WPInv_Invoice $invoice Invoice. |
618 | 618 | */ |
619 | - protected function process_initial_payment( $invoice ) { |
|
619 | + protected function process_initial_payment($invoice) { |
|
620 | 620 | |
621 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
622 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
623 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
621 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
622 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
623 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
624 | 624 | |
625 | 625 | // Do we have an error? |
626 | - if ( is_wp_error( $result ) ) { |
|
627 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
628 | - wpinv_send_back_to_checkout( $invoice ); |
|
626 | + if (is_wp_error($result)) { |
|
627 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
628 | + wpinv_send_back_to_checkout($invoice); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | // Process the response. |
632 | - $this->process_charge_response( $result, $invoice ); |
|
632 | + $this->process_charge_response($result, $invoice); |
|
633 | 633 | |
634 | - if ( wpinv_get_errors() ) { |
|
635 | - wpinv_send_back_to_checkout( $invoice ); |
|
634 | + if (wpinv_get_errors()) { |
|
635 | + wpinv_send_back_to_checkout($invoice); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | } |
@@ -643,30 +643,30 @@ discard block |
||
643 | 643 | * @param WPInv_Invoice $invoice Invoice. |
644 | 644 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
645 | 645 | */ |
646 | - public function process_subscription( $invoice, $subscriptions ) { |
|
646 | + public function process_subscription($invoice, $subscriptions) { |
|
647 | 647 | |
648 | 648 | // Check if there is an initial amount to charge. |
649 | - if ( (float) $invoice->get_total() > 0 ) { |
|
650 | - $this->process_initial_payment( $invoice ); |
|
649 | + if ((float) $invoice->get_total() > 0) { |
|
650 | + $this->process_initial_payment($invoice); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | // Activate the subscriptions. |
654 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
654 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
655 | 655 | |
656 | - foreach ( $subscriptions as $subscription ) { |
|
657 | - if ( $subscription->exists() ) { |
|
658 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
659 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
656 | + foreach ($subscriptions as $subscription) { |
|
657 | + if ($subscription->exists()) { |
|
658 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
659 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
660 | 660 | |
661 | - $subscription->set_next_renewal_date( $expiry ); |
|
662 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
663 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
661 | + $subscription->set_next_renewal_date($expiry); |
|
662 | + $subscription->set_date_created(current_time('mysql')); |
|
663 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
664 | 664 | $subscription->activate(); |
665 | 665 | } |
666 | 666 | } |
667 | 667 | |
668 | 668 | // Redirect to the success page. |
669 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
669 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
670 | 670 | |
671 | 671 | } |
672 | 672 | |
@@ -677,20 +677,20 @@ discard block |
||
677 | 677 | * @param bool $should_expire |
678 | 678 | * @param WPInv_Subscription $subscription |
679 | 679 | */ |
680 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
680 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
681 | 681 | |
682 | 682 | // Ensure its our subscription && it's active. |
683 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
683 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
684 | 684 | return $should_expire; |
685 | 685 | } |
686 | 686 | |
687 | 687 | // If this is the last renewal, complete the subscription. |
688 | - if ( $subscription->is_last_renewal() ) { |
|
688 | + if ($subscription->is_last_renewal()) { |
|
689 | 689 | $subscription->complete(); |
690 | 690 | return false; |
691 | 691 | } |
692 | 692 | |
693 | - $this->renew_subscription( $subscription ); |
|
693 | + $this->renew_subscription($subscription); |
|
694 | 694 | |
695 | 695 | return false; |
696 | 696 | |
@@ -701,28 +701,28 @@ discard block |
||
701 | 701 | * |
702 | 702 | * @param WPInv_Subscription $subscription |
703 | 703 | */ |
704 | - public function renew_subscription( $subscription ) { |
|
704 | + public function renew_subscription($subscription) { |
|
705 | 705 | |
706 | 706 | // Generate the renewal invoice. |
707 | 707 | $new_invoice = $subscription->create_payment(); |
708 | 708 | $old_invoice = $subscription->get_parent_payment(); |
709 | 709 | |
710 | - if ( empty( $new_invoice ) ) { |
|
711 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
710 | + if (empty($new_invoice)) { |
|
711 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
712 | 712 | $subscription->failing(); |
713 | 713 | return; |
714 | 714 | } |
715 | 715 | |
716 | 716 | // Charge the payment method. |
717 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
718 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
719 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
717 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
718 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
719 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
720 | 720 | |
721 | 721 | // Do we have an error? |
722 | - if ( is_wp_error( $result ) ) { |
|
722 | + if (is_wp_error($result)) { |
|
723 | 723 | |
724 | 724 | $old_invoice->add_note( |
725 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
725 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
726 | 726 | true, |
727 | 727 | false, |
728 | 728 | true |
@@ -733,12 +733,12 @@ discard block |
||
733 | 733 | } |
734 | 734 | |
735 | 735 | // Process the response. |
736 | - $this->process_charge_response( $result, $new_invoice ); |
|
736 | + $this->process_charge_response($result, $new_invoice); |
|
737 | 737 | |
738 | - if ( wpinv_get_errors() ) { |
|
738 | + if (wpinv_get_errors()) { |
|
739 | 739 | |
740 | 740 | $old_invoice->add_note( |
741 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
741 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
742 | 742 | true, |
743 | 743 | false, |
744 | 744 | true |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | - $subscription->add_payment( array(), $new_invoice ); |
|
751 | + $subscription->add_payment(array(), $new_invoice); |
|
752 | 752 | $subscription->renew(); |
753 | 753 | } |
754 | 754 | |
@@ -759,34 +759,34 @@ discard block |
||
759 | 759 | * @param GetPaid_Form_Item[] $items |
760 | 760 | * @return WPInv_Invoice |
761 | 761 | */ |
762 | - public function process_addons( $invoice, $items ) { |
|
762 | + public function process_addons($invoice, $items) { |
|
763 | 763 | |
764 | 764 | global $getpaid_authorize_addons; |
765 | 765 | |
766 | 766 | $getpaid_authorize_addons = array(); |
767 | - foreach ( $items as $item ) { |
|
767 | + foreach ($items as $item) { |
|
768 | 768 | |
769 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
769 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
770 | 770 | $getpaid_authorize_addons[] = $item; |
771 | 771 | } |
772 | 772 | |
773 | 773 | } |
774 | 774 | |
775 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
775 | + if (empty($getpaid_authorize_addons)) { |
|
776 | 776 | return; |
777 | 777 | } |
778 | 778 | |
779 | 779 | $invoice->recalculate_total(); |
780 | 780 | |
781 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
782 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
781 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
782 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
783 | 783 | |
784 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
785 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
786 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
784 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
785 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
786 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
787 | 787 | |
788 | - if ( is_wp_error( $result ) ) { |
|
789 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
788 | + if (is_wp_error($result)) { |
|
789 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
790 | 790 | return; |
791 | 791 | } |
792 | 792 | |
@@ -799,19 +799,19 @@ discard block |
||
799 | 799 | * @param array $args |
800 | 800 | * @return array |
801 | 801 | */ |
802 | - public function filter_addons_request( $args ) { |
|
802 | + public function filter_addons_request($args) { |
|
803 | 803 | |
804 | 804 | global $getpaid_authorize_addons; |
805 | 805 | $total = 0; |
806 | 806 | |
807 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
807 | + foreach ($getpaid_authorize_addons as $addon) { |
|
808 | 808 | $total += $addon->get_sub_total(); |
809 | 809 | } |
810 | 810 | |
811 | 811 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
812 | 812 | |
813 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
814 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
813 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
814 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | return $args; |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | public function sandbox_notice() { |
825 | 825 | |
826 | 826 | return sprintf( |
827 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
827 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
828 | 828 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
829 | 829 | '</a>' |
830 | 830 | ); |
@@ -836,42 +836,42 @@ discard block |
||
836 | 836 | * |
837 | 837 | * @param array $admin_settings |
838 | 838 | */ |
839 | - public function admin_settings( $admin_settings ) { |
|
839 | + public function admin_settings($admin_settings) { |
|
840 | 840 | |
841 | 841 | $currencies = sprintf( |
842 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
843 | - implode( ', ', $this->currencies ) |
|
842 | + __('Supported Currencies: %s', 'invoicing'), |
|
843 | + implode(', ', $this->currencies) |
|
844 | 844 | ); |
845 | 845 | |
846 | 846 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
847 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
847 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
848 | 848 | |
849 | 849 | $admin_settings['authorizenet_login_id'] = array( |
850 | 850 | 'type' => 'text', |
851 | 851 | 'id' => 'authorizenet_login_id', |
852 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
853 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
852 | + 'name' => __('API Login ID', 'invoicing'), |
|
853 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
854 | 854 | ); |
855 | 855 | |
856 | 856 | $admin_settings['authorizenet_transaction_key'] = array( |
857 | 857 | 'type' => 'text', |
858 | 858 | 'id' => 'authorizenet_transaction_key', |
859 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
859 | + 'name' => __('Transaction Key', 'invoicing'), |
|
860 | 860 | ); |
861 | 861 | |
862 | 862 | $admin_settings['authorizenet_signature_key'] = array( |
863 | 863 | 'type' => 'text', |
864 | 864 | 'id' => 'authorizenet_signature_key', |
865 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
866 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
865 | + 'name' => __('Signature Key', 'invoicing'), |
|
866 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
867 | 867 | ); |
868 | 868 | |
869 | 869 | $admin_settings['authorizenet_ipn_url'] = array( |
870 | 870 | 'type' => 'ipn_url', |
871 | 871 | 'id' => 'authorizenet_ipn_url', |
872 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
872 | + 'name' => __('Webhook URL', 'invoicing'), |
|
873 | 873 | 'std' => $this->notify_url, |
874 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
874 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
875 | 875 | 'custom' => 'authorizenet', |
876 | 876 | 'readonly' => true, |
877 | 877 | ); |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | |
20 | 20 | // Define constants. |
21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
26 | - define( 'WPINV_VERSION', '2.3.3' ); |
|
26 | + define( 'WPINV_VERSION', '2.3.3' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
46 | - return $GLOBALS['invoicing']; |
|
46 | + return $GLOBALS['invoicing']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '2.3.3' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.3.3'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 2.0.8 |
53 | 53 | */ |
54 | 54 | function getpaid_deactivation_hook() { |
55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
55 | + update_option('wpinv_flush_permalinks', 1); |
|
56 | 56 | } |
57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Kickstart the plugin. |
67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', -100); |