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
#[cfg(feature = "v2")]
use diesel::associations::HasTable;
#[cfg(feature = "v2")]
use diesel::ExpressionMethods;
#[cfg(feature = "v2")]
use crate::{
errors, query::generics, schema_v2::tokenization, tokenization as tokenization_diesel,
DatabaseConnectionWithContext, StorageResult,
};
#[cfg(all(feature = "v2", feature = "tokenization_v2"))]
impl tokenization_diesel::Tokenization {
pub async fn insert(self, conn: &DatabaseConnectionWithContext<'_>) -> StorageResult<Self> {
generics::generic_insert(conn, self).await
}
pub async fn find_by_id(
conn: &DatabaseConnectionWithContext<'_>,
id: &common_utils::id_type::GlobalTokenId,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
tokenization::dsl::id.eq(id.to_owned()),
)
.await
}
pub async fn update_with_id(
self,
conn: &DatabaseConnectionWithContext<'_>,
tokenization_record: tokenization_diesel::TokenizationUpdateInternal,
) -> StorageResult<Self> {
match generics::generic_update_with_unique_predicate_get_result::<
<Self as HasTable>::Table,
_,
_,
_,
>(
conn,
tokenization::dsl::id.eq(self.id.to_owned()),
tokenization_record,
)
.await
{
Err(error) => match error.current_context() {
errors::DatabaseError::NoFieldsToUpdate => Ok(self),
_ => Err(error),
},
result => result,
}
}
}