|
@@ -1,5 +1,5 @@ discard block |
|
|
block discarded – undo |
|
1
|
1
|
<?php |
|
2
|
|
-if ( ! defined( 'ABSPATH' ) ) { |
|
|
2
|
+if ( ! defined('ABSPATH')) { |
|
3
|
3
|
exit; |
|
4
|
4
|
} |
|
5
|
5
|
|
|
@@ -22,14 +22,14 @@ discard block |
|
|
block discarded – undo |
|
22
|
22
|
* @param object $order |
|
23
|
23
|
* @return string $currency |
|
24
|
24
|
*/ |
|
25
|
|
- public static function get_stripe_currency( $order = null ) { |
|
26
|
|
- if ( is_null( $order ) ) { |
|
|
25
|
+ public static function get_stripe_currency($order = null) { |
|
|
26
|
+ if (is_null($order)) { |
|
27
|
27
|
return false; |
|
28
|
28
|
} |
|
29
|
29
|
|
|
30
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
30
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
31
|
31
|
|
|
32
|
|
- return WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, true ) : $order->get_meta( self::META_NAME_STRIPE_CURRENCY, true ); |
|
|
32
|
+ return WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, true) : $order->get_meta(self::META_NAME_STRIPE_CURRENCY, true); |
|
33
|
33
|
} |
|
34
|
34
|
|
|
35
|
35
|
/** |
|
@@ -39,14 +39,14 @@ discard block |
|
|
block discarded – undo |
|
39
|
39
|
* @param object $order |
|
40
|
40
|
* @param string $currency |
|
41
|
41
|
*/ |
|
42
|
|
- public static function update_stripe_currency( $order = null, $currency ) { |
|
43
|
|
- if ( is_null( $order ) ) { |
|
|
42
|
+ public static function update_stripe_currency($order = null, $currency) { |
|
|
43
|
+ if (is_null($order)) { |
|
44
|
44
|
return false; |
|
45
|
45
|
} |
|
46
|
46
|
|
|
47
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
47
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
48
|
48
|
|
|
49
|
|
- WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_STRIPE_CURRENCY, $currency ) : $order->update_meta_data( self::META_NAME_STRIPE_CURRENCY, $currency ); |
|
|
49
|
+ WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_STRIPE_CURRENCY, $currency) : $order->update_meta_data(self::META_NAME_STRIPE_CURRENCY, $currency); |
|
50
|
50
|
} |
|
51
|
51
|
|
|
52
|
52
|
/** |
|
@@ -56,22 +56,22 @@ discard block |
|
|
block discarded – undo |
|
56
|
56
|
* @param object $order |
|
57
|
57
|
* @return string $amount |
|
58
|
58
|
*/ |
|
59
|
|
- public static function get_stripe_fee( $order = null ) { |
|
60
|
|
- if ( is_null( $order ) ) { |
|
|
59
|
+ public static function get_stripe_fee($order = null) { |
|
|
60
|
+ if (is_null($order)) { |
|
61
|
61
|
return false; |
|
62
|
62
|
} |
|
63
|
63
|
|
|
64
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
64
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
65
|
65
|
|
|
66
|
|
- $amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_FEE, true ) : $order->get_meta( self::META_NAME_FEE, true ); |
|
|
66
|
+ $amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_FEE, true) : $order->get_meta(self::META_NAME_FEE, true); |
|
67
|
67
|
|
|
68
|
68
|
// If not found let's check for legacy name. |
|
69
|
|
- if ( empty( $amount ) ) { |
|
70
|
|
- $amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_FEE, true ) : $order->get_meta( self::LEGACY_META_NAME_FEE, true ); |
|
|
69
|
+ if (empty($amount)) { |
|
|
70
|
+ $amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_FEE, true) : $order->get_meta(self::LEGACY_META_NAME_FEE, true); |
|
71
|
71
|
|
|
72
|
72
|
// If found update to new name. |
|
73
|
|
- if ( $amount ) { |
|
74
|
|
- self::update_stripe_fee( $order, $amount ); |
|
|
73
|
+ if ($amount) { |
|
|
74
|
+ self::update_stripe_fee($order, $amount); |
|
75
|
75
|
} |
|
76
|
76
|
} |
|
77
|
77
|
|
|
@@ -85,14 +85,14 @@ discard block |
|
|
block discarded – undo |
|
85
|
85
|
* @param object $order |
|
86
|
86
|
* @param float $amount |
|
87
|
87
|
*/ |
|
88
|
|
- public static function update_stripe_fee( $order = null, $amount = 0.0 ) { |
|
89
|
|
- if ( is_null( $order ) ) { |
|
|
88
|
+ public static function update_stripe_fee($order = null, $amount = 0.0) { |
|
|
89
|
+ if (is_null($order)) { |
|
90
|
90
|
return false; |
|
91
|
91
|
} |
|
92
|
92
|
|
|
93
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
93
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
94
|
94
|
|
|
95
|
|
- WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_FEE, $amount ) : $order->update_meta_data( self::META_NAME_FEE, $amount ); |
|
|
95
|
+ WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_FEE, $amount) : $order->update_meta_data(self::META_NAME_FEE, $amount); |
|
96
|
96
|
} |
|
97
|
97
|
|
|
98
|
98
|
/** |
|
@@ -101,15 +101,15 @@ discard block |
|
|
block discarded – undo |
|
101
|
101
|
* @since 4.1.0 |
|
102
|
102
|
* @param object $order |
|
103
|
103
|
*/ |
|
104
|
|
- public static function delete_stripe_fee( $order = null ) { |
|
105
|
|
- if ( is_null( $order ) ) { |
|
|
104
|
+ public static function delete_stripe_fee($order = null) { |
|
|
105
|
+ if (is_null($order)) { |
|
106
|
106
|
return false; |
|
107
|
107
|
} |
|
108
|
108
|
|
|
109
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
109
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
110
|
110
|
|
|
111
|
|
- delete_post_meta( $order_id, self::META_NAME_FEE ); |
|
112
|
|
- delete_post_meta( $order_id, self::LEGACY_META_NAME_FEE ); |
|
|
111
|
+ delete_post_meta($order_id, self::META_NAME_FEE); |
|
|
112
|
+ delete_post_meta($order_id, self::LEGACY_META_NAME_FEE); |
|
113
|
113
|
} |
|
114
|
114
|
|
|
115
|
115
|
/** |
|
@@ -119,22 +119,22 @@ discard block |
|
|
block discarded – undo |
|
119
|
119
|
* @param object $order |
|
120
|
120
|
* @return string $amount |
|
121
|
121
|
*/ |
|
122
|
|
- public static function get_stripe_net( $order = null ) { |
|
123
|
|
- if ( is_null( $order ) ) { |
|
|
122
|
+ public static function get_stripe_net($order = null) { |
|
|
123
|
+ if (is_null($order)) { |
|
124
|
124
|
return false; |
|
125
|
125
|
} |
|
126
|
126
|
|
|
127
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
127
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
128
|
128
|
|
|
129
|
|
- $amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::META_NAME_NET, true ) : $order->get_meta( self::META_NAME_NET, true ); |
|
|
129
|
+ $amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::META_NAME_NET, true) : $order->get_meta(self::META_NAME_NET, true); |
|
130
|
130
|
|
|
131
|
131
|
// If not found let's check for legacy name. |
|
132
|
|
- if ( empty( $amount ) ) { |
|
133
|
|
- $amount = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? get_post_meta( $order_id, self::LEGACY_META_NAME_NET, true ) : $order->get_meta( self::LEGACY_META_NAME_NET, true ); |
|
|
132
|
+ if (empty($amount)) { |
|
|
133
|
+ $amount = WC_Stripe_Helper::is_wc_lt('3.0') ? get_post_meta($order_id, self::LEGACY_META_NAME_NET, true) : $order->get_meta(self::LEGACY_META_NAME_NET, true); |
|
134
|
134
|
|
|
135
|
135
|
// If found update to new name. |
|
136
|
|
- if ( $amount ) { |
|
137
|
|
- self::update_stripe_net( $order, $amount ); |
|
|
136
|
+ if ($amount) { |
|
|
137
|
+ self::update_stripe_net($order, $amount); |
|
138
|
138
|
} |
|
139
|
139
|
} |
|
140
|
140
|
|
|
@@ -148,14 +148,14 @@ discard block |
|
|
block discarded – undo |
|
148
|
148
|
* @param object $order |
|
149
|
149
|
* @param float $amount |
|
150
|
150
|
*/ |
|
151
|
|
- public static function update_stripe_net( $order = null, $amount = 0.0 ) { |
|
152
|
|
- if ( is_null( $order ) ) { |
|
|
151
|
+ public static function update_stripe_net($order = null, $amount = 0.0) { |
|
|
152
|
+ if (is_null($order)) { |
|
153
|
153
|
return false; |
|
154
|
154
|
} |
|
155
|
155
|
|
|
156
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
156
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
157
|
157
|
|
|
158
|
|
- WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $order_id, self::META_NAME_NET, $amount ) : $order->update_meta_data( self::META_NAME_NET, $amount ); |
|
|
158
|
+ WC_Stripe_Helper::is_wc_lt('3.0') ? update_post_meta($order_id, self::META_NAME_NET, $amount) : $order->update_meta_data(self::META_NAME_NET, $amount); |
|
159
|
159
|
} |
|
160
|
160
|
|
|
161
|
161
|
/** |
|
@@ -164,15 +164,15 @@ discard block |
|
|
block discarded – undo |
|
164
|
164
|
* @since 4.1.0 |
|
165
|
165
|
* @param object $order |
|
166
|
166
|
*/ |
|
167
|
|
- public static function delete_stripe_net( $order = null ) { |
|
168
|
|
- if ( is_null( $order ) ) { |
|
|
167
|
+ public static function delete_stripe_net($order = null) { |
|
|
168
|
+ if (is_null($order)) { |
|
169
|
169
|
return false; |
|
170
|
170
|
} |
|
171
|
171
|
|
|
172
|
|
- $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
|
172
|
+ $order_id = WC_Stripe_Helper::is_wc_lt('3.0') ? $order->id : $order->get_id(); |
|
173
|
173
|
|
|
174
|
|
- delete_post_meta( $order_id, self::META_NAME_NET ); |
|
175
|
|
- delete_post_meta( $order_id, self::LEGACY_META_NAME_NET ); |
|
|
174
|
+ delete_post_meta($order_id, self::META_NAME_NET); |
|
|
175
|
+ delete_post_meta($order_id, self::LEGACY_META_NAME_NET); |
|
176
|
176
|
} |
|
177
|
177
|
|
|
178
|
178
|
/** |
|
@@ -183,15 +183,15 @@ discard block |
|
|
block discarded – undo |
|
183
|
183
|
* |
|
184
|
184
|
* @return float|int |
|
185
|
185
|
*/ |
|
186
|
|
- public static function get_stripe_amount( $total, $currency = '' ) { |
|
187
|
|
- if ( ! $currency ) { |
|
|
186
|
+ public static function get_stripe_amount($total, $currency = '') { |
|
|
187
|
+ if ( ! $currency) { |
|
188
|
188
|
$currency = get_woocommerce_currency(); |
|
189
|
189
|
} |
|
190
|
190
|
|
|
191
|
|
- if ( in_array( strtolower( $currency ), self::no_decimal_currencies() ) ) { |
|
192
|
|
- return absint( $total ); |
|
|
191
|
+ if (in_array(strtolower($currency), self::no_decimal_currencies())) { |
|
|
192
|
+ return absint($total); |
|
193
|
193
|
} else { |
|
194
|
|
- return absint( wc_format_decimal( ( (float) $total * 100 ), wc_get_price_decimals() ) ); // In cents. |
|
|
194
|
+ return absint(wc_format_decimal(((float) $total * 100), wc_get_price_decimals())); // In cents. |
|
195
|
195
|
} |
|
196
|
196
|
} |
|
197
|
197
|
|
|
@@ -206,24 +206,24 @@ discard block |
|
|
block discarded – undo |
|
206
|
206
|
return apply_filters( |
|
207
|
207
|
'wc_stripe_localized_messages', |
|
208
|
208
|
array( |
|
209
|
|
- 'invalid_number' => __( 'The card number is not a valid credit card number.', 'woocommerce-gateway-stripe' ), |
|
210
|
|
- 'invalid_expiry_month' => __( 'The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe' ), |
|
211
|
|
- 'invalid_expiry_year' => __( 'The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe' ), |
|
212
|
|
- 'invalid_cvc' => __( 'The card\'s security code is invalid.', 'woocommerce-gateway-stripe' ), |
|
213
|
|
- 'incorrect_number' => __( 'The card number is incorrect.', 'woocommerce-gateway-stripe' ), |
|
214
|
|
- 'incomplete_number' => __( 'The card number is incomplete.', 'woocommerce-gateway-stripe' ), |
|
215
|
|
- 'incomplete_cvc' => __( 'The card\'s security code is incomplete.', 'woocommerce-gateway-stripe' ), |
|
216
|
|
- 'incomplete_expiry' => __( 'The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe' ), |
|
217
|
|
- 'expired_card' => __( 'The card has expired.', 'woocommerce-gateway-stripe' ), |
|
218
|
|
- 'incorrect_cvc' => __( 'The card\'s security code is incorrect.', 'woocommerce-gateway-stripe' ), |
|
219
|
|
- 'incorrect_zip' => __( 'The card\'s zip code failed validation.', 'woocommerce-gateway-stripe' ), |
|
220
|
|
- 'invalid_expiry_year_past' => __( 'The card\'s expiration year is in the past', 'woocommerce-gateway-stripe' ), |
|
221
|
|
- 'card_declined' => __( 'The card was declined.', 'woocommerce-gateway-stripe' ), |
|
222
|
|
- 'missing' => __( 'There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe' ), |
|
223
|
|
- 'processing_error' => __( 'An error occurred while processing the card.', 'woocommerce-gateway-stripe' ), |
|
224
|
|
- 'invalid_request_error' => __( 'Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe' ), |
|
225
|
|
- 'invalid_sofort_country' => __( 'The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe' ), |
|
226
|
|
- 'email_invalid' => __( 'Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe' ), |
|
|
209
|
+ 'invalid_number' => __('The card number is not a valid credit card number.', 'woocommerce-gateway-stripe'), |
|
|
210
|
+ 'invalid_expiry_month' => __('The card\'s expiration month is invalid.', 'woocommerce-gateway-stripe'), |
|
|
211
|
+ 'invalid_expiry_year' => __('The card\'s expiration year is invalid.', 'woocommerce-gateway-stripe'), |
|
|
212
|
+ 'invalid_cvc' => __('The card\'s security code is invalid.', 'woocommerce-gateway-stripe'), |
|
|
213
|
+ 'incorrect_number' => __('The card number is incorrect.', 'woocommerce-gateway-stripe'), |
|
|
214
|
+ 'incomplete_number' => __('The card number is incomplete.', 'woocommerce-gateway-stripe'), |
|
|
215
|
+ 'incomplete_cvc' => __('The card\'s security code is incomplete.', 'woocommerce-gateway-stripe'), |
|
|
216
|
+ 'incomplete_expiry' => __('The card\'s expiration date is incomplete.', 'woocommerce-gateway-stripe'), |
|
|
217
|
+ 'expired_card' => __('The card has expired.', 'woocommerce-gateway-stripe'), |
|
|
218
|
+ 'incorrect_cvc' => __('The card\'s security code is incorrect.', 'woocommerce-gateway-stripe'), |
|
|
219
|
+ 'incorrect_zip' => __('The card\'s zip code failed validation.', 'woocommerce-gateway-stripe'), |
|
|
220
|
+ 'invalid_expiry_year_past' => __('The card\'s expiration year is in the past', 'woocommerce-gateway-stripe'), |
|
|
221
|
+ 'card_declined' => __('The card was declined.', 'woocommerce-gateway-stripe'), |
|
|
222
|
+ 'missing' => __('There is no card on a customer that is being charged.', 'woocommerce-gateway-stripe'), |
|
|
223
|
+ 'processing_error' => __('An error occurred while processing the card.', 'woocommerce-gateway-stripe'), |
|
|
224
|
+ 'invalid_request_error' => __('Unable to process this payment, please try again or use alternative method.', 'woocommerce-gateway-stripe'), |
|
|
225
|
+ 'invalid_sofort_country' => __('The billing country is not accepted by SOFORT. Please try another country.', 'woocommerce-gateway-stripe'), |
|
|
226
|
+ 'email_invalid' => __('Invalid email address, please correct and try again.', 'woocommerce-gateway-stripe'), |
|
227
|
227
|
) |
|
228
|
228
|
); |
|
229
|
229
|
} |
|
@@ -264,24 +264,24 @@ discard block |
|
|
block discarded – undo |
|
264
|
264
|
* @param string $type Type of number to format |
|
265
|
265
|
* @return string |
|
266
|
266
|
*/ |
|
267
|
|
- public static function format_balance_fee( $balance_transaction, $type = 'fee' ) { |
|
268
|
|
- if ( ! is_object( $balance_transaction ) ) { |
|
|
267
|
+ public static function format_balance_fee($balance_transaction, $type = 'fee') { |
|
|
268
|
+ if ( ! is_object($balance_transaction)) { |
|
269
|
269
|
return; |
|
270
|
270
|
} |
|
271
|
271
|
|
|
272
|
|
- if ( in_array( strtolower( $balance_transaction->currency ), self::no_decimal_currencies() ) ) { |
|
273
|
|
- if ( 'fee' === $type ) { |
|
|
272
|
+ if (in_array(strtolower($balance_transaction->currency), self::no_decimal_currencies())) { |
|
|
273
|
+ if ('fee' === $type) { |
|
274
|
274
|
return $balance_transaction->fee; |
|
275
|
275
|
} |
|
276
|
276
|
|
|
277
|
277
|
return $balance_transaction->net; |
|
278
|
278
|
} |
|
279
|
279
|
|
|
280
|
|
- if ( 'fee' === $type ) { |
|
281
|
|
- return number_format( $balance_transaction->fee / 100, 2, '.', '' ); |
|
|
280
|
+ if ('fee' === $type) { |
|
|
281
|
+ return number_format($balance_transaction->fee / 100, 2, '.', ''); |
|
282
|
282
|
} |
|
283
|
283
|
|
|
284
|
|
- return number_format( $balance_transaction->net / 100, 2, '.', '' ); |
|
|
284
|
+ return number_format($balance_transaction->net / 100, 2, '.', ''); |
|
285
|
285
|
} |
|
286
|
286
|
|
|
287
|
287
|
/** |
|
@@ -289,7 +289,7 @@ discard block |
|
|
block discarded – undo |
|
289
|
289
|
*/ |
|
290
|
290
|
public static function get_minimum_amount() { |
|
291
|
291
|
// Check order amount |
|
292
|
|
- switch ( get_woocommerce_currency() ) { |
|
|
292
|
+ switch (get_woocommerce_currency()) { |
|
293
|
293
|
case 'USD': |
|
294
|
294
|
case 'CAD': |
|
295
|
295
|
case 'EUR': |
|
@@ -334,14 +334,14 @@ discard block |
|
|
block discarded – undo |
|
334
|
334
|
* @param string $method The payment method to get the settings from. |
|
335
|
335
|
* @param string $setting The name of the setting to get. |
|
336
|
336
|
*/ |
|
337
|
|
- public static function get_settings( $method = null, $setting = null ) { |
|
338
|
|
- $all_settings = null === $method ? get_option( 'woocommerce_stripe_settings', array() ) : get_option( 'woocommerce_stripe_' . $method . '_settings', array() ); |
|
|
337
|
+ public static function get_settings($method = null, $setting = null) { |
|
|
338
|
+ $all_settings = null === $method ? get_option('woocommerce_stripe_settings', array()) : get_option('woocommerce_stripe_' . $method . '_settings', array()); |
|
339
|
339
|
|
|
340
|
|
- if ( null === $setting ) { |
|
|
340
|
+ if (null === $setting) { |
|
341
|
341
|
return $all_settings; |
|
342
|
342
|
} |
|
343
|
343
|
|
|
344
|
|
- return isset( $all_settings[ $setting ] ) ? $all_settings[ $setting ] : ''; |
|
|
344
|
+ return isset($all_settings[$setting]) ? $all_settings[$setting] : ''; |
|
345
|
345
|
} |
|
346
|
346
|
|
|
347
|
347
|
/** |
|
@@ -351,7 +351,7 @@ discard block |
|
|
block discarded – undo |
|
351
|
351
|
* @return bool |
|
352
|
352
|
*/ |
|
353
|
353
|
public static function is_pre_orders_exists() { |
|
354
|
|
- return class_exists( 'WC_Pre_Orders_Order' ); |
|
|
354
|
+ return class_exists('WC_Pre_Orders_Order'); |
|
355
|
355
|
} |
|
356
|
356
|
|
|
357
|
357
|
/** |
|
@@ -363,9 +363,9 @@ discard block |
|
|
block discarded – undo |
|
363
|
363
|
* @return bool |
|
364
|
364
|
*/ |
|
365
|
365
|
public static function is_pre_30() { |
|
366
|
|
- error_log( 'is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.' ); |
|
|
366
|
+ error_log('is_pre_30() function has been deprecated since 4.1.11. Please use is_wc_lt( $version ) instead.'); |
|
367
|
367
|
|
|
368
|
|
- return self::is_wc_lt( '3.0' ); |
|
|
368
|
+ return self::is_wc_lt('3.0'); |
|
369
|
369
|
} |
|
370
|
370
|
|
|
371
|
371
|
/** |
|
@@ -375,8 +375,8 @@ discard block |
|
|
block discarded – undo |
|
375
|
375
|
* @param string $version Version to check against. |
|
376
|
376
|
* @return bool |
|
377
|
377
|
*/ |
|
378
|
|
- public static function is_wc_lt( $version ) { |
|
379
|
|
- return version_compare( WC_VERSION, $version, '<' ); |
|
|
378
|
+ public static function is_wc_lt($version) { |
|
|
379
|
+ return version_compare(WC_VERSION, $version, '<'); |
|
380
|
380
|
} |
|
381
|
381
|
|
|
382
|
382
|
/** |
|
@@ -389,7 +389,7 @@ discard block |
|
|
block discarded – undo |
|
389
|
389
|
* @return string |
|
390
|
390
|
*/ |
|
391
|
391
|
public static function get_webhook_url() { |
|
392
|
|
- return add_query_arg( 'wc-api', 'wc_stripe', trailingslashit( get_home_url() ) ); |
|
|
392
|
+ return add_query_arg('wc-api', 'wc_stripe', trailingslashit(get_home_url())); |
|
393
|
393
|
} |
|
394
|
394
|
|
|
395
|
395
|
/** |
|
@@ -399,13 +399,13 @@ discard block |
|
|
block discarded – undo |
|
399
|
399
|
* @version 4.0.0 |
|
400
|
400
|
* @param string $source_id |
|
401
|
401
|
*/ |
|
402
|
|
- public static function get_order_by_source_id( $source_id ) { |
|
|
402
|
+ public static function get_order_by_source_id($source_id) { |
|
403
|
403
|
global $wpdb; |
|
404
|
404
|
|
|
405
|
|
- $order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id' ) ); |
|
|
405
|
+ $order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $source_id, '_stripe_source_id')); |
|
406
|
406
|
|
|
407
|
|
- if ( ! empty( $order_id ) ) { |
|
408
|
|
- return wc_get_order( $order_id ); |
|
|
407
|
+ if ( ! empty($order_id)) { |
|
|
408
|
+ return wc_get_order($order_id); |
|
409
|
409
|
} |
|
410
|
410
|
|
|
411
|
411
|
return false; |
|
@@ -418,17 +418,17 @@ discard block |
|
|
block discarded – undo |
|
418
|
418
|
* @since 4.1.16 Return false if charge_id is empty. |
|
419
|
419
|
* @param string $charge_id |
|
420
|
420
|
*/ |
|
421
|
|
- public static function get_order_by_charge_id( $charge_id ) { |
|
|
421
|
+ public static function get_order_by_charge_id($charge_id) { |
|
422
|
422
|
global $wpdb; |
|
423
|
423
|
|
|
424
|
|
- if ( empty( $charge_id ) ) { |
|
|
424
|
+ if (empty($charge_id)) { |
|
425
|
425
|
return false; |
|
426
|
426
|
} |
|
427
|
427
|
|
|
428
|
|
- $order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id' ) ); |
|
|
428
|
+ $order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $charge_id, '_transaction_id')); |
|
429
|
429
|
|
|
430
|
|
- if ( ! empty( $order_id ) ) { |
|
431
|
|
- return wc_get_order( $order_id ); |
|
|
430
|
+ if ( ! empty($order_id)) { |
|
|
431
|
+ return wc_get_order($order_id); |
|
432
|
432
|
} |
|
433
|
433
|
|
|
434
|
434
|
return false; |
|
@@ -441,13 +441,13 @@ discard block |
|
|
block discarded – undo |
|
441
|
441
|
* @param string $intent_id The ID of the intent. |
|
442
|
442
|
* @return WC_Order|bool Either an order or false when not found. |
|
443
|
443
|
*/ |
|
444
|
|
- public static function get_order_by_intent_id( $intent_id ) { |
|
|
444
|
+ public static function get_order_by_intent_id($intent_id) { |
|
445
|
445
|
global $wpdb; |
|
446
|
446
|
|
|
447
|
|
- $order_id = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id' ) ); |
|
|
447
|
+ $order_id = $wpdb->get_var($wpdb->prepare("SELECT DISTINCT ID FROM $wpdb->posts as posts LEFT JOIN $wpdb->postmeta as meta ON posts.ID = meta.post_id WHERE meta.meta_value = %s AND meta.meta_key = %s", $intent_id, '_stripe_intent_id')); |
|
448
|
448
|
|
|
449
|
|
- if ( ! empty( $order_id ) ) { |
|
450
|
|
- return wc_get_order( $order_id ); |
|
|
449
|
+ if ( ! empty($order_id)) { |
|
|
450
|
+ return wc_get_order($order_id); |
|
451
|
451
|
} |
|
452
|
452
|
|
|
453
|
453
|
return false; |
|
@@ -463,13 +463,13 @@ discard block |
|
|
block discarded – undo |
|
463
|
463
|
* @param string $statement_descriptor |
|
464
|
464
|
* @return string $statement_descriptor Sanitized statement descriptor |
|
465
|
465
|
*/ |
|
466
|
|
- public static function clean_statement_descriptor( $statement_descriptor = '' ) { |
|
467
|
|
- $disallowed_characters = array( '<', '>', '"', "'" ); |
|
|
466
|
+ public static function clean_statement_descriptor($statement_descriptor = '') { |
|
|
467
|
+ $disallowed_characters = array('<', '>', '"', "'"); |
|
468
|
468
|
|
|
469
|
469
|
// Remove special characters. |
|
470
|
|
- $statement_descriptor = str_replace( $disallowed_characters, '', $statement_descriptor ); |
|
|
470
|
+ $statement_descriptor = str_replace($disallowed_characters, '', $statement_descriptor); |
|
471
|
471
|
|
|
472
|
|
- $statement_descriptor = substr( trim( $statement_descriptor ), 0, 22 ); |
|
|
472
|
+ $statement_descriptor = substr(trim($statement_descriptor), 0, 22); |
|
473
|
473
|
|
|
474
|
474
|
return $statement_descriptor; |
|
475
|
475
|
} |