chromium/components/autofill/core/browser/payments/payments_network_interface.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/payments/payments_network_interface.h"

#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/data_model/autofill_data_model.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/payments/credit_card_save_metrics.h"
#include "components/autofill/core/browser/payments/account_info_getter.h"
#include "components/autofill/core/browser/payments/client_behavior_constants.h"
#include "components/autofill/core/browser/payments/payments_requests/get_card_upload_details_request.h"
#include "components/autofill/core/browser/payments/payments_requests/get_details_for_enrollment_request.h"
#include "components/autofill/core/browser/payments/payments_requests/get_iban_upload_details_request.h"
#include "components/autofill/core/browser/payments/payments_requests/get_unmask_details_request.h"
#include "components/autofill/core/browser/payments/payments_requests/opt_change_request.h"
#include "components/autofill/core/browser/payments/payments_requests/payments_request.h"
#include "components/autofill/core/browser/payments/payments_requests/select_challenge_option_request.h"
#include "components/autofill/core/browser/payments/payments_requests/unmask_card_request.h"
#include "components/autofill/core/browser/payments/payments_requests/unmask_iban_request.h"
#include "components/autofill/core/browser/payments/payments_requests/update_virtual_card_enrollment_request.h"
#include "components/autofill/core/browser/payments/payments_requests/upload_card_request.h"
#include "components/autofill/core/browser/payments/payments_requests/upload_iban_request.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "components/autofill/core/browser/payments/local_card_migration_manager.h"
#include "components/autofill/core/browser/payments/payments_requests/migrate_cards_request.h"
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

namespace autofill::payments {
namespace {

PaymentsRpcResult;

}  // namespace

PaymentsNetworkInterface::UnmaskDetails::UnmaskDetails() = default;

PaymentsNetworkInterface::UnmaskDetails::UnmaskDetails(const UnmaskDetails& other) {}

PaymentsNetworkInterface::UnmaskDetails::UnmaskDetails(UnmaskDetails&&) = default;

PaymentsNetworkInterface::UnmaskDetails& PaymentsNetworkInterface::UnmaskDetails::operator=(
    const PaymentsNetworkInterface::UnmaskDetails& other) {}

PaymentsNetworkInterface::UnmaskDetails& PaymentsNetworkInterface::UnmaskDetails::operator=(
    UnmaskDetails&&) = default;

PaymentsNetworkInterface::UnmaskDetails::~UnmaskDetails() = default;

PaymentsNetworkInterface::UnmaskRequestDetails::UnmaskRequestDetails() = default;

PaymentsNetworkInterface::UnmaskRequestDetails::UnmaskRequestDetails(
    const UnmaskRequestDetails& other) {}

PaymentsNetworkInterface::UnmaskRequestDetails::UnmaskRequestDetails(
    UnmaskRequestDetails&&) = default;

PaymentsNetworkInterface::UnmaskRequestDetails&
PaymentsNetworkInterface::UnmaskRequestDetails::operator=(
    const PaymentsNetworkInterface::UnmaskRequestDetails& other) {}

PaymentsNetworkInterface::UnmaskRequestDetails&
PaymentsNetworkInterface::UnmaskRequestDetails::operator=(
    UnmaskRequestDetails&&) = default;

PaymentsNetworkInterface::UnmaskRequestDetails::~UnmaskRequestDetails() = default;

PaymentsNetworkInterface::UnmaskResponseDetails::UnmaskResponseDetails() = default;

PaymentsNetworkInterface::UnmaskResponseDetails::UnmaskResponseDetails(
    const UnmaskResponseDetails& other) {}

PaymentsNetworkInterface::UnmaskResponseDetails::UnmaskResponseDetails(
    UnmaskResponseDetails&&) = default;

PaymentsNetworkInterface::UnmaskResponseDetails&
PaymentsNetworkInterface::UnmaskResponseDetails::operator=(
    const UnmaskResponseDetails& other) {}

PaymentsNetworkInterface::UnmaskResponseDetails&
PaymentsNetworkInterface::UnmaskResponseDetails::operator=(UnmaskResponseDetails&&) =
    default;

PaymentsNetworkInterface::UnmaskResponseDetails::~UnmaskResponseDetails() = default;

PaymentsNetworkInterface::UnmaskIbanRequestDetails::UnmaskIbanRequestDetails() = default;
PaymentsNetworkInterface::UnmaskIbanRequestDetails::UnmaskIbanRequestDetails(
    const UnmaskIbanRequestDetails& other) = default;
PaymentsNetworkInterface::UnmaskIbanRequestDetails::~UnmaskIbanRequestDetails() = default;

PaymentsNetworkInterface::OptChangeRequestDetails::OptChangeRequestDetails() = default;
PaymentsNetworkInterface::OptChangeRequestDetails::OptChangeRequestDetails(
    const OptChangeRequestDetails& other) {}
PaymentsNetworkInterface::OptChangeRequestDetails::~OptChangeRequestDetails() = default;

PaymentsNetworkInterface::OptChangeResponseDetails::OptChangeResponseDetails() = default;
PaymentsNetworkInterface::OptChangeResponseDetails::OptChangeResponseDetails(
    const OptChangeResponseDetails& other) {}
PaymentsNetworkInterface::OptChangeResponseDetails::~OptChangeResponseDetails() = default;

PaymentsNetworkInterface::UploadCardRequestDetails::UploadCardRequestDetails() =
    default;
PaymentsNetworkInterface::UploadCardRequestDetails::UploadCardRequestDetails(
    const UploadCardRequestDetails& other) = default;
PaymentsNetworkInterface::UploadCardRequestDetails::
    ~UploadCardRequestDetails() = default;

PaymentsNetworkInterface::UploadIbanRequestDetails::UploadIbanRequestDetails() = default;
PaymentsNetworkInterface::UploadIbanRequestDetails::UploadIbanRequestDetails(
    const UploadIbanRequestDetails& other) = default;
PaymentsNetworkInterface::UploadIbanRequestDetails::~UploadIbanRequestDetails() = default;

PaymentsNetworkInterface::MigrationRequestDetails::MigrationRequestDetails() = default;
PaymentsNetworkInterface::MigrationRequestDetails::MigrationRequestDetails(
    const MigrationRequestDetails& other) = default;
PaymentsNetworkInterface::MigrationRequestDetails::~MigrationRequestDetails() = default;

PaymentsNetworkInterface::SelectChallengeOptionRequestDetails::
    SelectChallengeOptionRequestDetails() = default;
PaymentsNetworkInterface::SelectChallengeOptionRequestDetails::
    SelectChallengeOptionRequestDetails(
        const SelectChallengeOptionRequestDetails& other) = default;
PaymentsNetworkInterface::SelectChallengeOptionRequestDetails::
    ~SelectChallengeOptionRequestDetails() = default;

PaymentsNetworkInterface::GetDetailsForEnrollmentRequestDetails::
    GetDetailsForEnrollmentRequestDetails() = default;
PaymentsNetworkInterface::GetDetailsForEnrollmentRequestDetails::
    GetDetailsForEnrollmentRequestDetails(
        const GetDetailsForEnrollmentRequestDetails& other) = default;
PaymentsNetworkInterface::GetDetailsForEnrollmentRequestDetails::
    ~GetDetailsForEnrollmentRequestDetails() = default;

PaymentsNetworkInterface::GetDetailsForEnrollmentResponseDetails::
    GetDetailsForEnrollmentResponseDetails() = default;
PaymentsNetworkInterface::GetDetailsForEnrollmentResponseDetails::
    GetDetailsForEnrollmentResponseDetails(
        const GetDetailsForEnrollmentResponseDetails& other) = default;
PaymentsNetworkInterface::GetDetailsForEnrollmentResponseDetails::
    ~GetDetailsForEnrollmentResponseDetails() = default;

PaymentsNetworkInterface::UploadCardResponseDetails::UploadCardResponseDetails() =
    default;
PaymentsNetworkInterface::UploadCardResponseDetails::UploadCardResponseDetails(
    const UploadCardResponseDetails&) = default;
PaymentsNetworkInterface::UploadCardResponseDetails::UploadCardResponseDetails(
    UploadCardResponseDetails&&) = default;
PaymentsNetworkInterface::UploadCardResponseDetails&
PaymentsNetworkInterface::UploadCardResponseDetails::operator=(
    const UploadCardResponseDetails&) = default;
PaymentsNetworkInterface::UploadCardResponseDetails&
PaymentsNetworkInterface::UploadCardResponseDetails::operator=(
    UploadCardResponseDetails&&) = default;
PaymentsNetworkInterface::UploadCardResponseDetails::~UploadCardResponseDetails() =
    default;

PaymentsNetworkInterface::UpdateVirtualCardEnrollmentRequestDetails::
    UpdateVirtualCardEnrollmentRequestDetails() = default;
PaymentsNetworkInterface::UpdateVirtualCardEnrollmentRequestDetails::
    UpdateVirtualCardEnrollmentRequestDetails(
        const UpdateVirtualCardEnrollmentRequestDetails&) = default;
PaymentsNetworkInterface::UpdateVirtualCardEnrollmentRequestDetails&
PaymentsNetworkInterface::UpdateVirtualCardEnrollmentRequestDetails::operator=(
    const UpdateVirtualCardEnrollmentRequestDetails&) = default;
PaymentsNetworkInterface::UpdateVirtualCardEnrollmentRequestDetails::
    ~UpdateVirtualCardEnrollmentRequestDetails() = default;

PaymentsNetworkInterface::PaymentsNetworkInterface(
    scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
    signin::IdentityManager* identity_manager,
    AccountInfoGetter* account_info_getter,
    bool is_off_the_record)
    :{}

PaymentsNetworkInterface::~PaymentsNetworkInterface() = default;

void PaymentsNetworkInterface::Prepare() {}

void PaymentsNetworkInterface::GetUnmaskDetails(
    base::OnceCallback<void(PaymentsRpcResult,
                            PaymentsNetworkInterface::UnmaskDetails&)> callback,
    const std::string& app_locale) {}

void PaymentsNetworkInterface::UnmaskCard(
    const PaymentsNetworkInterface::UnmaskRequestDetails& request_details,
    base::OnceCallback<void(
        PaymentsRpcResult,
        const PaymentsNetworkInterface::UnmaskResponseDetails&)> callback) {}

void PaymentsNetworkInterface::UnmaskIban(
    const UnmaskIbanRequestDetails& request_details,
    base::OnceCallback<void(PaymentsRpcResult, const std::u16string&)>
        callback) {}

void PaymentsNetworkInterface::OptChange(
    const OptChangeRequestDetails request_details,
    base::OnceCallback<
        void(PaymentsRpcResult,
             PaymentsNetworkInterface::OptChangeResponseDetails&)> callback) {}

void PaymentsNetworkInterface::GetCardUploadDetails(
    const std::vector<AutofillProfile>& addresses,
    const int detected_values,
    const std::vector<ClientBehaviorConstants>& client_behavior_signals,
    const std::string& app_locale,
    GetCardUploadDetailsCallback callback,
    const int billable_service_number,
    const int64_t billing_customer_number,
    UploadCardSource upload_card_source) {}

void PaymentsNetworkInterface::UploadCard(
    const PaymentsNetworkInterface::UploadCardRequestDetails& request_details,
    base::OnceCallback<void(PaymentsRpcResult,
                            const UploadCardResponseDetails&)> callback) {}

void PaymentsNetworkInterface::GetIbanUploadDetails(
    const std::string& app_locale,
    int64_t billing_customer_number,
    int billable_service_number,
    const std::string& country_code,
    base::OnceCallback<void(PaymentsRpcResult,
                            const std::u16string& validation_regex,
                            const std::u16string& context_token,
                            std::unique_ptr<base::Value::Dict>)> callback) {}

void PaymentsNetworkInterface::UploadIban(
    const UploadIbanRequestDetails& details,
    base::OnceCallback<void(PaymentsRpcResult)> callback) {}

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
void PaymentsNetworkInterface::MigrateCards(
    const MigrationRequestDetails& request_details,
    const std::vector<MigratableCreditCard>& migratable_credit_cards,
    MigrateCardsCallback callback) {}
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)

void PaymentsNetworkInterface::SelectChallengeOption(
    const SelectChallengeOptionRequestDetails& request_details,
    base::OnceCallback<void(PaymentsRpcResult, const std::string&)> callback) {}

void PaymentsNetworkInterface::GetVirtualCardEnrollmentDetails(
    const GetDetailsForEnrollmentRequestDetails& request_details,
    base::OnceCallback<void(PaymentsRpcResult,
                            const PaymentsNetworkInterface::
                                GetDetailsForEnrollmentResponseDetails&)>
        callback) {}

void PaymentsNetworkInterface::UpdateVirtualCardEnrollment(
    const UpdateVirtualCardEnrollmentRequestDetails& request_details,
    base::OnceCallback<void(PaymentsRpcResult)> callback) {}

}  // namespace autofill::payments