mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(core): Update shipping_cost and order_tax_amount to net_amount of payment_attempt (#5844)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -71,8 +71,12 @@ impl<T: DatabaseStore> ReverseLookupInterface for KVRouterStore<T> {
|
||||
new: DieselReverseLookupNew,
|
||||
storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<DieselReverseLookup, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselReverseLookup>(self, storage_scheme, Op::Insert).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselReverseLookup>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Insert,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
storage_enums::MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -126,8 +130,12 @@ impl<T: DatabaseStore> ReverseLookupInterface for KVRouterStore<T> {
|
||||
.get_lookup_by_lookup_id(id, storage_scheme)
|
||||
.await
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselReverseLookup>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselReverseLookup>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
storage_enums::MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
storage_enums::MerchantStorageScheme::RedisKv => {
|
||||
|
||||
@ -161,6 +161,8 @@ impl PaymentAttemptInterface for MockDb {
|
||||
customer_acceptance: payment_attempt.customer_acceptance,
|
||||
organization_id: payment_attempt.organization_id,
|
||||
profile_id: payment_attempt.profile_id,
|
||||
shipping_cost: payment_attempt.shipping_cost,
|
||||
order_tax_amount: payment_attempt.order_tax_amount,
|
||||
};
|
||||
payment_attempts.push(payment_attempt.clone());
|
||||
Ok(payment_attempt)
|
||||
|
||||
@ -338,9 +338,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
payment_attempt: PaymentAttemptNew,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Insert)
|
||||
.await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Insert,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -423,6 +426,8 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
customer_acceptance: payment_attempt.customer_acceptance.clone(),
|
||||
organization_id: payment_attempt.organization_id.clone(),
|
||||
profile_id: payment_attempt.profile_id.clone(),
|
||||
shipping_cost: payment_attempt.shipping_cost,
|
||||
order_tax_amount: payment_attempt.order_tax_amount,
|
||||
};
|
||||
|
||||
let field = format!("pa_{}", created_attempt.attempt_id);
|
||||
@ -487,11 +492,11 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
payment_id: &this.payment_id,
|
||||
};
|
||||
let field = format!("pa_{}", this.attempt_id);
|
||||
let storage_scheme = decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Update(key.clone(), &field, Some(&this.updated_by)),
|
||||
)
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
@ -606,8 +611,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -668,8 +677,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
storage_scheme,
|
||||
)
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
MerchantStorageScheme::RedisKv => {
|
||||
@ -722,8 +735,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
storage_scheme,
|
||||
)
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
MerchantStorageScheme::RedisKv => {
|
||||
@ -771,8 +788,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
connector_txn_id: &str,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -836,8 +857,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
attempt_id: &str,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -884,8 +909,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -945,8 +974,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -1009,8 +1042,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
payment_id: &common_utils::id_type::PaymentId,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Vec<PaymentAttempt>, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -1232,6 +1269,8 @@ impl DataModelExt for PaymentAttempt {
|
||||
customer_acceptance: self.customer_acceptance,
|
||||
organization_id: self.organization_id,
|
||||
profile_id: self.profile_id,
|
||||
shipping_cost: self.shipping_cost,
|
||||
order_tax_amount: self.order_tax_amount,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1301,6 +1340,8 @@ impl DataModelExt for PaymentAttempt {
|
||||
customer_acceptance: storage_model.customer_acceptance,
|
||||
organization_id: storage_model.organization_id,
|
||||
profile_id: storage_model.profile_id,
|
||||
shipping_cost: storage_model.shipping_cost,
|
||||
order_tax_amount: storage_model.order_tax_amount,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1386,6 +1427,8 @@ impl DataModelExt for PaymentAttempt {
|
||||
customer_acceptance: self.customer_acceptance,
|
||||
organization_id: self.organization_id,
|
||||
profile_id: self.profile_id,
|
||||
shipping_cost: self.shipping_cost,
|
||||
order_tax_amount: self.order_tax_amount,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1455,6 +1498,8 @@ impl DataModelExt for PaymentAttempt {
|
||||
customer_acceptance: storage_model.customer_acceptance,
|
||||
organization_id: storage_model.organization_id,
|
||||
profile_id: storage_model.profile_id,
|
||||
shipping_cost: storage_model.shipping_cost,
|
||||
order_tax_amount: storage_model.order_tax_amount,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1540,6 +1585,8 @@ impl DataModelExt for PaymentAttemptNew {
|
||||
customer_acceptance: self.customer_acceptance,
|
||||
organization_id: self.organization_id,
|
||||
profile_id: self.profile_id,
|
||||
shipping_cost: self.shipping_cost,
|
||||
order_tax_amount: self.order_tax_amount,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1608,6 +1655,8 @@ impl DataModelExt for PaymentAttemptNew {
|
||||
customer_acceptance: storage_model.customer_acceptance,
|
||||
organization_id: storage_model.organization_id,
|
||||
profile_id: storage_model.profile_id,
|
||||
shipping_cost: storage_model.shipping_cost,
|
||||
order_tax_amount: storage_model.order_tax_amount,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1733,6 +1782,8 @@ impl DataModelExt for PaymentAttemptUpdate {
|
||||
client_source,
|
||||
client_version,
|
||||
customer_acceptance,
|
||||
shipping_cost,
|
||||
order_tax_amount,
|
||||
} => DieselPaymentAttemptUpdate::ConfirmUpdate {
|
||||
amount: amount.get_amount_as_i64(),
|
||||
currency,
|
||||
@ -1766,6 +1817,8 @@ impl DataModelExt for PaymentAttemptUpdate {
|
||||
client_source,
|
||||
client_version,
|
||||
customer_acceptance,
|
||||
shipping_cost,
|
||||
order_tax_amount,
|
||||
},
|
||||
Self::VoidUpdate {
|
||||
status,
|
||||
@ -2072,6 +2125,8 @@ impl DataModelExt for PaymentAttemptUpdate {
|
||||
client_source,
|
||||
client_version,
|
||||
customer_acceptance,
|
||||
shipping_cost,
|
||||
order_tax_amount,
|
||||
} => Self::ConfirmUpdate {
|
||||
amount: MinorUnit::new(amount),
|
||||
currency,
|
||||
@ -2103,6 +2158,8 @@ impl DataModelExt for PaymentAttemptUpdate {
|
||||
client_source,
|
||||
client_version,
|
||||
customer_acceptance,
|
||||
shipping_cost,
|
||||
order_tax_amount,
|
||||
},
|
||||
DieselPaymentAttemptUpdate::VoidUpdate {
|
||||
status,
|
||||
|
||||
@ -79,8 +79,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
merchant_id: &merchant_id,
|
||||
payment_id: &payment_id,
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentIntent>(self, storage_scheme, Op::Insert).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentIntent>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Insert,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -154,11 +158,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
payment_id: &payment_id,
|
||||
};
|
||||
let field = format!("pi_{}", this.payment_id.get_string_repr());
|
||||
let storage_scheme = decide_storage_scheme::<_, DieselPaymentIntent>(
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentIntent>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Update(key.clone(), &field, Some(&this.updated_by)),
|
||||
)
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
@ -243,8 +247,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPaymentIntent>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPaymentIntent>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
let diesel_payment_intent = match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
|
||||
|
||||
@ -44,8 +44,12 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
|
||||
payouts: &Payouts,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayoutAttempt>(self, storage_scheme, Op::Insert).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayoutAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Insert,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
@ -144,11 +148,11 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
|
||||
payout_attempt_id: &this.payout_id,
|
||||
};
|
||||
let field = format!("poa_{}", this.payout_attempt_id);
|
||||
let storage_scheme = decide_storage_scheme::<_, DieselPayoutAttempt>(
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayoutAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Update(key.clone(), &field, None),
|
||||
)
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
@ -240,8 +244,12 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {
|
||||
payout_attempt_id: &str,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PayoutAttempt, errors::StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayoutAttempt>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayoutAttempt>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store
|
||||
|
||||
@ -82,8 +82,12 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
new: PayoutsNew,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<Payouts, StorageError> {
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Insert).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayouts>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Insert,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
self.router_store.insert_payout(new, storage_scheme).await
|
||||
@ -168,11 +172,11 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
payout_id: &this.payout_id,
|
||||
};
|
||||
let field = format!("po_{}", this.payout_id);
|
||||
let storage_scheme = decide_storage_scheme::<_, DieselPayouts>(
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayouts>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Update(key.clone(), &field, None),
|
||||
)
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
@ -235,8 +239,12 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayouts>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => database_call().await,
|
||||
MerchantStorageScheme::RedisKv => {
|
||||
@ -279,8 +287,12 @@ impl<T: DatabaseStore> PayoutsInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
};
|
||||
let storage_scheme =
|
||||
decide_storage_scheme::<_, DieselPayouts>(self, storage_scheme, Op::Find).await;
|
||||
let storage_scheme = Box::pin(decide_storage_scheme::<_, DieselPayouts>(
|
||||
self,
|
||||
storage_scheme,
|
||||
Op::Find,
|
||||
))
|
||||
.await;
|
||||
match storage_scheme {
|
||||
MerchantStorageScheme::PostgresOnly => {
|
||||
let maybe_payouts = database_call().await?;
|
||||
|
||||
Reference in New Issue
Block a user