WordPress at Your Fingertips
function is not described

WC_Checkout::process_order_payment() protected WC 3.0.0

Process an order that does require payment.

{} It's a method of the class: WC_Checkout{}

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->process_order_payment( $order_id, $payment_method );
$order_id(int) (required)
Order ID.
$payment_method(string) (required)
Payment method.

Changelog

Since 3.0.0 Introduced.

Code of WC_Checkout::process_order_payment() WC 5.9.0

protected function process_order_payment( $order_id, $payment_method ) {
	$available_gateways = WC()->payment_gateways->get_available_payment_gateways();

	if ( ! isset( $available_gateways[ $payment_method ] ) ) {
		return;
	}

	// Store Order ID in session so it can be re-used after payment failure.
	WC()->session->set( 'order_awaiting_payment', $order_id );

	// Process Payment.
	$result = $available_gateways[ $payment_method ]->process_payment( $order_id );

	// Redirect to success/confirmation/payment page.
	if ( isset( $result['result'] ) && 'success' === $result['result'] ) {
		$result['order_id'] = $order_id;

		$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );

		if ( ! is_ajax() ) {
			// phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
			wp_redirect( $result['redirect'] );
			exit;
		}

		wp_send_json( $result );
	}
}