WordPress at a glance
function is not described

wc_get_payment_gateway_by_order() WC 2.2

Get payment gateway class by order data.

No Hooks.

Return

WC_Payment_Gateway|true|false. Nothing.

Usage

wc_get_payment_gateway_by_order( $order );
$order(int|WC_Order) (required)
Order instance.

Changelog

Since 2.2 Introduced.

Code of wc_get_payment_gateway_by_order() WC 5.3.0

<?php
function wc_get_payment_gateway_by_order( $order ) {
	if ( WC()->payment_gateways() ) {
		$payment_gateways = WC()->payment_gateways()->payment_gateways();
	} else {
		$payment_gateways = array();
	}

	if ( ! is_object( $order ) ) {
		$order_id = absint( $order );
		$order    = wc_get_order( $order_id );
	}

	return is_a( $order, 'WC_Order' ) && isset( $payment_gateways[ $order->get_payment_method() ] ) ? $payment_gateways[ $order->get_payment_method() ] : false;
}