mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 21:37:41 +08:00
feat(router): Pass customers address in retrieve customer (#2376)
This commit is contained in:
@ -28,6 +28,12 @@ where
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::Address, errors::StorageError>;
|
||||
|
||||
async fn find_address_by_address_id(
|
||||
&self,
|
||||
address_id: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::Address, errors::StorageError>;
|
||||
|
||||
async fn insert_address_for_payments(
|
||||
&self,
|
||||
payment_id: &str,
|
||||
@ -82,6 +88,25 @@ mod storage {
|
||||
};
|
||||
#[async_trait::async_trait]
|
||||
impl AddressInterface for Store {
|
||||
async fn find_address_by_address_id(
|
||||
&self,
|
||||
address_id: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::Address, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
storage_types::Address::find_by_address_id(&conn, address_id)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
.into_report()
|
||||
.async_and_then(|address| async {
|
||||
address
|
||||
.convert(key_store.key.get_inner())
|
||||
.await
|
||||
.change_context(errors::StorageError::DecryptionError)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn find_address_by_merchant_id_payment_id_address_id(
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
@ -237,6 +262,25 @@ mod storage {
|
||||
};
|
||||
#[async_trait::async_trait]
|
||||
impl AddressInterface for Store {
|
||||
async fn find_address_by_address_id(
|
||||
&self,
|
||||
address_id: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::Address, errors::StorageError> {
|
||||
let conn = connection::pg_connection_read(self).await?;
|
||||
storage_types::Address::find_by_address_id(&conn, address_id)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
.into_report()
|
||||
.async_and_then(|address| async {
|
||||
address
|
||||
.convert(key_store.key.get_inner())
|
||||
.await
|
||||
.change_context(errors::StorageError::DecryptionError)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn find_address_by_merchant_id_payment_id_address_id(
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
@ -447,6 +491,31 @@ mod storage {
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl AddressInterface for MockDb {
|
||||
async fn find_address_by_address_id(
|
||||
&self,
|
||||
address_id: &str,
|
||||
key_store: &domain::MerchantKeyStore,
|
||||
) -> CustomResult<domain::Address, errors::StorageError> {
|
||||
match self
|
||||
.addresses
|
||||
.lock()
|
||||
.await
|
||||
.iter()
|
||||
.find(|address| address.address_id == address_id)
|
||||
{
|
||||
Some(address) => address
|
||||
.clone()
|
||||
.convert(key_store.key.get_inner())
|
||||
.await
|
||||
.change_context(errors::StorageError::DecryptionError),
|
||||
None => {
|
||||
return Err(
|
||||
errors::StorageError::ValueNotFound("address not found".to_string()).into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn find_address_by_merchant_id_payment_id_address_id(
|
||||
&self,
|
||||
_merchant_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user