@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | * Check if this gateway is enabled |
19 | 19 | */ |
20 | 20 | public function is_available() { |
21 | - if ( 'yes' === $this->enabled ) { |
|
22 | - if ( ! $this->testmode && is_checkout() && ! is_ssl() ) { |
|
21 | + if ('yes' === $this->enabled) { |
|
22 | + if ( ! $this->testmode && is_checkout() && ! is_ssl()) { |
|
23 | 23 | return false; |
24 | 24 | } |
25 | - if ( ! $this->secret_key || ! $this->publishable_key ) { |
|
25 | + if ( ! $this->secret_key || ! $this->publishable_key) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | return true; |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * @since 4.0.0 |
38 | 38 | * @version 4.0.0 |
39 | 39 | */ |
40 | - public function add_admin_notice( $slug, $class, $message ) { |
|
41 | - $this->notices[ $slug ] = array( |
|
40 | + public function add_admin_notice($slug, $class, $message) { |
|
41 | + $this->notices[$slug] = array( |
|
42 | 42 | 'class' => $class, |
43 | 43 | 'message' => $message, |
44 | 44 | ); |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @version 4.0.0 |
52 | 52 | */ |
53 | 53 | public function remove_admin_notice() { |
54 | - if ( did_action( 'woocommerce_update_options' ) ) { |
|
55 | - remove_action( 'admin_notices', array( $this, 'check_environment' ) ); |
|
54 | + if (did_action('woocommerce_update_options')) { |
|
55 | + remove_action('admin_notices', array($this, 'check_environment')); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | */ |
66 | 66 | public function payment_icons() { |
67 | - return apply_filters( 'wc_stripe_payment_icons', array( |
|
67 | + return apply_filters('wc_stripe_payment_icons', array( |
|
68 | 68 | 'visa' => '<i class="stripe-pf stripe-pf-visa stripe-pf-right" alt="Visa" aria-hidden="true"></i>', |
69 | 69 | 'amex' => '<i class="stripe-pf stripe-pf-american-express stripe-pf-right" alt="Amex" aria-hidden="true"></i>', |
70 | 70 | 'mastercard' => '<i class="stripe-pf stripe-pf-mastercard stripe-pf-right" alt="Mastercard" aria-hidden="true"></i>', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'eps' => '<i class="stripe-pf stripe-pf-eps stripe-pf-right" alt="EPS" aria-hidden="true"></i>', |
82 | 82 | 'sofort' => '<i class="stripe-pf stripe-pf-sofort stripe-pf-right" alt="SOFORT" aria-hidden="true"></i>', |
83 | 83 | 'sepa' => '<i class="stripe-pf stripe-pf-sepa stripe-pf-right" alt="SEPA" aria-hidden="true"></i>', |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @version 4.0.0 |
93 | 93 | * @param object $order |
94 | 94 | */ |
95 | - public function validate_minimum_order_amount( $order ) { |
|
96 | - if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) { |
|
95 | + public function validate_minimum_order_amount($order) { |
|
96 | + if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) { |
|
97 | 97 | /* translators: 1) dollar amount */ |
98 | - throw new WC_Stripe_Exception( 'Did not meet minimum amount', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) ); |
|
98 | + throw new WC_Stripe_Exception('Did not meet minimum amount', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100))); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | * @since 4.0.0 |
106 | 106 | * @version 4.0.0 |
107 | 107 | */ |
108 | - public function get_transaction_url( $order ) { |
|
109 | - if ( $this->testmode ) { |
|
108 | + public function get_transaction_url($order) { |
|
109 | + if ($this->testmode) { |
|
110 | 110 | $this->view_transaction_url = 'https://dashboard.stripe.com/test/payments/%s'; |
111 | 111 | } else { |
112 | 112 | $this->view_transaction_url = 'https://dashboard.stripe.com/payments/%s'; |
113 | 113 | } |
114 | 114 | |
115 | - return parent::get_transaction_url( $order ); |
|
115 | + return parent::get_transaction_url($order); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @since 4.0.0 |
122 | 122 | * @version 4.0.0 |
123 | 123 | */ |
124 | - public function get_stripe_customer_id( $order ) { |
|
125 | - $customer = get_user_meta( WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id', true ); |
|
124 | + public function get_stripe_customer_id($order) { |
|
125 | + $customer = get_user_meta(WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(), '_stripe_customer_id', true); |
|
126 | 126 | |
127 | - if ( empty( $customer ) ) { |
|
127 | + if (empty($customer)) { |
|
128 | 128 | // Try to get it via the order. |
129 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
130 | - return get_post_meta( $order->id, '_stripe_customer_id', true ); |
|
129 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
130 | + return get_post_meta($order->id, '_stripe_customer_id', true); |
|
131 | 131 | } else { |
132 | - return $order->get_meta( '_stripe_customer_id', true ); |
|
132 | + return $order->get_meta('_stripe_customer_id', true); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | 135 | return $customer; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | * @param object $order |
147 | 147 | * @param int $id Stripe session id. |
148 | 148 | */ |
149 | - public function get_stripe_return_url( $order = null, $id = null ) { |
|
150 | - if ( is_object( $order ) ) { |
|
151 | - if ( empty( $id ) ) { |
|
149 | + public function get_stripe_return_url($order = null, $id = null) { |
|
150 | + if (is_object($order)) { |
|
151 | + if (empty($id)) { |
|
152 | 152 | $id = uniqid(); |
153 | 153 | } |
154 | 154 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | 'order_id' => $order_id, |
160 | 160 | ); |
161 | 161 | |
162 | - return esc_url_raw( add_query_arg( $args, $this->get_return_url( $order ) ) ); |
|
162 | + return esc_url_raw(add_query_arg($args, $this->get_return_url($order))); |
|
163 | 163 | } |
164 | 164 | |
165 | - return esc_url_raw( add_query_arg( array( 'utm_nooverride' => '1' ), $this->get_return_url() ) ); |
|
165 | + return esc_url_raw(add_query_arg(array('utm_nooverride' => '1'), $this->get_return_url())); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -174,27 +174,26 @@ discard block |
||
174 | 174 | * @param object $source |
175 | 175 | * @return array() |
176 | 176 | */ |
177 | - public function generate_payment_request( $order, $source ) { |
|
178 | - $settings = get_option( 'woocommerce_stripe_settings', array() ); |
|
179 | - $statement_descriptor = ! empty( $settings['statement_descriptor'] ) ? str_replace( "'", '', $settings['statement_descriptor'] ) : ''; |
|
180 | - $capture = ! empty( $settings['capture'] ) && 'yes' === $settings['capture'] ? true : false; |
|
177 | + public function generate_payment_request($order, $source) { |
|
178 | + $settings = get_option('woocommerce_stripe_settings', array()); |
|
179 | + $statement_descriptor = ! empty($settings['statement_descriptor']) ? str_replace("'", '', $settings['statement_descriptor']) : ''; |
|
180 | + $capture = ! empty($settings['capture']) && 'yes' === $settings['capture'] ? true : false; |
|
181 | 181 | $post_data = array(); |
182 | - $post_data['currency'] = strtolower( WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency() ); |
|
183 | - $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount( $order->get_total(), $post_data['currency'] ); |
|
182 | + $post_data['currency'] = strtolower(WC_Stripe_Helper::is_pre_30() ? $order->get_order_currency() : $order->get_currency()); |
|
183 | + $post_data['amount'] = WC_Stripe_Helper::get_stripe_amount($order->get_total(), $post_data['currency']); |
|
184 | 184 | /* translators: 1) blog name 2) order number */ |
185 | - $post_data['description'] = sprintf( __( '%1$s - Order %2$s', 'woocommerce-gateway-stripe' ), wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $order->get_order_number() ); |
|
185 | + $post_data['description'] = sprintf(__('%1$s - Order %2$s', 'woocommerce-gateway-stripe'), wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES), $order->get_order_number()); |
|
186 | 186 | $billing_email = WC_Stripe_Helper::is_pre_30() ? $order->billing_email : $order->get_billing_email(); |
187 | 187 | $billing_first_name = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name(); |
188 | 188 | $billing_last_name = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name(); |
189 | 189 | |
190 | - if ( ! empty( $billing_email ) && apply_filters( 'wc_stripe_send_stripe_receipt', false ) ) { |
|
190 | + if ( ! empty($billing_email) && apply_filters('wc_stripe_send_stripe_receipt', false)) { |
|
191 | 191 | $post_data['receipt_email'] = $billing_email; |
192 | 192 | } |
193 | 193 | |
194 | - switch ( WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method() ) { |
|
195 | - case 'stripe': |
|
196 | - if ( ! empty( $statement_descriptor ) ) { |
|
197 | - $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor( $statement_descriptor ); |
|
194 | + switch (WC_Stripe_Helper::is_pre_30() ? $order->payment_method : $order->get_payment_method()) { |
|
195 | + case 'stripe' : if ( ! empty($statement_descriptor)) { |
|
196 | + $post_data['statement_descriptor'] = WC_Stripe_Helper::clean_statement_descriptor($statement_descriptor); |
|
198 | 197 | } |
199 | 198 | |
200 | 199 | $post_data['capture'] = $capture ? 'true' : 'false'; |
@@ -204,18 +203,18 @@ discard block |
||
204 | 203 | $post_data['expand[]'] = 'balance_transaction'; |
205 | 204 | |
206 | 205 | $metadata = array( |
207 | - __( 'customer_name', 'woocommerce-gateway-stripe' ) => sanitize_text_field( $billing_first_name ) . ' ' . sanitize_text_field( $billing_last_name ), |
|
208 | - __( 'customer_email', 'woocommerce-gateway-stripe' ) => sanitize_email( $billing_email ), |
|
206 | + __('customer_name', 'woocommerce-gateway-stripe') => sanitize_text_field($billing_first_name) . ' ' . sanitize_text_field($billing_last_name), |
|
207 | + __('customer_email', 'woocommerce-gateway-stripe') => sanitize_email($billing_email), |
|
209 | 208 | 'order_id' => WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(), |
210 | 209 | ); |
211 | 210 | |
212 | - $post_data['metadata'] = apply_filters( 'wc_stripe_payment_metadata', $metadata, $order, $source ); |
|
211 | + $post_data['metadata'] = apply_filters('wc_stripe_payment_metadata', $metadata, $order, $source); |
|
213 | 212 | |
214 | - if ( $source->customer ) { |
|
213 | + if ($source->customer) { |
|
215 | 214 | $post_data['customer'] = $source->customer; |
216 | 215 | } |
217 | 216 | |
218 | - if ( $source->source ) { |
|
217 | + if ($source->source) { |
|
219 | 218 | $post_data['source'] = $source->source; |
220 | 219 | } |
221 | 220 | |
@@ -227,77 +226,77 @@ discard block |
||
227 | 226 | * @param WC_Order $order |
228 | 227 | * @param object $source |
229 | 228 | */ |
230 | - return apply_filters( 'wc_stripe_generate_payment_request', $post_data, $order, $source ); |
|
229 | + return apply_filters('wc_stripe_generate_payment_request', $post_data, $order, $source); |
|
231 | 230 | } |
232 | 231 | |
233 | 232 | /** |
234 | 233 | * Store extra meta data for an order from a Stripe Response. |
235 | 234 | */ |
236 | - public function process_response( $response, $order ) { |
|
237 | - WC_Stripe_Logger::log( 'Processing response: ' . print_r( $response, true ) ); |
|
235 | + public function process_response($response, $order) { |
|
236 | + WC_Stripe_Logger::log('Processing response: ' . print_r($response, true)); |
|
238 | 237 | |
239 | 238 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
240 | 239 | |
241 | - $captured = ( isset( $response->captured ) && $response->captured ) ? 'yes' : 'no'; |
|
240 | + $captured = (isset($response->captured) && $response->captured) ? 'yes' : 'no'; |
|
242 | 241 | |
243 | 242 | // Store charge data |
244 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_stripe_charge_captured', $captured ) : $order->update_meta_data( '_stripe_charge_captured', $captured ); |
|
243 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_stripe_charge_captured', $captured) : $order->update_meta_data('_stripe_charge_captured', $captured); |
|
245 | 244 | |
246 | 245 | // Store other data such as fees |
247 | - if ( isset( $response->balance_transaction ) && isset( $response->balance_transaction->fee ) ) { |
|
246 | + if (isset($response->balance_transaction) && isset($response->balance_transaction->fee)) { |
|
248 | 247 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
249 | 248 | // values are in the local currency of the Stripe account, not from WC. |
250 | - $fee = ! empty( $response->balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $response->balance_transaction, 'fee' ) : 0; |
|
251 | - $net = ! empty( $response->balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $response->balance_transaction, 'net' ) : 0; |
|
252 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_FEE, $fee ) : $order->update_meta_data( self::META_NAME_FEE, $fee ); |
|
253 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_NET, $net ) : $order->update_meta_data( self::META_NAME_NET, $net ); |
|
249 | + $fee = ! empty($response->balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($response->balance_transaction, 'fee') : 0; |
|
250 | + $net = ! empty($response->balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($response->balance_transaction, 'net') : 0; |
|
251 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_FEE, $fee) : $order->update_meta_data(self::META_NAME_FEE, $fee); |
|
252 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_NET, $net) : $order->update_meta_data(self::META_NAME_NET, $net); |
|
254 | 253 | } |
255 | 254 | |
256 | - if ( 'yes' === $captured ) { |
|
255 | + if ('yes' === $captured) { |
|
257 | 256 | /** |
258 | 257 | * Charge can be captured but in a pending state. Payment methods |
259 | 258 | * that are asynchronous may take couple days to clear. Webhook will |
260 | 259 | * take care of the status changes. |
261 | 260 | */ |
262 | - if ( 'pending' === $response->status ) { |
|
263 | - if ( ! wc_string_to_bool( get_post_meta( $order_id, '_order_stock_reduced', true ) ) ) { |
|
264 | - WC_Stripe_Helper::is_pre_30() ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id ); |
|
261 | + if ('pending' === $response->status) { |
|
262 | + if ( ! wc_string_to_bool(get_post_meta($order_id, '_order_stock_reduced', true))) { |
|
263 | + WC_Stripe_Helper::is_pre_30() ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id); |
|
265 | 264 | } |
266 | 265 | |
267 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_transaction_id', $response->id, true ) : $order->set_transaction_id( $response->id ); |
|
266 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $response->id, true) : $order->set_transaction_id($response->id); |
|
268 | 267 | /* translators: transaction id */ |
269 | - $order->update_status( 'on-hold', sprintf( __( 'Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe' ), $response->id ) ); |
|
268 | + $order->update_status('on-hold', sprintf(__('Stripe charge awaiting payment: %s.', 'woocommerce-gateway-stripe'), $response->id)); |
|
270 | 269 | } |
271 | 270 | |
272 | - if ( 'succeeded' === $response->status ) { |
|
273 | - $order->payment_complete( $response->id ); |
|
271 | + if ('succeeded' === $response->status) { |
|
272 | + $order->payment_complete($response->id); |
|
274 | 273 | |
275 | 274 | /* translators: transaction id */ |
276 | - $message = sprintf( __( 'Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe' ), $response->id ); |
|
277 | - $order->add_order_note( $message ); |
|
275 | + $message = sprintf(__('Stripe charge complete (Charge ID: %s)', 'woocommerce-gateway-stripe'), $response->id); |
|
276 | + $order->add_order_note($message); |
|
278 | 277 | } |
279 | 278 | |
280 | - if ( 'failed' === $response->status ) { |
|
281 | - $localized_message = __( 'Payment processing failed. Please retry.', 'woocommerce-gateway-stripe' ); |
|
282 | - $order->add_order_note( $localized_message ); |
|
283 | - throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); |
|
279 | + if ('failed' === $response->status) { |
|
280 | + $localized_message = __('Payment processing failed. Please retry.', 'woocommerce-gateway-stripe'); |
|
281 | + $order->add_order_note($localized_message); |
|
282 | + throw new WC_Stripe_Exception(print_r($response, true), $localized_message); |
|
284 | 283 | } |
285 | 284 | } else { |
286 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_transaction_id', $response->id, true ) : $order->set_transaction_id( $response->id ); |
|
285 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_transaction_id', $response->id, true) : $order->set_transaction_id($response->id); |
|
287 | 286 | |
288 | - if ( $order->has_status( array( 'pending', 'failed' ) ) ) { |
|
289 | - WC_Stripe_Helper::is_pre_30() ? $order->reduce_order_stock() : wc_reduce_stock_levels( $order_id ); |
|
287 | + if ($order->has_status(array('pending', 'failed'))) { |
|
288 | + WC_Stripe_Helper::is_pre_30() ? $order->reduce_order_stock() : wc_reduce_stock_levels($order_id); |
|
290 | 289 | } |
291 | 290 | |
292 | 291 | /* translators: transaction id */ |
293 | - $order->update_status( 'on-hold', sprintf( __( 'Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe' ), $response->id ) ); |
|
292 | + $order->update_status('on-hold', sprintf(__('Stripe charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-gateway-stripe'), $response->id)); |
|
294 | 293 | } |
295 | 294 | |
296 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
295 | + if (is_callable(array($order, 'save'))) { |
|
297 | 296 | $order->save(); |
298 | 297 | } |
299 | 298 | |
300 | - do_action( 'wc_gateway_stripe_process_response', $response, $order ); |
|
299 | + do_action('wc_gateway_stripe_process_response', $response, $order); |
|
301 | 300 | |
302 | 301 | return $response; |
303 | 302 | } |
@@ -310,10 +309,10 @@ discard block |
||
310 | 309 | * @param int $order_id |
311 | 310 | * @return null |
312 | 311 | */ |
313 | - public function send_failed_order_email( $order_id ) { |
|
312 | + public function send_failed_order_email($order_id) { |
|
314 | 313 | $emails = WC()->mailer()->get_emails(); |
315 | - if ( ! empty( $emails ) && ! empty( $order_id ) ) { |
|
316 | - $emails['WC_Email_Failed_Order']->trigger( $order_id ); |
|
314 | + if ( ! empty($emails) && ! empty($order_id)) { |
|
315 | + $emails['WC_Email_Failed_Order']->trigger($order_id); |
|
317 | 316 | } |
318 | 317 | } |
319 | 318 | |
@@ -325,7 +324,7 @@ discard block |
||
325 | 324 | * @param object $order |
326 | 325 | * @return object $details |
327 | 326 | */ |
328 | - public function get_owner_details( $order ) { |
|
327 | + public function get_owner_details($order) { |
|
329 | 328 | $billing_first_name = WC_Stripe_Helper::is_pre_30() ? $order->billing_first_name : $order->get_billing_first_name(); |
330 | 329 | $billing_last_name = WC_Stripe_Helper::is_pre_30() ? $order->billing_last_name : $order->get_billing_last_name(); |
331 | 330 | |
@@ -336,8 +335,8 @@ discard block |
||
336 | 335 | |
337 | 336 | $phone = WC_Stripe_Helper::is_pre_30() ? $order->billing_phone : $order->get_billing_phone(); |
338 | 337 | |
339 | - if ( ! empty( $phone ) ) { |
|
340 | - $details['phone'] = $phone; |
|
338 | + if ( ! empty($phone)) { |
|
339 | + $details['phone'] = $phone; |
|
341 | 340 | } |
342 | 341 | |
343 | 342 | $details['address']['line1'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_address_1 : $order->get_billing_address_1(); |
@@ -347,7 +346,7 @@ discard block |
||
347 | 346 | $details['address']['postal_code'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_postcode : $order->get_billing_postcode(); |
348 | 347 | $details['address']['country'] = WC_Stripe_Helper::is_pre_30() ? $order->billing_country : $order->get_billing_country(); |
349 | 348 | |
350 | - return (object) apply_filters( 'wc_stripe_owner_details', $details, $order ); |
|
349 | + return (object) apply_filters('wc_stripe_owner_details', $details, $order); |
|
351 | 350 | } |
352 | 351 | |
353 | 352 | /** |
@@ -356,16 +355,16 @@ discard block |
||
356 | 355 | * @since 4.0.3 |
357 | 356 | */ |
358 | 357 | public function create_source_object() { |
359 | - $source = ! empty( $_POST['stripe_source'] ) ? wc_clean( $_POST['stripe_source'] ) : ''; |
|
358 | + $source = ! empty($_POST['stripe_source']) ? wc_clean($_POST['stripe_source']) : ''; |
|
360 | 359 | |
361 | - if ( empty( $source ) ) { |
|
360 | + if (empty($source)) { |
|
362 | 361 | return ''; |
363 | 362 | } |
364 | 363 | |
365 | - $source_object = WC_Stripe_API::retrieve( 'sources/' . $source ); |
|
364 | + $source_object = WC_Stripe_API::retrieve('sources/' . $source); |
|
366 | 365 | |
367 | - if ( ! empty( $source_object->error ) ) { |
|
368 | - throw new WC_Stripe_Exception( print_r( $source_object, true ), $source_object->error->message ); |
|
366 | + if ( ! empty($source_object->error)) { |
|
367 | + throw new WC_Stripe_Exception(print_r($source_object, true), $source_object->error->message); |
|
369 | 368 | } |
370 | 369 | |
371 | 370 | return $source_object; |
@@ -385,58 +384,58 @@ discard block |
||
385 | 384 | * @throws Exception When card was not added or for and invalid card. |
386 | 385 | * @return object |
387 | 386 | */ |
388 | - public function prepare_source( $source_object = '', $user_id, $force_save_source = false ) { |
|
389 | - $customer = new WC_Stripe_Customer( $user_id ); |
|
387 | + public function prepare_source($source_object = '', $user_id, $force_save_source = false) { |
|
388 | + $customer = new WC_Stripe_Customer($user_id); |
|
390 | 389 | $set_customer = true; |
391 | - $force_save_source = apply_filters( 'wc_stripe_force_save_source', $force_save_source, $customer ); |
|
390 | + $force_save_source = apply_filters('wc_stripe_force_save_source', $force_save_source, $customer); |
|
392 | 391 | $source = ''; |
393 | 392 | $wc_token_id = false; |
394 | - $payment_method = isset( $_POST['payment_method'] ) ? wc_clean( $_POST['payment_method'] ) : 'stripe'; |
|
393 | + $payment_method = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : 'stripe'; |
|
395 | 394 | |
396 | 395 | // New CC info was entered and we have a new source to process. |
397 | - if ( ! empty( $source_object ) ) { |
|
396 | + if ( ! empty($source_object)) { |
|
398 | 397 | // This gets the source object from Stripe. |
399 | 398 | $source = $source_object; |
400 | 399 | |
401 | 400 | // This checks to see if customer opted to save the payment method to file. |
402 | - $maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ); |
|
401 | + $maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']); |
|
403 | 402 | |
404 | 403 | /** |
405 | 404 | * This is true if the user wants to store the card to their account. |
406 | 405 | * Criteria to save to file is they are logged in, they opted to save or product requirements and the source is |
407 | 406 | * actually reusable. Either that or force_save_source is true. |
408 | 407 | */ |
409 | - if ( ( $user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source->usage ) || $force_save_source ) { |
|
410 | - $source = $customer->add_source( $source->id ); |
|
408 | + if (($user_id && $this->saved_cards && $maybe_saved_card && 'reusable' === $source->usage) || $force_save_source) { |
|
409 | + $source = $customer->add_source($source->id); |
|
411 | 410 | |
412 | - if ( ! empty( $source->error ) ) { |
|
413 | - throw new WC_Stripe_Exception( print_r( $source, true ), $source->error->message ); |
|
411 | + if ( ! empty($source->error)) { |
|
412 | + throw new WC_Stripe_Exception(print_r($source, true), $source->error->message); |
|
414 | 413 | } |
415 | 414 | } else { |
416 | 415 | $source = $source->id; |
417 | 416 | } |
418 | - } elseif ( isset( $_POST[ 'wc-' . $payment_method . '-payment-token' ] ) && 'new' !== $_POST[ 'wc-' . $payment_method . '-payment-token' ] ) { |
|
417 | + } elseif (isset($_POST['wc-' . $payment_method . '-payment-token']) && 'new' !== $_POST['wc-' . $payment_method . '-payment-token']) { |
|
419 | 418 | // Use an existing token, and then process the payment |
420 | 419 | |
421 | - $wc_token_id = wc_clean( $_POST[ 'wc-' . $payment_method . '-payment-token' ] ); |
|
422 | - $wc_token = WC_Payment_Tokens::get( $wc_token_id ); |
|
420 | + $wc_token_id = wc_clean($_POST['wc-' . $payment_method . '-payment-token']); |
|
421 | + $wc_token = WC_Payment_Tokens::get($wc_token_id); |
|
423 | 422 | |
424 | - if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id() ) { |
|
425 | - WC()->session->set( 'refresh_totals', true ); |
|
426 | - throw new WC_Stripe_Exception( 'Invalid payment method', __( 'Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe' ) ); |
|
423 | + if ( ! $wc_token || $wc_token->get_user_id() !== get_current_user_id()) { |
|
424 | + WC()->session->set('refresh_totals', true); |
|
425 | + throw new WC_Stripe_Exception('Invalid payment method', __('Invalid payment method. Please input a new card number.', 'woocommerce-gateway-stripe')); |
|
427 | 426 | } |
428 | 427 | |
429 | 428 | $source = $wc_token->get_token(); |
430 | - } elseif ( isset( $_POST['stripe_token'] ) && 'new' !== $_POST['stripe_token'] ) { |
|
431 | - $stripe_token = wc_clean( $_POST['stripe_token'] ); |
|
432 | - $maybe_saved_card = isset( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ) && ! empty( $_POST[ 'wc-' . $payment_method . '-new-payment-method' ] ); |
|
429 | + } elseif (isset($_POST['stripe_token']) && 'new' !== $_POST['stripe_token']) { |
|
430 | + $stripe_token = wc_clean($_POST['stripe_token']); |
|
431 | + $maybe_saved_card = isset($_POST['wc-' . $payment_method . '-new-payment-method']) && ! empty($_POST['wc-' . $payment_method . '-new-payment-method']); |
|
433 | 432 | |
434 | 433 | // This is true if the user wants to store the card to their account. |
435 | - if ( ( $user_id && $this->saved_cards && $maybe_saved_card ) || $force_save_source ) { |
|
436 | - $source = $customer->add_source( $stripe_token ); |
|
434 | + if (($user_id && $this->saved_cards && $maybe_saved_card) || $force_save_source) { |
|
435 | + $source = $customer->add_source($stripe_token); |
|
437 | 436 | |
438 | - if ( ! empty( $source->error ) ) { |
|
439 | - throw new WC_Stripe_Exception( print_r( $source, true ), $source->error->message ); |
|
437 | + if ( ! empty($source->error)) { |
|
438 | + throw new WC_Stripe_Exception(print_r($source, true), $source->error->message); |
|
440 | 439 | } |
441 | 440 | } else { |
442 | 441 | $set_customer = false; |
@@ -444,7 +443,7 @@ discard block |
||
444 | 443 | } |
445 | 444 | } |
446 | 445 | |
447 | - if ( ! $set_customer ) { |
|
446 | + if ( ! $set_customer) { |
|
448 | 447 | $customer_id = false; |
449 | 448 | } else { |
450 | 449 | $customer_id = $customer->get_id() ? $customer->get_id() : false; |
@@ -465,27 +464,27 @@ discard block |
||
465 | 464 | * @param WC_Order $order For to which the source applies. |
466 | 465 | * @param stdClass $source Source information. |
467 | 466 | */ |
468 | - public function save_source( $order, $source ) { |
|
467 | + public function save_source($order, $source) { |
|
469 | 468 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
470 | 469 | |
471 | 470 | // Store source in the order. |
472 | - if ( $source->customer ) { |
|
473 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
474 | - update_post_meta( $order_id, '_stripe_customer_id', $source->customer ); |
|
471 | + if ($source->customer) { |
|
472 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
473 | + update_post_meta($order_id, '_stripe_customer_id', $source->customer); |
|
475 | 474 | } else { |
476 | - $order->update_meta_data( '_stripe_customer_id', $source->customer ); |
|
475 | + $order->update_meta_data('_stripe_customer_id', $source->customer); |
|
477 | 476 | } |
478 | 477 | } |
479 | 478 | |
480 | - if ( $source->source ) { |
|
481 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
482 | - update_post_meta( $order_id, '_stripe_source_id', $source->source ); |
|
479 | + if ($source->source) { |
|
480 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
481 | + update_post_meta($order_id, '_stripe_source_id', $source->source); |
|
483 | 482 | } else { |
484 | - $order->update_meta_data( '_stripe_source_id', $source->source ); |
|
483 | + $order->update_meta_data('_stripe_source_id', $source->source); |
|
485 | 484 | } |
486 | 485 | } |
487 | 486 | |
488 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
487 | + if (is_callable(array($order, 'save'))) { |
|
489 | 488 | $order->save(); |
490 | 489 | } |
491 | 490 | } |
@@ -503,37 +502,37 @@ discard block |
||
503 | 502 | * @param object $order |
504 | 503 | * @return object |
505 | 504 | */ |
506 | - public function prepare_order_source( $order = null ) { |
|
505 | + public function prepare_order_source($order = null) { |
|
507 | 506 | $stripe_customer = new WC_Stripe_Customer(); |
508 | 507 | $stripe_source = false; |
509 | 508 | $token_id = false; |
510 | 509 | |
511 | - if ( $order ) { |
|
510 | + if ($order) { |
|
512 | 511 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
513 | 512 | |
514 | - $stripe_customer_id = get_post_meta( $order_id, '_stripe_customer_id', true ); |
|
513 | + $stripe_customer_id = get_post_meta($order_id, '_stripe_customer_id', true); |
|
515 | 514 | |
516 | - if ( $stripe_customer_id ) { |
|
517 | - $stripe_customer->set_id( $stripe_customer_id ); |
|
515 | + if ($stripe_customer_id) { |
|
516 | + $stripe_customer->set_id($stripe_customer_id); |
|
518 | 517 | } |
519 | 518 | |
520 | - $source_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_stripe_source_id', true ) : $order->get_meta( '_stripe_source_id', true ); |
|
519 | + $source_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_stripe_source_id', true) : $order->get_meta('_stripe_source_id', true); |
|
521 | 520 | |
522 | 521 | // Since 4.0.0, we changed card to source so we need to account for that. |
523 | - if ( empty( $source_id ) ) { |
|
524 | - $source_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta( $order_id, '_stripe_card_id', true ) : $order->get_meta( '_stripe_card_id', true ); |
|
522 | + if (empty($source_id)) { |
|
523 | + $source_id = WC_Stripe_Helper::is_pre_30() ? get_post_meta($order_id, '_stripe_card_id', true) : $order->get_meta('_stripe_card_id', true); |
|
525 | 524 | |
526 | 525 | // Take this opportunity to update the key name. |
527 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_stripe_source_id', $source_id ) : $order->update_meta_data( '_stripe_source_id', $source_id ); |
|
526 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_stripe_source_id', $source_id) : $order->update_meta_data('_stripe_source_id', $source_id); |
|
528 | 527 | |
529 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
528 | + if (is_callable(array($order, 'save'))) { |
|
530 | 529 | $order->save(); |
531 | 530 | } |
532 | 531 | } |
533 | 532 | |
534 | - if ( $source_id ) { |
|
533 | + if ($source_id) { |
|
535 | 534 | $stripe_source = $source_id; |
536 | - } elseif ( apply_filters( 'wc_stripe_use_default_customer_source', true ) ) { |
|
535 | + } elseif (apply_filters('wc_stripe_use_default_customer_source', true)) { |
|
537 | 536 | /* |
538 | 537 | * We can attempt to charge the customer's default source |
539 | 538 | * by sending empty source id. |
@@ -558,27 +557,27 @@ discard block |
||
558 | 557 | * @param object $order The order object |
559 | 558 | * @param int $balance_transaction_id |
560 | 559 | */ |
561 | - public function update_fees( $order, $balance_transaction_id ) { |
|
560 | + public function update_fees($order, $balance_transaction_id) { |
|
562 | 561 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
563 | 562 | |
564 | - $balance_transaction = WC_Stripe_API::retrieve( 'balance/history/' . $balance_transaction_id ); |
|
563 | + $balance_transaction = WC_Stripe_API::retrieve('balance/history/' . $balance_transaction_id); |
|
565 | 564 | |
566 | - if ( empty( $balance_transaction->error ) ) { |
|
567 | - if ( isset( $balance_transaction ) && isset( $balance_transaction->fee ) ) { |
|
565 | + if (empty($balance_transaction->error)) { |
|
566 | + if (isset($balance_transaction) && isset($balance_transaction->fee)) { |
|
568 | 567 | // Fees and Net needs to both come from Stripe to be accurate as the returned |
569 | 568 | // values are in the local currency of the Stripe account, not from WC. |
570 | - $fee = ! empty( $balance_transaction->fee ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'fee' ) : 0; |
|
571 | - $net = ! empty( $balance_transaction->net ) ? WC_Stripe_Helper::format_balance_fee( $balance_transaction, 'net' ) : 0; |
|
569 | + $fee = ! empty($balance_transaction->fee) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'fee') : 0; |
|
570 | + $net = ! empty($balance_transaction->net) ? WC_Stripe_Helper::format_balance_fee($balance_transaction, 'net') : 0; |
|
572 | 571 | |
573 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_FEE, $fee ) : $order->update_meta_data( self::META_NAME_FEE, $fee ); |
|
574 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, self::META_NAME_NET, $net ) : $order->update_meta_data( self::META_NAME_NET, $net ); |
|
572 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_FEE, $fee) : $order->update_meta_data(self::META_NAME_FEE, $fee); |
|
573 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, self::META_NAME_NET, $net) : $order->update_meta_data(self::META_NAME_NET, $net); |
|
575 | 574 | |
576 | - if ( is_callable( array( $order, 'save' ) ) ) { |
|
575 | + if (is_callable(array($order, 'save'))) { |
|
577 | 576 | $order->save(); |
578 | 577 | } |
579 | 578 | } |
580 | 579 | } else { |
581 | - WC_Stripe_Logger::log( "Unable to update fees/net meta for order: {$order_id}" ); |
|
580 | + WC_Stripe_Logger::log("Unable to update fees/net meta for order: {$order_id}"); |
|
582 | 581 | } |
583 | 582 | } |
584 | 583 | |
@@ -591,57 +590,57 @@ discard block |
||
591 | 590 | * @param float $amount |
592 | 591 | * @return bool |
593 | 592 | */ |
594 | - public function process_refund( $order_id, $amount = null, $reason = '' ) { |
|
595 | - $order = wc_get_order( $order_id ); |
|
593 | + public function process_refund($order_id, $amount = null, $reason = '') { |
|
594 | + $order = wc_get_order($order_id); |
|
596 | 595 | |
597 | - if ( ! $order || ! $order->get_transaction_id() ) { |
|
596 | + if ( ! $order || ! $order->get_transaction_id()) { |
|
598 | 597 | return false; |
599 | 598 | } |
600 | 599 | |
601 | 600 | $body = array(); |
602 | 601 | |
603 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
604 | - $order_currency = get_post_meta( $order_id, '_order_currency', true ); |
|
602 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
603 | + $order_currency = get_post_meta($order_id, '_order_currency', true); |
|
605 | 604 | } else { |
606 | 605 | $order_currency = $order->get_currency(); |
607 | 606 | } |
608 | 607 | |
609 | - if ( ! is_null( $amount ) ) { |
|
610 | - $body['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $order_currency ); |
|
608 | + if ( ! is_null($amount)) { |
|
609 | + $body['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $order_currency); |
|
611 | 610 | } |
612 | 611 | |
613 | - if ( $reason ) { |
|
612 | + if ($reason) { |
|
614 | 613 | $body['metadata'] = array( |
615 | 614 | 'reason' => $reason, |
616 | 615 | ); |
617 | 616 | } |
618 | 617 | |
619 | - WC_Stripe_Logger::log( "Info: Beginning refund for order {$order->get_transaction_id()} for the amount of {$amount}" ); |
|
618 | + WC_Stripe_Logger::log("Info: Beginning refund for order {$order->get_transaction_id()} for the amount of {$amount}"); |
|
620 | 619 | |
621 | - $response = WC_Stripe_API::request( $body, 'charges/' . $order->get_transaction_id() . '/refunds' ); |
|
620 | + $response = WC_Stripe_API::request($body, 'charges/' . $order->get_transaction_id() . '/refunds'); |
|
622 | 621 | |
623 | - if ( ! empty( $response->error ) ) { |
|
624 | - WC_Stripe_Logger::log( 'Error: ' . $response->error->message ); |
|
622 | + if ( ! empty($response->error)) { |
|
623 | + WC_Stripe_Logger::log('Error: ' . $response->error->message); |
|
625 | 624 | |
626 | 625 | return $response; |
627 | 626 | |
628 | - } elseif ( ! empty( $response->id ) ) { |
|
629 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $order_id, '_stripe_refund_id', $response->id ) : $order->update_meta_data( '_stripe_refund_id', $response->id ); |
|
627 | + } elseif ( ! empty($response->id)) { |
|
628 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($order_id, '_stripe_refund_id', $response->id) : $order->update_meta_data('_stripe_refund_id', $response->id); |
|
630 | 629 | |
631 | - $amount = wc_price( $response->amount / 100 ); |
|
630 | + $amount = wc_price($response->amount / 100); |
|
632 | 631 | |
633 | - if ( in_array( strtolower( $order->get_currency() ), WC_Stripe_Helper::no_decimal_currencies() ) ) { |
|
634 | - $amount = wc_price( $response->amount ); |
|
632 | + if (in_array(strtolower($order->get_currency()), WC_Stripe_Helper::no_decimal_currencies())) { |
|
633 | + $amount = wc_price($response->amount); |
|
635 | 634 | } |
636 | 635 | |
637 | - if ( isset( $response->balance_transaction ) ) { |
|
638 | - $this->update_fees( $order, $response->balance_transaction ); |
|
636 | + if (isset($response->balance_transaction)) { |
|
637 | + $this->update_fees($order, $response->balance_transaction); |
|
639 | 638 | } |
640 | 639 | |
641 | 640 | /* translators: 1) dollar amount 2) transaction id 3) refund message */ |
642 | - $refund_message = sprintf( __( 'Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe' ), $amount, $response->id, $reason ); |
|
643 | - $order->add_order_note( $refund_message ); |
|
644 | - WC_Stripe_Logger::log( 'Success: ' . html_entity_decode( strip_tags( $refund_message ) ) ); |
|
641 | + $refund_message = sprintf(__('Refunded %1$s - Refund ID: %2$s - Reason: %3$s', 'woocommerce-gateway-stripe'), $amount, $response->id, $reason); |
|
642 | + $order->add_order_note($refund_message); |
|
643 | + WC_Stripe_Logger::log('Success: ' . html_entity_decode(strip_tags($refund_message))); |
|
645 | 644 | |
646 | 645 | return true; |
647 | 646 | } |
@@ -656,44 +655,44 @@ discard block |
||
656 | 655 | */ |
657 | 656 | public function add_payment_method() { |
658 | 657 | $error = false; |
659 | - $error_msg = __( 'There was a problem adding the card.', 'woocommerce-gateway-stripe' ); |
|
658 | + $error_msg = __('There was a problem adding the card.', 'woocommerce-gateway-stripe'); |
|
660 | 659 | $source_id = ''; |
661 | 660 | |
662 | - if ( empty( $_POST['stripe_source'] ) && empty( $_POST['stripe_token'] ) || ! is_user_logged_in() ) { |
|
661 | + if (empty($_POST['stripe_source']) && empty($_POST['stripe_token']) || ! is_user_logged_in()) { |
|
663 | 662 | $error = true; |
664 | 663 | } |
665 | 664 | |
666 | - $stripe_customer = new WC_Stripe_Customer( get_current_user_id() ); |
|
665 | + $stripe_customer = new WC_Stripe_Customer(get_current_user_id()); |
|
667 | 666 | |
668 | - $source = ! empty( $_POST['stripe_source'] ) ? wc_clean( $_POST['stripe_source'] ) : ''; |
|
667 | + $source = ! empty($_POST['stripe_source']) ? wc_clean($_POST['stripe_source']) : ''; |
|
669 | 668 | |
670 | - $source_object = WC_Stripe_API::retrieve( 'sources/' . $source ); |
|
669 | + $source_object = WC_Stripe_API::retrieve('sources/' . $source); |
|
671 | 670 | |
672 | - if ( isset( $source_object ) ) { |
|
673 | - if ( ! empty( $source_object->error ) ) { |
|
671 | + if (isset($source_object)) { |
|
672 | + if ( ! empty($source_object->error)) { |
|
674 | 673 | $error = true; |
675 | 674 | } |
676 | 675 | |
677 | 676 | $source_id = $source_object->id; |
678 | - } elseif ( isset( $_POST['stripe_token'] ) ) { |
|
679 | - $source_id = wc_clean( $_POST['stripe_token'] ); |
|
677 | + } elseif (isset($_POST['stripe_token'])) { |
|
678 | + $source_id = wc_clean($_POST['stripe_token']); |
|
680 | 679 | } |
681 | 680 | |
682 | - $response = $stripe_customer->add_source( $source_id ); |
|
681 | + $response = $stripe_customer->add_source($source_id); |
|
683 | 682 | |
684 | - if ( ! $response || is_wp_error( $response ) || ! empty( $response->error ) ) { |
|
683 | + if ( ! $response || is_wp_error($response) || ! empty($response->error)) { |
|
685 | 684 | $error = true; |
686 | 685 | } |
687 | 686 | |
688 | - if ( $error ) { |
|
689 | - wc_add_notice( $error_msg, 'error' ); |
|
690 | - WC_Stripe_Logger::log( 'Add payment method Error: ' . $error_msg ); |
|
687 | + if ($error) { |
|
688 | + wc_add_notice($error_msg, 'error'); |
|
689 | + WC_Stripe_Logger::log('Add payment method Error: ' . $error_msg); |
|
691 | 690 | return; |
692 | 691 | } |
693 | 692 | |
694 | 693 | return array( |
695 | 694 | 'result' => 'success', |
696 | - 'redirect' => wc_get_endpoint_url( 'payment-methods' ), |
|
695 | + 'redirect' => wc_get_endpoint_url('payment-methods'), |
|
697 | 696 | ); |
698 | 697 | } |
699 | 698 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if ( ! defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | public function __construct() { |
16 | 16 | parent::__construct(); |
17 | 17 | |
18 | - if ( class_exists( 'WC_Subscriptions_Order' ) ) { |
|
19 | - add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 ); |
|
20 | - add_action( 'wcs_resubscribe_order_created', array( $this, 'delete_resubscribe_meta' ), 10 ); |
|
21 | - add_action( 'wcs_renewal_order_created', array( $this, 'delete_renewal_meta' ), 10 ); |
|
22 | - add_action( 'woocommerce_subscription_failing_payment_method_updated_stripe', array( $this, 'update_failing_payment_method' ), 10, 2 ); |
|
18 | + if (class_exists('WC_Subscriptions_Order')) { |
|
19 | + add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'scheduled_subscription_payment'), 10, 2); |
|
20 | + add_action('wcs_resubscribe_order_created', array($this, 'delete_resubscribe_meta'), 10); |
|
21 | + add_action('wcs_renewal_order_created', array($this, 'delete_renewal_meta'), 10); |
|
22 | + add_action('woocommerce_subscription_failing_payment_method_updated_stripe', array($this, 'update_failing_payment_method'), 10, 2); |
|
23 | 23 | |
24 | 24 | // display the credit card used for a subscription in the "My Subscriptions" table |
25 | - add_filter( 'woocommerce_my_subscriptions_payment_method', array( $this, 'maybe_render_subscription_payment_method' ), 10, 2 ); |
|
25 | + add_filter('woocommerce_my_subscriptions_payment_method', array($this, 'maybe_render_subscription_payment_method'), 10, 2); |
|
26 | 26 | |
27 | 27 | // allow store managers to manually set Stripe as the payment method on a subscription |
28 | - add_filter( 'woocommerce_subscription_payment_meta', array( $this, 'add_subscription_payment_meta' ), 10, 2 ); |
|
29 | - add_filter( 'woocommerce_subscription_validate_payment_meta', array( $this, 'validate_subscription_payment_meta' ), 10, 2 ); |
|
30 | - add_filter( 'wc_stripe_display_save_payment_method_checkbox', array( $this, 'maybe_hide_save_checkbox' ) ); |
|
31 | - add_filter( 'wc_stripe_payment_metadata', array( $this, 'add_subscription_meta_data' ), 10, 2 ); |
|
28 | + add_filter('woocommerce_subscription_payment_meta', array($this, 'add_subscription_payment_meta'), 10, 2); |
|
29 | + add_filter('woocommerce_subscription_validate_payment_meta', array($this, 'validate_subscription_payment_meta'), 10, 2); |
|
30 | + add_filter('wc_stripe_display_save_payment_method_checkbox', array($this, 'maybe_hide_save_checkbox')); |
|
31 | + add_filter('wc_stripe_payment_metadata', array($this, 'add_subscription_meta_data'), 10, 2); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( class_exists( 'WC_Pre_Orders_Order' ) ) { |
|
35 | - add_action( 'wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array( $this, 'process_pre_order_release_payment' ) ); |
|
34 | + if (class_exists('WC_Pre_Orders_Order')) { |
|
35 | + add_action('wc_pre_orders_process_pre_order_completion_payment_' . $this->id, array($this, 'process_pre_order_release_payment')); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @since 4.0.0 |
44 | 44 | * @version 4.0.0 |
45 | 45 | */ |
46 | - public function maybe_hide_save_checkbox( $display_tokenization ) { |
|
47 | - if ( WC_Subscriptions_Cart::cart_contains_subscription() ) { |
|
46 | + public function maybe_hide_save_checkbox($display_tokenization) { |
|
47 | + if (WC_Subscriptions_Cart::cart_contains_subscription()) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param int $order_id |
57 | 57 | * @return boolean |
58 | 58 | */ |
59 | - public function has_subscription( $order_id ) { |
|
60 | - return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) ); |
|
59 | + public function has_subscription($order_id) { |
|
60 | + return (function_exists('wcs_order_contains_subscription') && (wcs_order_contains_subscription($order_id) || wcs_is_subscription($order_id) || wcs_order_contains_renewal($order_id))); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @param int $order_id |
66 | 66 | * @return boolean |
67 | 67 | */ |
68 | - protected function is_pre_order( $order_id ) { |
|
69 | - return ( class_exists( 'WC_Pre_Orders_Order' ) && WC_Pre_Orders_Order::order_contains_pre_order( $order_id ) ); |
|
68 | + protected function is_pre_order($order_id) { |
|
69 | + return (class_exists('WC_Pre_Orders_Order') && WC_Pre_Orders_Order::order_contains_pre_order($order_id)); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param int $order_id |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function process_payment( $order_id, $retry = true, $force_save_source = false ) { |
|
78 | - if ( $this->has_subscription( $order_id ) ) { |
|
77 | + public function process_payment($order_id, $retry = true, $force_save_source = false) { |
|
78 | + if ($this->has_subscription($order_id)) { |
|
79 | 79 | // Regular payment with force customer enabled |
80 | - return parent::process_payment( $order_id, true, true ); |
|
81 | - } elseif ( $this->is_pre_order( $order_id ) ) { |
|
82 | - return $this->process_pre_order( $order_id, $retry, $force_save_source ); |
|
80 | + return parent::process_payment($order_id, true, true); |
|
81 | + } elseif ($this->is_pre_order($order_id)) { |
|
82 | + return $this->process_pre_order($order_id, $retry, $force_save_source); |
|
83 | 83 | } else { |
84 | - return parent::process_payment( $order_id, $retry, $force_save_source ); |
|
84 | + return parent::process_payment($order_id, $retry, $force_save_source); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @param array $metadata |
93 | 93 | * @param object $order |
94 | 94 | */ |
95 | - public function add_subscription_meta_data( $metadata, $order ) { |
|
96 | - if ( ! $this->has_subscription( $order->get_id() ) ) { |
|
95 | + public function add_subscription_meta_data($metadata, $order) { |
|
96 | + if ( ! $this->has_subscription($order->get_id())) { |
|
97 | 97 | return $metadata; |
98 | 98 | } |
99 | 99 | |
100 | 100 | return $metadata += array( |
101 | 101 | 'payment_type' => 'recurring', |
102 | - 'site_url' => esc_url( get_site_url() ), |
|
102 | + 'site_url' => esc_url(get_site_url()), |
|
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
@@ -109,24 +109,24 @@ discard block |
||
109 | 109 | * @since 3.1.0 |
110 | 110 | * @version 4.0.0 |
111 | 111 | */ |
112 | - public function save_source( $order, $source ) { |
|
113 | - parent::save_source( $order, $source ); |
|
112 | + public function save_source($order, $source) { |
|
113 | + parent::save_source($order, $source); |
|
114 | 114 | |
115 | - $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
|
115 | + $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
|
116 | 116 | |
117 | 117 | // Also store it on the subscriptions being purchased or paid for in the order |
118 | - if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
119 | - $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
120 | - } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
121 | - $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
118 | + if (function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order_id)) { |
|
119 | + $subscriptions = wcs_get_subscriptions_for_order($order_id); |
|
120 | + } elseif (function_exists('wcs_order_contains_renewal') && wcs_order_contains_renewal($order_id)) { |
|
121 | + $subscriptions = wcs_get_subscriptions_for_renewal_order($order_id); |
|
122 | 122 | } else { |
123 | 123 | $subscriptions = array(); |
124 | 124 | } |
125 | 125 | |
126 | - foreach ( $subscriptions as $subscription ) { |
|
126 | + foreach ($subscriptions as $subscription) { |
|
127 | 127 | $subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id(); |
128 | - update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
129 | - update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
128 | + update_post_meta($subscription_id, '_stripe_customer_id', $source->customer); |
|
129 | + update_post_meta($subscription_id, '_stripe_source_id', $source->source); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | * @param string $stripe_token (default: '') |
138 | 138 | * @param bool initial_payment |
139 | 139 | */ |
140 | - public function process_subscription_payment( $order = '', $amount = 0 ) { |
|
141 | - if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) { |
|
140 | + public function process_subscription_payment($order = '', $amount = 0) { |
|
141 | + if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) { |
|
142 | 142 | /* translators: minimum amount */ |
143 | - return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) ); |
|
143 | + return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100))); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
147 | 147 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
148 | 148 | |
149 | 149 | // Get source from order |
150 | - $prepared_source = $this->prepare_order_source( $order ); |
|
150 | + $prepared_source = $this->prepare_order_source($order); |
|
151 | 151 | |
152 | 152 | // Or fail :( |
153 | - if ( ! $prepared_source->customer ) { |
|
154 | - return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) ); |
|
153 | + if ( ! $prepared_source->customer) { |
|
154 | + return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe')); |
|
155 | 155 | } |
156 | 156 | |
157 | - WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" ); |
|
157 | + WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}"); |
|
158 | 158 | |
159 | 159 | // Make the request |
160 | - $request = $this->generate_payment_request( $order, $prepared_source ); |
|
160 | + $request = $this->generate_payment_request($order, $prepared_source); |
|
161 | 161 | $request['capture'] = 'true'; |
162 | - $request['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] ); |
|
163 | - $response = WC_Stripe_API::request( $request ); |
|
162 | + $request['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']); |
|
163 | + $response = WC_Stripe_API::request($request); |
|
164 | 164 | |
165 | 165 | // Process valid response |
166 | - if ( ! empty( $response->error ) ) { |
|
166 | + if ( ! empty($response->error)) { |
|
167 | 167 | return $response; // Default catch all errors. |
168 | 168 | } |
169 | 169 | |
170 | - $this->process_response( $response, $order ); |
|
170 | + $this->process_response($response, $order); |
|
171 | 171 | |
172 | 172 | return $response; |
173 | 173 | } |
@@ -182,61 +182,61 @@ discard block |
||
182 | 182 | * @param string $stripe_token (default: '') |
183 | 183 | * @param bool initial_payment |
184 | 184 | */ |
185 | - public function retry_subscription_payment( $order = '', $amount = 0 ) { |
|
186 | - if ( $amount * 100 < WC_Stripe_Helper::get_minimum_amount() ) { |
|
185 | + public function retry_subscription_payment($order = '', $amount = 0) { |
|
186 | + if ($amount * 100 < WC_Stripe_Helper::get_minimum_amount()) { |
|
187 | 187 | /* translators: minimum amount */ |
188 | - return new WP_Error( 'stripe_error', sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) ); |
|
188 | + return new WP_Error('stripe_error', sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100))); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | $customer_id = WC_Stripe_Helper::is_pre_30() ? $order->customer_user : $order->get_customer_id(); |
192 | 192 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
193 | 193 | |
194 | 194 | // Get source from order |
195 | - $prepared_source = $this->prepare_order_source( $order ); |
|
195 | + $prepared_source = $this->prepare_order_source($order); |
|
196 | 196 | |
197 | 197 | // Or fail :( |
198 | - if ( ! $prepared_source->customer ) { |
|
199 | - return new WP_Error( 'stripe_error', __( 'Customer not found', 'woocommerce-gateway-stripe' ) ); |
|
198 | + if ( ! $prepared_source->customer) { |
|
199 | + return new WP_Error('stripe_error', __('Customer not found', 'woocommerce-gateway-stripe')); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | // Passing empty source with charge customer default. |
203 | 203 | $prepared_source->source = ''; |
204 | 204 | |
205 | - WC_Stripe_Logger::log( "Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}" ); |
|
205 | + WC_Stripe_Logger::log("Info: Begin processing subscription payment for order {$order_id} for the amount of {$amount}"); |
|
206 | 206 | |
207 | 207 | // Make the request |
208 | - $request = $this->generate_payment_request( $order, $prepared_source ); |
|
208 | + $request = $this->generate_payment_request($order, $prepared_source); |
|
209 | 209 | $request['capture'] = 'true'; |
210 | - $request['amount'] = WC_Stripe_Helper::get_stripe_amount( $amount, $request['currency'] ); |
|
211 | - $response = WC_Stripe_API::request( $request ); |
|
210 | + $request['amount'] = WC_Stripe_Helper::get_stripe_amount($amount, $request['currency']); |
|
211 | + $response = WC_Stripe_API::request($request); |
|
212 | 212 | |
213 | - if ( ! empty( $response->error ) || is_wp_error( $response ) ) { |
|
213 | + if ( ! empty($response->error) || is_wp_error($response)) { |
|
214 | 214 | /* translators: error message */ |
215 | - $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) ); |
|
215 | + $renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->error->message)); |
|
216 | 216 | } |
217 | 217 | |
218 | - $this->process_response( $response, $order ); |
|
218 | + $this->process_response($response, $order); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Don't transfer Stripe customer/token meta to resubscribe orders. |
223 | 223 | * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription |
224 | 224 | */ |
225 | - public function delete_resubscribe_meta( $resubscribe_order ) { |
|
226 | - delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_customer_id' ); |
|
227 | - delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_source_id' ); |
|
225 | + public function delete_resubscribe_meta($resubscribe_order) { |
|
226 | + delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_customer_id'); |
|
227 | + delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_source_id'); |
|
228 | 228 | // For BW compat will remove in future |
229 | - delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id() ), '_stripe_card_id' ); |
|
230 | - $this->delete_renewal_meta( $resubscribe_order ); |
|
229 | + delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $resubscribe_order->id : $resubscribe_order->get_id()), '_stripe_card_id'); |
|
230 | + $this->delete_renewal_meta($resubscribe_order); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Don't transfer Stripe fee/ID meta to renewal orders. |
235 | 235 | * @param int $resubscribe_order The order created for the customer to resubscribe to the old expired/cancelled subscription |
236 | 236 | */ |
237 | - public function delete_renewal_meta( $renewal_order ) { |
|
238 | - delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Stripe Fee' ); |
|
239 | - delete_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id() ), 'Net Revenue From Stripe' ); |
|
237 | + public function delete_renewal_meta($renewal_order) { |
|
238 | + delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Stripe Fee'); |
|
239 | + delete_post_meta((WC_Stripe_Helper::is_pre_30() ? $renewal_order->id : $renewal_order->get_id()), 'Net Revenue From Stripe'); |
|
240 | 240 | return $renewal_order; |
241 | 241 | } |
242 | 242 | |
@@ -246,21 +246,21 @@ discard block |
||
246 | 246 | * @param $amount_to_charge float The amount to charge. |
247 | 247 | * @param $renewal_order WC_Order A WC_Order object created to record the renewal payment. |
248 | 248 | */ |
249 | - public function scheduled_subscription_payment( $amount_to_charge, $renewal_order ) { |
|
250 | - $response = $this->process_subscription_payment( $renewal_order, $amount_to_charge ); |
|
249 | + public function scheduled_subscription_payment($amount_to_charge, $renewal_order) { |
|
250 | + $response = $this->process_subscription_payment($renewal_order, $amount_to_charge); |
|
251 | 251 | |
252 | - if ( is_wp_error( $response ) ) { |
|
252 | + if (is_wp_error($response)) { |
|
253 | 253 | /* translators: error message */ |
254 | - $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->get_error_message() ) ); |
|
254 | + $renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->get_error_message())); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( ! empty( $response->error ) ) { |
|
257 | + if ( ! empty($response->error)) { |
|
258 | 258 | // This is a very generic error to listen for but worth a retry before total fail. |
259 | - if ( isset( $response->error->type ) && 'invalid_request_error' === $response->error->type && apply_filters( 'wc_stripe_use_default_customer_source', true ) ) { |
|
260 | - $this->retry_subscription_payment( $renewal_order, $amount_to_charge ); |
|
259 | + if (isset($response->error->type) && 'invalid_request_error' === $response->error->type && apply_filters('wc_stripe_use_default_customer_source', true)) { |
|
260 | + $this->retry_subscription_payment($renewal_order, $amount_to_charge); |
|
261 | 261 | } else { |
262 | 262 | /* translators: error message */ |
263 | - $renewal_order->update_status( 'failed', sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $response->error->message ) ); |
|
263 | + $renewal_order->update_status('failed', sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $response->error->message)); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -269,20 +269,20 @@ discard block |
||
269 | 269 | * Remove order meta |
270 | 270 | * @param object $order |
271 | 271 | */ |
272 | - public function remove_order_source_before_retry( $order ) { |
|
272 | + public function remove_order_source_before_retry($order) { |
|
273 | 273 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
274 | - delete_post_meta( $order_id, '_stripe_source_id' ); |
|
274 | + delete_post_meta($order_id, '_stripe_source_id'); |
|
275 | 275 | // For BW compat will remove in the future. |
276 | - delete_post_meta( $order_id, '_stripe_card_id' ); |
|
276 | + delete_post_meta($order_id, '_stripe_card_id'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Remove order meta |
281 | 281 | * @param object $order |
282 | 282 | */ |
283 | - public function remove_order_customer_before_retry( $order ) { |
|
283 | + public function remove_order_customer_before_retry($order) { |
|
284 | 284 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
285 | - delete_post_meta( $order_id, '_stripe_customer_id' ); |
|
285 | + delete_post_meta($order_id, '_stripe_customer_id'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | * @param WC_Order $renewal_order The order which recorded the successful payment (to make up for the failed automatic payment). |
295 | 295 | * @return void |
296 | 296 | */ |
297 | - public function update_failing_payment_method( $subscription, $renewal_order ) { |
|
298 | - if ( WC_Stripe_Helper::is_pre_30() ) { |
|
299 | - update_post_meta( $subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id ); |
|
300 | - update_post_meta( $subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id ); |
|
297 | + public function update_failing_payment_method($subscription, $renewal_order) { |
|
298 | + if (WC_Stripe_Helper::is_pre_30()) { |
|
299 | + update_post_meta($subscription->id, '_stripe_customer_id', $renewal_order->stripe_customer_id); |
|
300 | + update_post_meta($subscription->id, '_stripe_source_id', $renewal_order->stripe_source_id); |
|
301 | 301 | |
302 | 302 | } else { |
303 | - update_post_meta( $subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta( '_stripe_customer_id', true ) ); |
|
304 | - update_post_meta( $subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta( '_stripe_source_id', true ) ); |
|
303 | + update_post_meta($subscription->get_id(), '_stripe_customer_id', $renewal_order->get_meta('_stripe_customer_id', true)); |
|
304 | + update_post_meta($subscription->get_id(), '_stripe_source_id', $renewal_order->get_meta('_stripe_source_id', true)); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -314,21 +314,21 @@ discard block |
||
314 | 314 | * @param WC_Subscription $subscription An instance of a subscription object |
315 | 315 | * @return array |
316 | 316 | */ |
317 | - public function add_subscription_payment_meta( $payment_meta, $subscription ) { |
|
318 | - $source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true ); |
|
317 | + public function add_subscription_payment_meta($payment_meta, $subscription) { |
|
318 | + $source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true); |
|
319 | 319 | |
320 | 320 | // For BW compat will remove in future. |
321 | - if ( empty( $source_id ) ) { |
|
322 | - $source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true ); |
|
321 | + if (empty($source_id)) { |
|
322 | + $source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true); |
|
323 | 323 | |
324 | 324 | // Take this opportunity to update the key name. |
325 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $source_id ); |
|
325 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $source_id); |
|
326 | 326 | } |
327 | 327 | |
328 | - $payment_meta[ $this->id ] = array( |
|
328 | + $payment_meta[$this->id] = array( |
|
329 | 329 | 'post_meta' => array( |
330 | 330 | '_stripe_customer_id' => array( |
331 | - 'value' => get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ), |
|
331 | + 'value' => get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true), |
|
332 | 332 | 'label' => 'Stripe Customer ID', |
333 | 333 | ), |
334 | 334 | '_stripe_source_id' => array( |
@@ -351,22 +351,22 @@ discard block |
||
351 | 351 | * @param array $payment_meta associative array of meta data required for automatic payments |
352 | 352 | * @return array |
353 | 353 | */ |
354 | - public function validate_subscription_payment_meta( $payment_method_id, $payment_meta ) { |
|
355 | - if ( $this->id === $payment_method_id ) { |
|
354 | + public function validate_subscription_payment_meta($payment_method_id, $payment_meta) { |
|
355 | + if ($this->id === $payment_method_id) { |
|
356 | 356 | |
357 | - if ( ! isset( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) || empty( $payment_meta['post_meta']['_stripe_customer_id']['value'] ) ) { |
|
358 | - throw new Exception( __( 'A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe' ) ); |
|
359 | - } elseif ( 0 !== strpos( $payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_' ) ) { |
|
360 | - throw new Exception( __( 'Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe' ) ); |
|
357 | + if ( ! isset($payment_meta['post_meta']['_stripe_customer_id']['value']) || empty($payment_meta['post_meta']['_stripe_customer_id']['value'])) { |
|
358 | + throw new Exception(__('A "Stripe Customer ID" value is required.', 'woocommerce-gateway-stripe')); |
|
359 | + } elseif (0 !== strpos($payment_meta['post_meta']['_stripe_customer_id']['value'], 'cus_')) { |
|
360 | + throw new Exception(__('Invalid customer ID. A valid "Stripe Customer ID" must begin with "cus_".', 'woocommerce-gateway-stripe')); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | if ( |
364 | - ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
365 | - && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'card_' ) ) |
|
366 | - && ( ! empty( $payment_meta['post_meta']['_stripe_source_id']['value'] ) |
|
367 | - && 0 !== strpos( $payment_meta['post_meta']['_stripe_source_id']['value'], 'src_' ) ) ) { |
|
364 | + ( ! empty($payment_meta['post_meta']['_stripe_source_id']['value']) |
|
365 | + && 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'card_')) |
|
366 | + && ( ! empty($payment_meta['post_meta']['_stripe_source_id']['value']) |
|
367 | + && 0 !== strpos($payment_meta['post_meta']['_stripe_source_id']['value'], 'src_')) ) { |
|
368 | 368 | |
369 | - throw new Exception( __( 'Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe' ) ); |
|
369 | + throw new Exception(__('Invalid source ID. A valid source "Stripe Source ID" must begin with "src_" or "card_".', 'woocommerce-gateway-stripe')); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
@@ -379,91 +379,91 @@ discard block |
||
379 | 379 | * @param WC_Subscription $subscription the subscription details |
380 | 380 | * @return string the subscription payment method |
381 | 381 | */ |
382 | - public function maybe_render_subscription_payment_method( $payment_method_to_display, $subscription ) { |
|
382 | + public function maybe_render_subscription_payment_method($payment_method_to_display, $subscription) { |
|
383 | 383 | $customer_user = WC_Stripe_Helper::is_pre_30() ? $subscription->customer_user : $subscription->get_customer_id(); |
384 | 384 | |
385 | 385 | // bail for other payment methods |
386 | - if ( ( WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method() ) !== $this->id || ! $customer_user ) { |
|
386 | + if ((WC_Stripe_Helper::is_pre_30() ? $subscription->payment_method : $subscription->get_payment_method()) !== $this->id || ! $customer_user) { |
|
387 | 387 | return $payment_method_to_display; |
388 | 388 | } |
389 | 389 | |
390 | - $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_source_id', true ); |
|
390 | + $stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_source_id', true); |
|
391 | 391 | |
392 | 392 | // For BW compat will remove in future. |
393 | - if ( empty( $stripe_source_id ) ) { |
|
394 | - $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_card_id', true ); |
|
393 | + if (empty($stripe_source_id)) { |
|
394 | + $stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_card_id', true); |
|
395 | 395 | |
396 | 396 | // Take this opportunity to update the key name. |
397 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_id(), '_stripe_source_id', $stripe_source_id ); |
|
397 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_id(), '_stripe_source_id', $stripe_source_id); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | $stripe_customer = new WC_Stripe_Customer(); |
401 | - $stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id() ), '_stripe_customer_id', true ); |
|
401 | + $stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id()), '_stripe_customer_id', true); |
|
402 | 402 | |
403 | 403 | // If we couldn't find a Stripe customer linked to the subscription, fallback to the user meta data. |
404 | - if ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) { |
|
404 | + if ( ! $stripe_customer_id || ! is_string($stripe_customer_id)) { |
|
405 | 405 | $user_id = $customer_user; |
406 | - $stripe_customer_id = get_user_meta( $user_id, '_stripe_customer_id', true ); |
|
407 | - $stripe_source_id = get_user_meta( $user_id, '_stripe_source_id', true ); |
|
406 | + $stripe_customer_id = get_user_meta($user_id, '_stripe_customer_id', true); |
|
407 | + $stripe_source_id = get_user_meta($user_id, '_stripe_source_id', true); |
|
408 | 408 | |
409 | 409 | // For BW compat will remove in future. |
410 | - if ( empty( $stripe_source_id ) ) { |
|
411 | - $stripe_source_id = get_user_meta( $user_id, '_stripe_card_id', true ); |
|
410 | + if (empty($stripe_source_id)) { |
|
411 | + $stripe_source_id = get_user_meta($user_id, '_stripe_card_id', true); |
|
412 | 412 | |
413 | 413 | // Take this opportunity to update the key name. |
414 | - update_user_meta( $user_id, '_stripe_source_id', $stripe_source_id ); |
|
414 | + update_user_meta($user_id, '_stripe_source_id', $stripe_source_id); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | 418 | // If we couldn't find a Stripe customer linked to the account, fallback to the order meta data. |
419 | - if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) { |
|
420 | - $stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true ); |
|
421 | - $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true ); |
|
419 | + if (( ! $stripe_customer_id || ! is_string($stripe_customer_id)) && false !== $subscription->order) { |
|
420 | + $stripe_customer_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_customer_id', true); |
|
421 | + $stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_source_id', true); |
|
422 | 422 | |
423 | 423 | // For BW compat will remove in future. |
424 | - if ( empty( $stripe_source_id ) ) { |
|
425 | - $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true ); |
|
424 | + if (empty($stripe_source_id)) { |
|
425 | + $stripe_source_id = get_post_meta((WC_Stripe_Helper::is_pre_30() ? $subscription->order->id : $subscription->get_parent_id()), '_stripe_card_id', true); |
|
426 | 426 | |
427 | 427 | // Take this opportunity to update the key name. |
428 | - WC_Stripe_Helper::is_pre_30() ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id ); |
|
428 | + WC_Stripe_Helper::is_pre_30() ? update_post_meta($subscription->order->id, '_stripe_source_id', $stripe_source_id) : update_post_meta($subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - $stripe_customer->set_id( $stripe_customer_id ); |
|
432 | + $stripe_customer->set_id($stripe_customer_id); |
|
433 | 433 | $sources = $stripe_customer->get_sources(); |
434 | 434 | |
435 | - if ( $sources ) { |
|
435 | + if ($sources) { |
|
436 | 436 | $found_source = false; |
437 | - foreach ( $sources as $source ) { |
|
438 | - if ( isset( $source->type ) && 'card' === $source->type ) { |
|
437 | + foreach ($sources as $source) { |
|
438 | + if (isset($source->type) && 'card' === $source->type) { |
|
439 | 439 | $card = $source->card; |
440 | - } elseif ( isset( $source->object ) && 'card' === $source->object ) { |
|
440 | + } elseif (isset($source->object) && 'card' === $source->object) { |
|
441 | 441 | $card = $source; |
442 | 442 | } |
443 | 443 | |
444 | - if ( $source->id === $stripe_source_id ) { |
|
444 | + if ($source->id === $stripe_source_id) { |
|
445 | 445 | $found_source = true; |
446 | 446 | |
447 | - if ( $card ) { |
|
447 | + if ($card) { |
|
448 | 448 | /* translators: 1) card brand 2) last 4 digits */ |
449 | - $payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 ); |
|
449 | + $payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4); |
|
450 | 450 | } else { |
451 | - $payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' ); |
|
451 | + $payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe'); |
|
452 | 452 | } |
453 | 453 | break; |
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | - if ( ! $found_source ) { |
|
458 | - if ( 'card' === $sources[0]->type ) { |
|
457 | + if ( ! $found_source) { |
|
458 | + if ('card' === $sources[0]->type) { |
|
459 | 459 | $card = $sources[0]->card; |
460 | 460 | } |
461 | 461 | |
462 | - if ( $card ) { |
|
462 | + if ($card) { |
|
463 | 463 | /* translators: 1) card brand 2) last 4 digits */ |
464 | - $payment_method_to_display = sprintf( __( 'Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe' ), ( isset( $card->brand ) ? $card->brand : __( 'N/A', 'woocommerce-gateway-stripe' ) ), $card->last4 ); |
|
464 | + $payment_method_to_display = sprintf(__('Via %1$s card ending in %2$s', 'woocommerce-gateway-stripe'), (isset($card->brand) ? $card->brand : __('N/A', 'woocommerce-gateway-stripe')), $card->last4); |
|
465 | 465 | } else { |
466 | - $payment_method_to_display = __( 'N/A', 'woocommerce-gateway-stripe' ); |
|
466 | + $payment_method_to_display = __('N/A', 'woocommerce-gateway-stripe'); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | } |
@@ -476,43 +476,43 @@ discard block |
||
476 | 476 | * @param int $order_id |
477 | 477 | * @return array |
478 | 478 | */ |
479 | - public function process_pre_order( $order_id, $retry, $force_save_source ) { |
|
480 | - if ( WC_Pre_Orders_Order::order_requires_payment_tokenization( $order_id ) ) { |
|
479 | + public function process_pre_order($order_id, $retry, $force_save_source) { |
|
480 | + if (WC_Pre_Orders_Order::order_requires_payment_tokenization($order_id)) { |
|
481 | 481 | try { |
482 | - $order = wc_get_order( $order_id ); |
|
482 | + $order = wc_get_order($order_id); |
|
483 | 483 | |
484 | - if ( $order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount() ) { |
|
484 | + if ($order->get_total() * 100 < WC_Stripe_Helper::get_minimum_amount()) { |
|
485 | 485 | /* translators: minimum amount */ |
486 | - throw new Exception( sprintf( __( 'Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe' ), wc_price( WC_Stripe_Helper::get_minimum_amount() / 100 ) ) ); |
|
486 | + throw new Exception(sprintf(__('Sorry, the minimum allowed order total is %1$s to use this payment method.', 'woocommerce-gateway-stripe'), wc_price(WC_Stripe_Helper::get_minimum_amount() / 100))); |
|
487 | 487 | } |
488 | 488 | |
489 | - $source = $this->prepare_source( $this->create_source_object(), get_current_user_id(), true ); |
|
489 | + $source = $this->prepare_source($this->create_source_object(), get_current_user_id(), true); |
|
490 | 490 | |
491 | 491 | // We need a source on file to continue. |
492 | - if ( empty( $source->customer ) || empty( $source->source ) ) { |
|
493 | - throw new Exception( __( 'Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe' ) ); |
|
492 | + if (empty($source->customer) || empty($source->source)) { |
|
493 | + throw new Exception(__('Unable to store payment details. Please try again.', 'woocommerce-gateway-stripe')); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | // Store source to order meta |
497 | - $this->save_source( $order, $source ); |
|
497 | + $this->save_source($order, $source); |
|
498 | 498 | |
499 | 499 | // Remove cart |
500 | 500 | WC()->cart->empty_cart(); |
501 | 501 | |
502 | 502 | // Is pre ordered! |
503 | - WC_Pre_Orders_Order::mark_order_as_pre_ordered( $order ); |
|
503 | + WC_Pre_Orders_Order::mark_order_as_pre_ordered($order); |
|
504 | 504 | |
505 | 505 | // Return thank you page redirect |
506 | 506 | return array( |
507 | 507 | 'result' => 'success', |
508 | - 'redirect' => $this->get_return_url( $order ), |
|
508 | + 'redirect' => $this->get_return_url($order), |
|
509 | 509 | ); |
510 | - } catch ( Exception $e ) { |
|
511 | - wc_add_notice( $e->getMessage(), 'error' ); |
|
510 | + } catch (Exception $e) { |
|
511 | + wc_add_notice($e->getMessage(), 'error'); |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | } else { |
515 | - return parent::process_payment( $order_id, $retry, $force_save_source ); |
|
515 | + return parent::process_payment($order_id, $retry, $force_save_source); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @param WC_Order $order |
522 | 522 | * @return void |
523 | 523 | */ |
524 | - public function process_pre_order_release_payment( $order ) { |
|
524 | + public function process_pre_order_release_payment($order) { |
|
525 | 525 | try { |
526 | 526 | // Define some callbacks if the first attempt fails. |
527 | 527 | $retry_callbacks = array( |
@@ -529,33 +529,33 @@ discard block |
||
529 | 529 | 'remove_order_customer_before_retry', |
530 | 530 | ); |
531 | 531 | |
532 | - while ( 1 ) { |
|
533 | - $source = $this->prepare_order_source( $order ); |
|
534 | - $response = WC_Stripe_API::request( $this->generate_payment_request( $order, $source ) ); |
|
532 | + while (1) { |
|
533 | + $source = $this->prepare_order_source($order); |
|
534 | + $response = WC_Stripe_API::request($this->generate_payment_request($order, $source)); |
|
535 | 535 | |
536 | - if ( ! empty( $response->error ) ) { |
|
537 | - if ( 0 === sizeof( $retry_callbacks ) ) { |
|
538 | - throw new Exception( $response->error->message ); |
|
536 | + if ( ! empty($response->error)) { |
|
537 | + if (0 === sizeof($retry_callbacks)) { |
|
538 | + throw new Exception($response->error->message); |
|
539 | 539 | } else { |
540 | - $retry_callback = array_shift( $retry_callbacks ); |
|
541 | - call_user_func( array( $this, $retry_callback ), $order ); |
|
540 | + $retry_callback = array_shift($retry_callbacks); |
|
541 | + call_user_func(array($this, $retry_callback), $order); |
|
542 | 542 | } |
543 | 543 | } else { |
544 | 544 | // Successful |
545 | - $this->process_response( $response, $order ); |
|
545 | + $this->process_response($response, $order); |
|
546 | 546 | break; |
547 | 547 | } |
548 | 548 | } |
549 | - } catch ( Exception $e ) { |
|
549 | + } catch (Exception $e) { |
|
550 | 550 | /* translators: error message */ |
551 | - $order_note = sprintf( __( 'Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe' ), $e->getMessage() ); |
|
551 | + $order_note = sprintf(__('Stripe Transaction Failed (%s)', 'woocommerce-gateway-stripe'), $e->getMessage()); |
|
552 | 552 | |
553 | 553 | // Mark order as failed if not already set, |
554 | 554 | // otherwise, make sure we add the order note so we can detect when someone fails to check out multiple times |
555 | - if ( ! $order->has_status( 'failed' ) ) { |
|
556 | - $order->update_status( 'failed', $order_note ); |
|
555 | + if ( ! $order->has_status('failed')) { |
|
556 | + $order->update_status('failed', $order_note); |
|
557 | 557 | } else { |
558 | - $order->add_order_note( $order_note ); |
|
558 | + $order->add_order_note($order_note); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |