Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(payment): update version to V2 and set last_modified timestamps to current time (#12499)

Gaurav Rawat5a9d62f6c41c
diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rs
index 5c0f2f61b8..db78dade1f 100644
--- a/crates/diesel_models/src/payment_method.rs
+++ b/crates/diesel_models/src/payment_method.rs
@@ -1632,7 +1632,7 @@ impl CommonMandateReference {
}
#[cfg(feature = "v1")]
- fn parse_payments_reference_with_token_fallback(
+ pub fn parse_payments_reference_with_token_fallback(
payments_json: serde_json::Value,
) -> CustomResult<PaymentsMandateReference, ParsingError> {
match serde_json::from_value::<PaymentsMandateReference>(payments_json.clone()) {
diff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rs
index 6ef537f673..cf5f1a1564 100644
--- a/crates/hyperswitch_domain_models/src/payment_methods.rs
+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs
@@ -218,10 +218,10 @@ impl PaymentMethod {
.as_object_mut()
.map(|obj| obj.remove("payouts"));
- serde_json::from_value::<mandates::PaymentsMandateReference>(mandate_details)
- .inspect_err(|err| {
- router_env::logger::error!("Failed to parse payments data: {:?}", err);
- })
+ diesel_models::CommonMandateReference::parse_payments_reference_with_token_fallback(
+ mandate_details,
+ )
+ .map(mandates::PaymentsMandateReference::from)
})
.transpose()
.map_err(|err| {
diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rs
index bebc861b77..fd82140c57 100644
--- a/crates/router/src/core/payment_methods/transformers.rs
+++ b/crates/router/src/core/payment_methods/transformers.rs
@@ -1466,6 +1466,8 @@ impl DomainPaymentMethodWrapper {
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to serialize connector mandate details")?;
+ let current_time = common_utils::date_time::now();
+
Ok(Self(domain::PaymentMethod {
customer_id: response.customer_id.clone(),
merchant_id: response.merchant_id.clone(),
@@ -1483,9 +1485,7 @@ impl DomainPaymentMethodWrapper {
created_at: response
.created
.unwrap_or_else(common_utils::date_time::now),
- last_modified: response
- .last_used_at
- .unwrap_or_else(common_utils::date_time::now),
+ last_modified: current_time,
payment_method: Some(response.payment_method),
payment_method_type: response.payment_method_type,
payment_method_issuer: None,
@@ -1504,7 +1504,7 @@ impl DomainPaymentMethodWrapper {
client_secret: None,
payment_method_billing_address: encrypted_payment_method_billing_address,
updated_by: None,
- version: common_enums::ApiVersion::V1, //to be updated later
+ version: common_enums::ApiVersion::V2, //to be updated later
network_token_requestor_reference_id: None, //to be added later
network_token_locker_id: None,
network_token_payment_method_data: None,
@@ -1519,7 +1519,7 @@ impl DomainPaymentMethodWrapper {
locker_fingerprint_id: None,
network_tokenization_data: None,
storage_type: response.storage_type,
- compatibility_updated_at: None,
+ compatibility_updated_at: Some(current_time),
}))
}
@@ -1589,6 +1589,8 @@ impl DomainPaymentMethodWrapper {
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to serialize connector mandate details")?;
+ let current_time = common_utils::date_time::now();
+
Ok(Self(domain::PaymentMethod {
customer_id: response.customer_id.clone(),
merchant_id: response.merchant_id.clone(),
@@ -1606,9 +1608,7 @@ impl DomainPaymentMethodWrapper {
created_at: response
.created
.unwrap_or_else(common_utils::date_time::now),
- last_modified: response
- .last_used_at
- .unwrap_or_else(common_utils::date_time::now),
+ last_modified: current_time,
payment_method: response.payment_method,
payment_method_type: response.payment_method_type,
payment_method_issuer: None,
@@ -1627,7 +1627,7 @@ impl DomainPaymentMethodWrapper {
client_secret: None,
payment_method_billing_address: encrypted_payment_method_billing_address,
updated_by: None,
- version: common_enums::ApiVersion::V1, //to be updated later
+ version: common_enums::ApiVersion::V2, //to be updated later
network_token_requestor_reference_id: None, //to be added later
network_token_locker_id: None,
network_token_payment_method_data: None,
@@ -1642,7 +1642,7 @@ impl DomainPaymentMethodWrapper {
locker_fingerprint_id: None,
network_tokenization_data: None,
storage_type: response.storage_type,
- compatibility_updated_at: None,
+ compatibility_updated_at: Some(current_time),
}))
}
}
@@ -1774,6 +1774,8 @@ impl
impl TryFrom<CreatePaymentMethodResponse> for DomainPaymentMethodWrapper {
type Error = error_stack::Report<errors::ApiErrorResponse>;
fn try_from(response: CreatePaymentMethodResponse) -> Result<Self, Self::Error> {
+ let current_time = common_utils::date_time::now();
+
Ok(Self(domain::PaymentMethod {
customer_id: response.customer_id,
merchant_id: response.merchant_id,
@@ -1791,9 +1793,7 @@ impl TryFrom<CreatePaymentMethodResponse> for DomainPaymentMethodWrapper {
created_at: response
.created
.unwrap_or_else(common_utils::date_time::now),
- last_modified: response
- .last_used_at
- .unwrap_or_else(common_utils::date_time::now),
+ last_modified: current_time,
payment_method: response.payment_method,
payment_method_type: response.payment_method_type,
payment_method_issuer: None,
@@ -1812,7 +1812,7 @@ impl TryFrom<CreatePaymentMethodResponse> for DomainPaymentMethodWrapper {
client_secret: None,
payment_method_billing_address: None, //Should be sent from PM service
updated_by: None,
- version: common_enums::ApiVersion::V1,
+ version: common_enums::ApiVersion::V2,
network_token_requestor_reference_id: None, //to be added later
network_token_locker_id: None,
network_token_payment_method_data: None,
@@ -1823,7 +1823,7 @@ impl TryFrom<CreatePaymentMethodResponse> for DomainPaymentMethodWrapper {
locker_fingerprint_id: None,
network_tokenization_data: None,
storage_type: response.storage_type,
- compatibility_updated_at: None,
+ compatibility_updated_at: Some(current_time),
}))
}
}