mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat(payments_v2): payment intent diesel and domain models changes v2 (#5783)
Co-authored-by: hrithikesh026 <hrithikesh.vm@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -73,8 +73,8 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentIntent, StorageError> {
|
||||
let merchant_id = payment_intent.merchant_id.clone();
|
||||
let payment_id = payment_intent.payment_id.clone();
|
||||
let field = payment_intent.payment_id.get_hash_key_for_kv_store();
|
||||
let payment_id = payment_intent.get_id().to_owned();
|
||||
let field = payment_intent.get_id().get_hash_key_for_kv_store();
|
||||
let key = PartitionKey::MerchantIdPaymentId {
|
||||
merchant_id: &merchant_id,
|
||||
payment_id: &payment_id,
|
||||
@ -152,12 +152,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentIntent, StorageError> {
|
||||
let merchant_id = this.merchant_id.clone();
|
||||
let payment_id = this.payment_id.clone();
|
||||
let payment_id = this.get_id().to_owned();
|
||||
let key = PartitionKey::MerchantIdPaymentId {
|
||||
merchant_id: &merchant_id,
|
||||
payment_id: &payment_id,
|
||||
};
|
||||
let field = format!("pi_{}", this.payment_id.get_string_repr());
|
||||
let field = format!("pi_{}", this.get_id().get_string_repr());
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentIntent>(
|
||||
self,
|
||||
storage_scheme,
|
||||
@ -229,6 +229,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
|
||||
#[instrument(skip_all)]
|
||||
async fn find_payment_intent_by_payment_id_merchant_id(
|
||||
&self,
|
||||
@ -288,6 +289,35 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
.change_context(StorageError::DecryptionError)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_v2"))]
|
||||
#[instrument(skip_all)]
|
||||
async fn find_payment_intent_by_id(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
id: &common_utils::id_type::PaymentId,
|
||||
merchant_key_store: &MerchantKeyStore,
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentIntent, StorageError> {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id)
|
||||
.await
|
||||
.map_err(|er| {
|
||||
let new_err = diesel_error_to_data_error(er.current_context());
|
||||
er.change_context(new_err)
|
||||
})?;
|
||||
|
||||
let merchant_id = diesel_payment_intent.merchant_id.clone();
|
||||
|
||||
PaymentIntent::convert_back(
|
||||
state,
|
||||
diesel_payment_intent,
|
||||
merchant_key_store.key.get_inner(),
|
||||
merchant_id.to_owned().into(),
|
||||
)
|
||||
.await
|
||||
.change_context(StorageError::DecryptionError)
|
||||
}
|
||||
|
||||
async fn get_active_payment_attempt(
|
||||
&self,
|
||||
payment: &mut PaymentIntent,
|
||||
@ -315,7 +345,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
async fn filter_payment_intent_by_constraints(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
@ -335,7 +369,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
async fn filter_payment_intents_by_time_range_constraints(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
@ -354,7 +392,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
)
|
||||
.await
|
||||
}
|
||||
#[cfg(feature = "olap")]
|
||||
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
async fn get_intent_status_with_count(
|
||||
&self,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
@ -366,7 +409,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
async fn get_filtered_payment_intents_attempt(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
@ -386,7 +433,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
async fn get_filtered_active_attempt_ids_for_total_count(
|
||||
&self,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
@ -468,6 +519,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.change_context(StorageError::DecryptionError)
|
||||
}
|
||||
|
||||
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
|
||||
#[instrument(skip_all)]
|
||||
async fn find_payment_intent_by_payment_id_merchant_id(
|
||||
&self,
|
||||
@ -498,6 +550,35 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "v2", feature = "payment_v2"))]
|
||||
#[instrument(skip_all)]
|
||||
async fn find_payment_intent_by_id(
|
||||
&self,
|
||||
state: &KeyManagerState,
|
||||
id: &common_utils::id_type::PaymentId,
|
||||
merchant_key_store: &MerchantKeyStore,
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentIntent, StorageError> {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
let diesel_payment_intent = DieselPaymentIntent::find_by_global_id(&conn, id)
|
||||
.await
|
||||
.map_err(|er| {
|
||||
let new_err = diesel_error_to_data_error(er.current_context());
|
||||
er.change_context(new_err)
|
||||
})?;
|
||||
|
||||
let merchant_id = diesel_payment_intent.merchant_id.clone();
|
||||
|
||||
PaymentIntent::convert_back(
|
||||
state,
|
||||
diesel_payment_intent,
|
||||
merchant_key_store.key.get_inner(),
|
||||
merchant_id.to_owned().into(),
|
||||
)
|
||||
.await
|
||||
.change_context(StorageError::DecryptionError)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
async fn get_active_payment_attempt(
|
||||
&self,
|
||||
@ -526,7 +607,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
async fn filter_payment_intent_by_constraints(
|
||||
&self,
|
||||
@ -652,7 +737,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
async fn filter_payment_intents_by_time_range_constraints(
|
||||
&self,
|
||||
@ -674,7 +763,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
async fn get_intent_status_with_count(
|
||||
&self,
|
||||
@ -718,7 +811,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
async fn get_filtered_payment_intents_attempt(
|
||||
&self,
|
||||
@ -911,7 +1008,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
#[cfg(all(
|
||||
any(feature = "v1", feature = "v2"),
|
||||
not(feature = "payment_v2"),
|
||||
feature = "olap"
|
||||
))]
|
||||
#[instrument(skip_all)]
|
||||
async fn get_filtered_active_attempt_ids_for_total_count(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user