refactor: incorporate hyperswitch_interface into router (#3669)

Co-authored-by: Narayan Bhat <narayan.bhat@juspay.in>
This commit is contained in:
Chethan Rao
2024-02-26 19:18:18 +05:30
committed by GitHub
parent c117f8ec63
commit 2185cd38c1
48 changed files with 671 additions and 1613 deletions

View File

@ -5,8 +5,6 @@ use api_models::{
payment_methods::{self, BankAccountAccessCreds},
payments::{AddressDetails, BankDebitBilling, BankDebitData, PaymentMethodData},
};
#[cfg(feature = "hashicorp-vault")]
use external_services::hashicorp_vault::{self, decrypt::VaultFetch};
use hex;
pub mod helpers;
pub mod transformers;
@ -19,8 +17,6 @@ use common_utils::{
};
use data_models::payments::PaymentIntent;
use error_stack::{IntoReport, ResultExt};
#[cfg(feature = "aws_kms")]
pub use external_services::aws_kms;
use helpers::PaymentAuthConnectorDataExt;
use masking::{ExposeInterface, PeekInterface};
use pm_auth::{
@ -347,34 +343,13 @@ async fn store_bank_details_in_payment_methods(
}
}
let pm_auth_key = async {
#[cfg(feature = "hashicorp-vault")]
let client =
external_services::hashicorp_vault::core::get_hashicorp_client(&state.conf.hc_vault)
.await
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed while creating client")?;
#[cfg(feature = "hashicorp-vault")]
let output = masking::Secret::new(state.conf.payment_method_auth.pm_auth_key.clone())
.fetch_inner::<hashicorp_vault::core::Kv2>(client)
.await
.change_context(ApiErrorResponse::InternalServerError)?
.expose();
#[cfg(not(feature = "hashicorp-vault"))]
let output = state.conf.payment_method_auth.pm_auth_key.clone();
Ok::<_, error_stack::Report<ApiErrorResponse>>(output)
}
.await?;
#[cfg(feature = "aws_kms")]
let pm_auth_key = aws_kms::core::get_aws_kms_client(&state.conf.kms)
.await
.decrypt(pm_auth_key)
.await
.change_context(ApiErrorResponse::InternalServerError)?;
let pm_auth_key = state
.conf
.payment_method_auth
.get_inner()
.pm_auth_key
.clone()
.expose();
let mut update_entries: Vec<(storage::PaymentMethod, storage::PaymentMethodUpdate)> =
Vec::new();