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

WC_Gateway_Paypal::process_refund() public WC 1.0

Process a refund if supported.

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

Хуков нет.

Возвращает

true/false/WP_Error.

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

$WC_Gateway_Paypal = new WC_Gateway_Paypal();
$WC_Gateway_Paypal->process_refund( $order_id, $amount, $reason );
$order_id(число) (обязательный)
Order ID.
$amount(float)
Refund amount.
$reason(строка)
Refund reason.

Код WC_Gateway_Paypal::process_refund() WC 5.0.0

<?php
public function process_refund( $order_id, $amount = null, $reason = '' ) {
	$order = wc_get_order( $order_id );

	if ( ! $this->can_refund_order( $order ) ) {
		return new WP_Error( 'error', __( 'Refund failed.', 'woocommerce' ) );
	}

	$this->init_api();

	$result = WC_Gateway_Paypal_API_Handler::refund_transaction( $order, $amount, $reason );

	if ( is_wp_error( $result ) ) {
		$this->log( 'Refund Failed: ' . $result->get_error_message(), 'error' );
		return new WP_Error( 'error', $result->get_error_message() );
	}

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

	switch ( strtolower( $result->ACK ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		case 'success':
		case 'successwithwarning':
			$order->add_order_note(
				/* translators: 1: Refund amount, 2: Refund ID */
				sprintf( __( 'Refunded %1$s - Refund ID: %2$s', 'woocommerce' ), $result->GROSSREFUNDAMT, $result->REFUNDTRANSACTIONID ) // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
			);
			return true;
	}

	return isset( $result->L_LONGMESSAGE0 ) ? new WP_Error( 'error', $result->L_LONGMESSAGE0 ) : false; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
}