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 diesel_models::fraud_check::{self as storage, FraudCheck, FraudCheckUpdate};
use error_stack::report;
use router_env::instrument;
use super::MockDb;
use crate::{
connection,
core::errors::{self, CustomResult},
services::Store,
};
#[router_derive::track_async_interface]
#[async_trait::async_trait]
pub trait FraudCheckInterface {
async fn insert_fraud_check_response(
&self,
new: storage::FraudCheckNew,
) -> CustomResult<FraudCheck, errors::StorageError>;
async fn update_fraud_check_response_with_frm_id(
&self,
this: FraudCheck,
fraud_check: FraudCheckUpdate,
) -> CustomResult<FraudCheck, errors::StorageError>;
async fn find_fraud_check_by_frm_id(
&self,
frm_id: String,
) -> CustomResult<FraudCheck, errors::StorageError>;
}
#[async_trait::async_trait]
impl FraudCheckInterface for Store {
#[instrument(skip_all)]
async fn insert_fraud_check_response(
&self,
new: storage::FraudCheckNew,
) -> CustomResult<FraudCheck, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
new.insert(&conn)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
}
#[instrument(skip_all)]
async fn update_fraud_check_response_with_frm_id(
&self,
this: FraudCheck,
fraud_check: FraudCheckUpdate,
) -> CustomResult<FraudCheck, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
this.update_with_frm_id(&conn, fraud_check)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
}
#[instrument(skip_all)]
async fn find_fraud_check_by_frm_id(
&self,
frm_id: String,
) -> CustomResult<FraudCheck, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
FraudCheck::get_with_frm_id(&conn, frm_id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
}
}
#[async_trait::async_trait]
impl FraudCheckInterface for MockDb {
async fn insert_fraud_check_response(
&self,
_new: storage::FraudCheckNew,
) -> CustomResult<FraudCheck, errors::StorageError> {
Err(errors::StorageError::MockDbError)?
}
async fn update_fraud_check_response_with_frm_id(
&self,
_this: FraudCheck,
_fraud_check: FraudCheckUpdate,
) -> CustomResult<FraudCheck, errors::StorageError> {
Err(errors::StorageError::MockDbError)?
}
async fn find_fraud_check_by_frm_id(
&self,
_frm_id: String,
) -> CustomResult<FraudCheck, errors::StorageError> {
Err(errors::StorageError::MockDbError)?
}
}