WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Gateway_Paypal::capture_payment() public WC 1.0

Capture payment when the order is changed from on-hold to complete or processing

{} Это метод класса: WC_Gateway_Paypal{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$WC_Gateway_Paypal = new WC_Gateway_Paypal();
$WC_Gateway_Paypal->capture_payment( $order_id );
$order_id(int) (обязательный)
Order ID.

Код WC_Gateway_Paypal::capture_payment() WC 5.6.0

public function capture_payment( $order_id ) {
	$order = wc_get_order( $order_id );

	if ( 'paypal' === $order->get_payment_method() && 'pending' === $order->get_meta( '_paypal_status', true ) && $order->get_transaction_id() ) {
		$this->init_api();
		$result = WC_Gateway_Paypal_API_Handler::do_capture( $order );

		if ( is_wp_error( $result ) ) {
			$this->log( 'Capture Failed: ' . $result->get_error_message(), 'error' );
			/* translators: %s: Paypal gateway error message */
			$order->add_order_note( sprintf( __( 'Payment could not be captured: %s', 'woocommerce' ), $result->get_error_message() ) );
			return;
		}

		$this->log( 'Capture Result: ' . wc_print_r( $result, true ) );

		// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		if ( ! empty( $result->PAYMENTSTATUS ) ) {
			switch ( $result->PAYMENTSTATUS ) {
				case 'Completed':
					/* translators: 1: Amount, 2: Authorization ID, 3: Transaction ID */
					$order->add_order_note( sprintf( __( 'Payment of %1$s was captured - Auth ID: %2$s, Transaction ID: %3$s', 'woocommerce' ), $result->AMT, $result->AUTHORIZATIONID, $result->TRANSACTIONID ) );
					update_post_meta( $order->get_id(), '_paypal_status', $result->PAYMENTSTATUS );
					update_post_meta( $order->get_id(), '_transaction_id', $result->TRANSACTIONID );
					break;
				default:
					/* translators: 1: Authorization ID, 2: Payment status */
					$order->add_order_note( sprintf( __( 'Payment could not be captured - Auth ID: %1$s, Status: %2$s', 'woocommerce' ), $result->AUTHORIZATIONID, $result->PAYMENTSTATUS ) );
					break;
			}
		}
		// phpcs:enable
	}
}