Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
use error_stack::report;
use hyperswitch_domain_models::callback_mapper as domain;
use router_env::instrument;
use storage_impl::{DataModelExt, MockDb};
use super::Store;
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
#[router_derive::track_async_interface]
#[async_trait::async_trait]
pub trait CallbackMapperInterface {
async fn insert_call_back_mapper(
&self,
call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError>;
async fn find_call_back_mapper_by_id(
&self,
id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError>;
}
#[async_trait::async_trait]
impl CallbackMapperInterface for Store {
#[instrument(skip_all)]
async fn insert_call_back_mapper(
&self,
call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
call_back_mapper
.to_storage_model()
.insert(&conn)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
.map(domain::CallbackMapper::from_storage_model)
}
#[instrument(skip_all)]
async fn find_call_back_mapper_by_id(
&self,
id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
let conn = connection::pg_connection_read(self).await?;
storage::CallbackMapper::find_by_id(&conn, id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
.map(domain::CallbackMapper::from_storage_model)
}
}
#[async_trait::async_trait]
impl CallbackMapperInterface for MockDb {
#[instrument(skip_all)]
async fn insert_call_back_mapper(
&self,
_call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
Err(errors::StorageError::MockDbError)?
}
#[instrument(skip_all)]
async fn find_call_back_mapper_by_id(
&self,
_id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
Err(errors::StorageError::MockDbError)?
}
}