mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
enhance(storage_models): delete client secret when status is succeeded, failed, cancelled (#724)
This commit is contained in:
@ -1126,7 +1126,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for CancelRequest {
|
||||
Some(c) => Some(
|
||||
CancellationReason::from_str(c)
|
||||
.into_report()
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?,
|
||||
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
|
||||
),
|
||||
None => None,
|
||||
};
|
||||
|
||||
@ -178,7 +178,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
status: Some(status),
|
||||
setup_future_usage,
|
||||
customer_id,
|
||||
client_secret: make_client_secret_null_if_success(Some(status)),
|
||||
client_secret: make_client_secret_null_based_on_status(status),
|
||||
shipping_address_id,
|
||||
billing_address_id,
|
||||
modified_at: Some(common_utils::date_time::now()),
|
||||
@ -199,7 +199,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
} => Self {
|
||||
return_url,
|
||||
status,
|
||||
client_secret: make_client_secret_null_if_success(status),
|
||||
client_secret: status.and_then(make_client_secret_null_based_on_status),
|
||||
customer_id,
|
||||
shipping_address_id,
|
||||
billing_address_id,
|
||||
@ -209,6 +209,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
PaymentIntentUpdate::PGStatusUpdate { status } => Self {
|
||||
status: Some(status),
|
||||
modified_at: Some(common_utils::date_time::now()),
|
||||
client_secret: make_client_secret_null_based_on_status(status),
|
||||
..Default::default()
|
||||
},
|
||||
PaymentIntentUpdate::MerchantStatusUpdate {
|
||||
@ -217,7 +218,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
billing_address_id,
|
||||
} => Self {
|
||||
status: Some(status),
|
||||
client_secret: make_client_secret_null_if_success(Some(status)),
|
||||
client_secret: make_client_secret_null_based_on_status(status),
|
||||
shipping_address_id,
|
||||
billing_address_id,
|
||||
modified_at: Some(common_utils::date_time::now()),
|
||||
@ -237,7 +238,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
amount_captured,
|
||||
// customer_id,
|
||||
return_url,
|
||||
client_secret: make_client_secret_null_if_success(Some(status)),
|
||||
client_secret: make_client_secret_null_based_on_status(status),
|
||||
modified_at: Some(common_utils::date_time::now()),
|
||||
..Default::default()
|
||||
},
|
||||
@ -245,12 +246,17 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_client_secret_null_if_success(
|
||||
status: Option<storage_enums::IntentStatus>,
|
||||
fn make_client_secret_null_based_on_status(
|
||||
status: storage_enums::IntentStatus,
|
||||
) -> Option<Option<String>> {
|
||||
if status == Some(storage_enums::IntentStatus::Succeeded) {
|
||||
Some(None)
|
||||
} else {
|
||||
None
|
||||
match status {
|
||||
storage_enums::IntentStatus::Succeeded
|
||||
| storage_enums::IntentStatus::Failed
|
||||
| storage_enums::IntentStatus::Cancelled => Some(None),
|
||||
storage_enums::IntentStatus::Processing
|
||||
| storage_enums::IntentStatus::RequiresCustomerAction
|
||||
| storage_enums::IntentStatus::RequiresPaymentMethod
|
||||
| storage_enums::IntentStatus::RequiresConfirmation
|
||||
| storage_enums::IntentStatus::RequiresCapture => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user