WordPress at Your Fingertips
function is not described

WC_Gateway_Paypal::process_refund() public WC 1.0

Process a refund if supported.

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

No Hooks.

Return

true|false|WP_Error.

Usage

$WC_Gateway_Paypal = new WC_Gateway_Paypal();
$WC_Gateway_Paypal->process_refund( $order_id, $amount, $reason );
$order_id(int) (required)
Order ID.
$amount(float)
Refund amount.
Default: null
$reason(string)
Refund reason.
Default: ''

Code of WC_Gateway_Paypal::process_refund() WC 5.7.1

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
}