has_status( 'processing' ) ) { $this->session_handler->destroy_session_data(); return array( 'result' => 'success', 'redirect' => $this->get_return_url( $wc_order ), ); } //phpcs:enable WordPress.Security.NonceVerification.Recommended try { if ( $this->order_processor->process( $wc_order, $woocommerce ) ) { $this->session_handler->destroy_session_data(); return array( 'result' => 'success', 'redirect' => $this->get_return_url( $wc_order ), ); } } catch ( PayPalApiException $error ) { if ( $error->has_detail( 'INSTRUMENT_DECLINED' ) ) { $this->session_handler->increment_insufficient_funding_tries(); $host = $this->config->has( 'sandbox_on' ) && $this->config->get( 'sandbox_on' ) ? 'https://www.sandbox.paypal.com/' : 'https://www.paypal.com/'; $url = $host . 'checkoutnow?token=' . $this->session_handler->order()->id(); if ( $this->session_handler->insufficient_funding_tries() >= 3 ) { $this->session_handler->destroy_session_data(); wc_add_notice( __( 'Please use a different payment method.', 'woocommerce-paypal-payments' ), 'error' ); return null; } return array( 'result' => 'success', 'redirect' => $url, ); } $this->session_handler->destroy_session_data(); } catch ( RuntimeException $error ) { $this->session_handler->destroy_session_data(); wc_add_notice( $error->getMessage(), 'error' ); return null; } wc_add_notice( $this->order_processor->last_error(), 'error' ); return null; } /** * Checks if vault enabled setting for PayPal or credit card is enabled. * * @return bool Whether vault settings are enabled or not. * @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException When a setting hasn't been found. */ protected function vault_settings_enabled(): bool { if ( $this->config->has( 'vault_enabled' ) && $this->config->get( 'vault_enabled' ) ) { return true; } if ( $this->config->has( 'dcc_vault_enabled' ) && $this->config->get( 'dcc_vault_enabled' ) ) { return true; } return false; } }