WC_Gateway_Paypal_API_Handler::do_capture()public staticWC 1.0

Capture an authorization.

Метод класса: 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::do_capture( $order, $amount );
$order(WC_Order) (обязательный)
Order object.
$amount(float)
Amount.
По умолчанию: null

Код WC_Gateway_Paypal_API_Handler::do_capture() WC 8.7.0

public static function do_capture( $order, $amount = null ) {
	$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_capture_request( $order, $amount ),
			'timeout'     => 70,
			'user-agent'  => 'WooCommerce/' . WC()->version,
			'httpversion' => '1.1',
		)
	);

	WC_Gateway_Paypal::log( 'DoCapture 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;
}