REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.65 KB
Close
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/StoreApi/Utilities/PaymentUtils.php
Text
Base64
<?php declare(strict_types=1); namespace Automattic\WooCommerce\StoreApi\Utilities; /** * PaymentUtils * * Utility class for payment methods. */ class PaymentUtils { /** * Callback for woocommerce_payment_methods_list_item filter to add token id * to the generated list. * * @param array $list_item The current list item for the saved payment method. * @param \WC_Token $token The token for the current list item. * * @return array The list item with the token id added. */ public static function include_token_id_with_payment_methods( $list_item, $token ) { $list_item['tokenId'] = $token->get_id(); $brand = ! empty( $list_item['method']['brand'] ) ? strtolower( $list_item['method']['brand'] ) : ''; if ( ! empty( $brand ) && esc_html__( 'Credit card', 'woocommerce' ) !== $brand ) { $list_item['method']['brand'] = wc_get_credit_card_type_label( $brand ); } return $list_item; } /** * Get enabled payment gateways. * * @return array */ public static function get_enabled_payment_gateways() { $payment_gateways = WC()->payment_gateways->payment_gateways(); return array_filter( $payment_gateways, function ( $payment_gateway ) { return 'yes' === $payment_gateway->enabled; } ); } /** * Returns enabled saved payment methods for a customer and the default method if there are multiple. * * @return array */ public static function get_saved_payment_methods() { if ( ! is_user_logged_in() ) { return; } add_filter( 'woocommerce_payment_methods_list_item', [ self::class, 'include_token_id_with_payment_methods' ], 10, 2 ); $enabled_payment_gateways = self::get_enabled_payment_gateways(); $saved_payment_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); $payment_methods = [ 'enabled' => [], 'default' => null, ]; // Filter out payment methods that are not enabled. foreach ( $saved_payment_methods as $payment_method_group => $saved_payment_methods ) { $payment_methods['enabled'][ $payment_method_group ] = array_values( array_filter( $saved_payment_methods, function ( $saved_payment_method ) use ( $enabled_payment_gateways, &$payment_methods ) { if ( true === $saved_payment_method['is_default'] && null === $payment_methods['default'] ) { $payment_methods['default'] = $saved_payment_method; } return in_array( $saved_payment_method['method']['gateway'], array_keys( $enabled_payment_gateways ), true ); } ) ); } remove_filter( 'woocommerce_payment_methods_list_item', [ self::class, 'include_token_id_with_payment_methods' ], 10, 2 ); return $payment_methods; } /** * Returns the default payment method for a customer. * * @return string */ public static function get_default_payment_method() { $saved_payment_methods = self::get_saved_payment_methods(); // A saved payment method exists, set as default. if ( $saved_payment_methods && ! empty( $saved_payment_methods['default'] ) ) { return $saved_payment_methods['default']['method']['gateway'] ?? ''; } $chosen_payment_method = WC()->session->get( 'chosen_payment_method' ); // If payment method is already stored in session, use it. if ( $chosen_payment_method ) { return $chosen_payment_method; } // If no saved payment method exists, use the first enabled payment method. $enabled_payment_gateways = self::get_enabled_payment_gateways(); if ( empty( $enabled_payment_gateways ) ) { return ''; } $first_key = array_key_first( $enabled_payment_gateways ); $first_payment_method = $enabled_payment_gateways[ $first_key ]; return $first_payment_method->id ?? ''; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 21
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
AgenticCheckoutUtils.php
14.76 KB
lrw-r--r--
2026-02-23 17:58:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ArrayUtils.php
1.49 KB
lrw-r--r--
2024-04-30 19:35:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CartController.php
48.42 KB
lrw-r--r--
2026-03-12 20:10:34
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CartTokenUtils.php
1.81 KB
lrw-r--r--
2025-06-23 19:46:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CheckoutTrait.php
10.82 KB
lrw-r--r--
2025-06-23 19:46:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DraftOrderTrait.php
1.76 KB
lrw-r--r--
2024-09-04 20:34:26
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
JsonWebToken.php
5.45 KB
lrw-r--r--
2025-07-29 12:34:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LocalPickupUtils.php
5.67 KB
lrw-r--r--
2026-01-19 14:46:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
NoticeHandler.php
2.02 KB
lrw-r--r--
2025-03-03 22:28:12
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
OrderAuthorizationTrait.php
3.29 KB
lrw-r--r--
2025-12-22 17:20:32
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
OrderController.php
32.10 KB
lrw-r--r--
2026-05-05 14:26:50
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Pagination.php
2.05 KB
lrw-r--r--
2023-12-27 00:45:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PaymentUtils.php
3.65 KB
lrw-r--r--
2025-05-12 21:07:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProductItemTrait.php
3.54 KB
lrw-r--r--
2026-03-30 17:12:24
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProductLinksTrait.php
1.82 KB
lrw-r--r--
2026-03-30 17:12:24
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProductQuery.php
21.61 KB
lrw-r--r--
2026-05-05 14:26:50
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProductQueryFilters.php
9.25 KB
lrw-r--r--
2025-07-29 12:34:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
QuantityLimits.php
10.11 KB
lrw-r--r--
2025-07-29 12:34:58
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RateLimits.php
6.14 KB
lrw-r--r--
2025-03-03 22:28:12
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SanitizationUtils.php
794 B
lrw-r--r--
2024-02-27 18:59:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ValidationUtils.php
1.73 KB
lrw-r--r--
2023-12-27 00:45:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).