get_meta( PayPalGateway::INTENT_META_KEY ) ); if ( $intent !== 'AUTHORIZE' ) { throw new InvalidArgumentException( 'Only orders with "authorize" intent can be captured.' ); } $captured = wc_string_to_bool( $wc_order->get_meta( AuthorizedPaymentsProcessor::CAPTURED_META_KEY ) ); if ( $captured ) { throw new InvalidArgumentException( 'The order is already captured.' ); } $authorized_payment_processor = PPCP::container()->get( 'wcgateway.processor.authorized-payments' ); assert( $authorized_payment_processor instanceof AuthorizedPaymentsProcessor ); if ( ! $authorized_payment_processor->capture_authorized_payment( $wc_order ) ) { throw new RuntimeException( 'Capture failed.' ); } }