refactor(storage): remove id from payment intent, attempt and remove datamodel ext from payment intent (#4923)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Prajjwal Kumar <prajjwal.kumar@juspay.in>
This commit is contained in:
Narayan Bhat
2024-06-19 17:10:32 +05:30
committed by GitHub
parent 2106a27f40
commit bec51a3557
71 changed files with 1319 additions and 935 deletions

View File

@ -197,12 +197,14 @@ pub async fn find_payment_intent_from_payment_id_type(
db: &dyn StorageInterface,
payment_id_type: payments::PaymentIdType,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse> {
match payment_id_type {
payments::PaymentIdType::PaymentIntentId(payment_id) => db
.find_payment_intent_by_payment_id_merchant_id(
&payment_id,
&merchant_account.merchant_id,
key_store,
merchant_account.storage_scheme,
)
.await
@ -219,6 +221,7 @@ pub async fn find_payment_intent_from_payment_id_type(
db.find_payment_intent_by_payment_id_merchant_id(
&attempt.payment_id,
&merchant_account.merchant_id,
key_store,
merchant_account.storage_scheme,
)
.await
@ -236,6 +239,7 @@ pub async fn find_payment_intent_from_payment_id_type(
db.find_payment_intent_by_payment_id_merchant_id(
&attempt.payment_id,
&merchant_account.merchant_id,
key_store,
merchant_account.storage_scheme,
)
.await
@ -251,6 +255,7 @@ pub async fn find_payment_intent_from_refund_id_type(
db: &dyn StorageInterface,
refund_id_type: webhooks::RefundIdType,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
connector_name: &str,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse> {
let refund = match refund_id_type {
@ -283,6 +288,7 @@ pub async fn find_payment_intent_from_refund_id_type(
db.find_payment_intent_by_payment_id_merchant_id(
&attempt.payment_id,
&merchant_account.merchant_id,
key_store,
merchant_account.storage_scheme,
)
.await
@ -293,6 +299,7 @@ pub async fn find_payment_intent_from_mandate_id_type(
db: &dyn StorageInterface,
mandate_id_type: webhooks::MandateIdType,
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
) -> CustomResult<PaymentIntent, errors::ApiErrorResponse> {
let mandate = match mandate_id_type {
webhooks::MandateIdType::MandateId(mandate_id) => db
@ -318,6 +325,7 @@ pub async fn find_payment_intent_from_mandate_id_type(
.ok_or(errors::ApiErrorResponse::InternalServerError)
.attach_printable("original_payment_id not present in mandate record")?,
&merchant_account.merchant_id,
key_store,
merchant_account.storage_scheme,
)
.await
@ -493,8 +501,13 @@ pub async fn get_mca_from_object_reference_id(
get_mca_from_payment_intent(
db,
merchant_account,
find_payment_intent_from_payment_id_type(db, payment_id_type, merchant_account)
.await?,
find_payment_intent_from_payment_id_type(
db,
payment_id_type,
merchant_account,
key_store,
)
.await?,
key_store,
connector_name,
)
@ -508,6 +521,7 @@ pub async fn get_mca_from_object_reference_id(
db,
refund_id_type,
merchant_account,
key_store,
connector_name,
)
.await?,
@ -520,8 +534,13 @@ pub async fn get_mca_from_object_reference_id(
get_mca_from_payment_intent(
db,
merchant_account,
find_payment_intent_from_mandate_id_type(db, mandate_id_type, merchant_account)
.await?,
find_payment_intent_from_mandate_id_type(
db,
mandate_id_type,
merchant_account,
key_store,
)
.await?,
key_store,
connector_name,
)