WC_Gateway_Paypal_API_Handler::do_capture( WC_Order $order, float $amount = null )
Capture an authorization.
Description Description
Parameters Parameters
- $order
-
(Required) Order object.
- $amount
-
(Optional) Amount.
Default value: null
Return Return
(object) Either an object of name value pairs for a success, or a WP_ERROR object.
Source Source
File: includes/gateways/paypal/includes/class-wc-gateway-paypal-api-handler.php
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 ( empty( $raw_response['body'] ) ) { return new WP_Error( 'paypal-api', 'Empty Response' ); } elseif ( is_wp_error( $raw_response ) ) { return $raw_response; } parse_str( $raw_response['body'], $response ); return (object) $response; }