WC_Gateway_Paypal_API_Handler::refund_transaction()
Refund an order via PayPal.
Метод класса: WC_Gateway_Paypal_API_Handler{}
Хуков нет.
Возвращает
Объект
. Either an object of name value pairs for a success, or a WP_ERROR object.
Использование
$result = WC_Gateway_Paypal_API_Handler::refund_transaction( $order, $amount, $reason );
- $order(WC_Order) (обязательный)
- Order object.
- $amount(float)
- Refund amount.
По умолчанию: null - $reason(строка)
- Refund reason.
По умолчанию: ''
Код WC_Gateway_Paypal_API_Handler::refund_transaction() WC Gateway Paypal API Handler::refund transaction WC 8.3.1
public static function refund_transaction( $order, $amount = null, $reason = '' ) { $raw_response = wp_safe_remote_post( self::$sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp', array( 'method' => 'POST', 'body' => self::get_refund_request( $order, $amount, $reason ), 'timeout' => 70, 'user-agent' => 'WooCommerce/' . WC()->version, 'httpversion' => '1.1', ) ); WC_Gateway_Paypal::log( 'Refund Response: ' . wc_print_r( $raw_response, true ) ); if ( is_wp_error( $raw_response ) ) { return $raw_response; } elseif ( empty( $raw_response['body'] ) ) { return new WP_Error( 'paypal-api', 'Empty Response' ); } parse_str( $raw_response['body'], $response ); return (object) $response; }