gateway = $gateway; $this->http = $http; $this->account = $account; } /** * Initializes this class's WP hooks. * * @return void */ public function init_hooks() { add_action( 'woocommerce_system_status_report', [ $this, 'render_status_report_section' ], 1 ); add_filter( 'woocommerce_debug_tools', [ $this, 'debug_tools' ] ); } /** * Add WCPay tools to the Woo debug tools. * * @param array $tools List of current available tools. */ public function debug_tools( $tools ) { return array_merge( $tools, [ 'clear_wcpay_account_cache' => [ 'name' => sprintf( /* translators: %s: WooPayments */ __( 'Clear %s account cache', 'woocommerce-payments' ), 'WooPayments' ), 'button' => __( 'Clear', 'woocommerce-payments' ), 'desc' => sprintf( /* translators: %s: WooPayments */ __( 'This tool will clear the cached account values used in %s.', 'woocommerce-payments' ), 'WooPayments' ), 'callback' => [ $this->account, 'refresh_account_data' ], ], 'delete_wcpay_test_orders' => [ 'name' => sprintf( /* translators: %s: WooPayments */ __( 'Delete %s test orders', 'woocommerce-payments' ), 'WooPayments' ), 'button' => __( 'Delete', 'woocommerce-payments' ), 'desc' => sprintf( /* translators: %s: WooPayments */ __( 'Note: This option deletes all test mode orders placed via %s. Orders placed via other gateways will not be affected. Use with caution, as this action cannot be undone.', 'woocommerce-payments' ), 'WooPayments' ), 'callback' => [ $this, 'delete_test_orders' ], ], ] ); } /** * Deletes all test orders created with WooPayments. * * Test orders are identified by the '_wcpay_mode' meta key with value 'test'. * * @return string Success or error message. */ public function delete_test_orders() { // Add explicit capability check. if ( ! current_user_can( 'manage_woocommerce' ) ) { return __( 'You do not have permission to delete orders.', 'woocommerce-payments' ); } try { // Get all orders with test mode meta. $test_orders = wc_get_orders( [ 'limit' => -1, // phpcs:ignore 'meta_key' => WC_Payments_Order_Service::WCPAY_MODE_META_KEY, // phpcs:ignore 'meta_value' => 'test', 'return' => 'objects', ] ); if ( empty( $test_orders ) ) { return __( 'No test orders found.', 'woocommerce-payments' ); } $deleted_count = 0; foreach ( $test_orders as $order ) { // Permanently delete the order (skip trash). if ( $order->delete( true ) ) { ++$deleted_count; } } return sprintf( /* translators: %d: number of orders deleted */ _n( '%d test order has been permanently deleted.', '%d test orders have been permanently deleted.', $deleted_count, 'woocommerce-payments' ), $deleted_count ); } catch ( Exception $e ) { return sprintf( /* translators: %s: error message */ __( 'Error deleting test orders: %s', 'woocommerce-payments' ), $e->getMessage() ); } } /** * Renders WCPay information on the status page. */ public function render_status_report_section() { ?>
WooPayments |
||
|---|---|---|
| : | ||
| : | http->is_connected() ? esc_html__( 'Yes', 'woocommerce-payments' ) : ' ' . esc_html__( 'No', 'woocommerce-payments' ) . ''; ?> | |
| : | http->is_connected() ? $this->http->get_blog_id() : '-' ); ?> | |
| : | gateway->is_connected() ? esc_html( $this->account->get_stripe_account_id() ?? '-' ) : ' ' . esc_html__( 'Not connected', 'woocommerce-payments' ) . ''; ?> | |
| : | gateway->needs_setup() ? ' ' . esc_html__( 'Needs setup', 'woocommerce-payments' ) . '' : ( $this->gateway->is_enabled() ? esc_html__( 'Enabled', 'woocommerce-payments' ) : esc_html__( 'Disabled', 'woocommerce-payments' ) ); ?> | |
| : | is_test() ? esc_html_e( 'Enabled', 'woocommerce-payments' ) : esc_html_e( 'Disabled', 'woocommerce-payments' ); ?> | |
| : | gateway->get_upe_enabled_payment_method_ids() ) ); ?> | |
| : | ||
| : | gateway->get_option( 'platform_checkout_button_locations', [] ); $woopay_enabled_locations = empty( $woopay_enabled_locations ) ? 'no locations enabled' : implode( ',', $woopay_enabled_locations ); echo esc_html( WC_Payments_Features::is_woopay_enabled() ? __( 'Enabled', 'woocommerce-payments' ) . ' (' . $woopay_enabled_locations . ')' : __( 'Disabled', 'woocommerce-payments' ) ); ?> | |
| : | ||
| : | gateway->get_option( 'payment_request' ); $payment_request_enabled_locations = $this->gateway->get_option( 'payment_request_button_locations', [] ); $payment_request_enabled_locations = empty( $payment_request_enabled_locations ) ? 'no locations enabled' : implode( ',', $payment_request_enabled_locations ); echo esc_html( $payment_request_enabled ? __( 'Enabled', 'woocommerce-payments' ) . ' (' . $payment_request_enabled_locations . ')' : __( 'Disabled', 'woocommerce-payments' ) ); ?> | |
| : | gateway->get_option( 'current_protection_level' ) ); ?> | |
| : | gateway->get_option( 'advanced_fraud_protection_settings' ) ), true ); $list = array_filter( array_map( function ( $rule ) { if ( empty( $rule['key'] ) ) { return null; } switch ( $rule['key'] ) { case 'avs_verification': return 'AVS Verification'; case 'international_ip_address': return 'International IP Address'; case 'ip_address_mismatch': return 'IP Address Mismatch'; case 'address_mismatch': return 'Address Mismatch'; case 'purchase_price_threshold': return 'Purchase Price Threshold'; case 'order_items_threshold': return 'Order Items Threshold'; default: // Ignore all others. return null; } }, $adv_fraud_settings ) ); echo empty( $list ) ? '-' : esc_html( implode( ',', $list ) ); ?> | |
| : | ||
| : | gateway->get_option( 'manual_capture' ); echo $manual_capture_enabled ? esc_html__( 'Enabled', 'woocommerce-payments' ) : esc_html__( 'Disabled', 'woocommerce-payments' ); ?> | |
| : | ||
| : | ||