mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
db: Added Reverse lookup table (#147)
This commit is contained in:
@ -126,3 +126,18 @@ impl ConnectorErrorExt for error_stack::Report<errors::ConnectorError> {
|
||||
self.change_context(errors::ApiErrorResponse::PaymentAuthorizationFailed { data })
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait RedisErrorExt {
|
||||
fn to_redis_failed_response(self, key: &str) -> error_stack::Report<errors::StorageError>;
|
||||
}
|
||||
|
||||
impl RedisErrorExt for error_stack::Report<errors::RedisError> {
|
||||
fn to_redis_failed_response(self, key: &str) -> error_stack::Report<errors::StorageError> {
|
||||
match self.current_context() {
|
||||
errors::RedisError::NotFound => self.change_context(
|
||||
errors::StorageError::ValueNotFound(format!("Data does not exist for key {key}",)),
|
||||
),
|
||||
_ => self.change_context(errors::StorageError::KVError),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ where
|
||||
.make_pm_data(
|
||||
state,
|
||||
payment_data.payment_attempt.payment_method,
|
||||
&payment_data.payment_attempt.txn_id,
|
||||
&payment_data.payment_attempt.attempt_id,
|
||||
&payment_data.payment_attempt,
|
||||
&payment_data.payment_method_data,
|
||||
&payment_data.token,
|
||||
@ -594,7 +594,7 @@ pub async fn add_process_sync_task(
|
||||
force_sync: true,
|
||||
merchant_id: Some(payment_attempt.merchant_id.clone()),
|
||||
|
||||
resource_id: api::PaymentIdType::PaymentTxnId(payment_attempt.txn_id.clone()),
|
||||
resource_id: api::PaymentIdType::PaymentAttemptId(payment_attempt.attempt_id.clone()),
|
||||
param: None,
|
||||
connector: None,
|
||||
};
|
||||
@ -603,7 +603,7 @@ pub async fn add_process_sync_task(
|
||||
let process_tracker_id = pt_utils::get_process_tracker_id(
|
||||
runner,
|
||||
task,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
&payment_attempt.merchant_id,
|
||||
);
|
||||
let process_tracker_entry =
|
||||
|
||||
@ -323,7 +323,7 @@ pub fn create_startpay_url(
|
||||
server.base_url,
|
||||
payment_intent.payment_id,
|
||||
payment_intent.merchant_id,
|
||||
payment_attempt.txn_id
|
||||
payment_attempt.attempt_id
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsCancelRequest>
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_attempt.payment_id,
|
||||
&payment_attempt.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -89,7 +89,7 @@ impl<F: Send + Clone> GetTracker<F, payments::PaymentData<F>, api::PaymentsCaptu
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_attempt.payment_id,
|
||||
&payment_attempt.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -97,7 +97,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_attempt.payment_id,
|
||||
&payment_attempt.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -434,7 +434,7 @@ impl PaymentCreate {
|
||||
storage::PaymentAttemptNew {
|
||||
payment_id: payment_id.to_string(),
|
||||
merchant_id: merchant_id.to_string(),
|
||||
txn_id: Uuid::new_v4().to_string(),
|
||||
attempt_id: Uuid::new_v4().to_string(),
|
||||
status,
|
||||
amount: amount.into(),
|
||||
currency,
|
||||
@ -495,7 +495,7 @@ impl PaymentCreate {
|
||||
storage::ConnectorResponseNew {
|
||||
payment_id: payment_attempt.payment_id.clone(),
|
||||
merchant_id: payment_attempt.merchant_id.clone(),
|
||||
txn_id: payment_attempt.txn_id.clone(),
|
||||
txn_id: payment_attempt.attempt_id.clone(),
|
||||
created_at: payment_attempt.created_at,
|
||||
modified_at: payment_attempt.modified_at,
|
||||
connector_name: payment_attempt.connector.clone(),
|
||||
|
||||
@ -285,7 +285,7 @@ impl PaymentMethodValidate {
|
||||
storage::PaymentAttemptNew {
|
||||
payment_id: payment_id.to_string(),
|
||||
merchant_id: merchant_id.to_string(),
|
||||
txn_id: Uuid::new_v4().to_string(),
|
||||
attempt_id: Uuid::new_v4().to_string(),
|
||||
status,
|
||||
// Amount & Currency will be zero in this case
|
||||
amount: 0,
|
||||
|
||||
@ -106,7 +106,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsSessionRequest>
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_intent.payment_id,
|
||||
&payment_intent.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -103,7 +103,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsStartRequest> f
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_intent.payment_id,
|
||||
&payment_intent.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -215,8 +215,8 @@ async fn get_tracker_for_sync<
|
||||
api::PaymentIdType::ConnectorTransactionId(ref id) => {
|
||||
db.find_payment_attempt_by_merchant_id_connector_txn_id(merchant_id, id, storage_scheme)
|
||||
}
|
||||
api::PaymentIdType::PaymentTxnId(ref id) => {
|
||||
db.find_payment_attempt_by_merchant_id_txn_id(merchant_id, id, storage_scheme)
|
||||
api::PaymentIdType::PaymentAttemptId(ref id) => {
|
||||
db.find_payment_attempt_by_merchant_id_attempt_id(merchant_id, id, storage_scheme)
|
||||
}
|
||||
}
|
||||
.await
|
||||
@ -233,7 +233,7 @@ async fn get_tracker_for_sync<
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_intent.payment_id,
|
||||
&payment_intent.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -116,7 +116,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
||||
.find_connector_response_by_payment_id_merchant_id_txn_id(
|
||||
&payment_intent.payment_id,
|
||||
&payment_intent.merchant_id,
|
||||
&payment_attempt.txn_id,
|
||||
&payment_attempt.attempt_id,
|
||||
storage_scheme,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -490,6 +490,7 @@ fn mk_new_refund(
|
||||
refund_status: enums::RefundStatus::Pending,
|
||||
metadata: request.metadata,
|
||||
description: request.reason,
|
||||
attempt_id: payment_attempt.attempt_id.clone(),
|
||||
..storage::RefundNew::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,9 +51,11 @@ pub async fn construct_refund_router_data<'a, F>(
|
||||
.get_required_value("payment_method_type")?;
|
||||
let payment_method_data = match payment_method_data.cloned() {
|
||||
Some(v) => v,
|
||||
None => helpers::Vault::get_payment_method_data_from_locker(state, &payment_attempt.txn_id)
|
||||
.await?
|
||||
.get_required_value("payment_method_data")?,
|
||||
None => {
|
||||
helpers::Vault::get_payment_method_data_from_locker(state, &payment_attempt.attempt_id)
|
||||
.await?
|
||||
.get_required_value("payment_method_data")?
|
||||
}
|
||||
};
|
||||
|
||||
let router_data = types::RouterData {
|
||||
|
||||
Reference in New Issue
Block a user