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

fix(payment_methods): payment method type not being stored in payment method (#7411)

Narayan Bhat833da1c3c5a0
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index efc987ec3d..f9a6f9a9eb 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -920,7 +920,7 @@ pub async fn create_payment_method_core(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Unable to generate GlobalPaymentMethodId")?;
- let mut payment_method = create_payment_method_for_intent(
+ let payment_method = create_payment_method_for_intent(
state,
req.metadata.clone(),
&customer_id,
@@ -970,9 +970,6 @@ pub async fn create_payment_method_core(
let (response, payment_method) = match vaulting_result {
Ok((vaulting_resp, fingerprint_id)) => {
- payment_method.set_payment_method_type(req.payment_method_type);
- payment_method.set_payment_method_subtype(req.payment_method_subtype);
-
let pm_update = create_pm_additional_data_update(
Some(&payment_method_data),
state,
@@ -982,6 +979,8 @@ pub async fn create_payment_method_core(
&payment_method,
None,
network_tokenization_resp,
+ Some(req.payment_method_type),
+ Some(req.payment_method_subtype),
)
.await
.attach_printable("Unable to create Payment method data")?;
@@ -1552,6 +1551,8 @@ pub async fn create_pm_additional_data_update(
payment_method: &domain::PaymentMethod,
connector_token_details: Option<payment_methods::ConnectorTokenDetails>,
nt_data: Option<NetworkTokenPaymentMethodDetails>,
+ payment_method_type: Option<common_enums::PaymentMethod>,
+ payment_method_subtype: Option<common_enums::PaymentMethodType>,
) -> RouterResult<storage::PaymentMethodUpdate> {
let encrypted_payment_method_data = payment_method_vaulting_data
.map(
@@ -1591,9 +1592,8 @@ pub async fn create_pm_additional_data_update(
let pm_update = storage::PaymentMethodUpdate::GenericUpdate {
status: Some(enums::PaymentMethodStatus::Active),
locker_id: vault_id,
- // Payment method type remains the same, only card details are updated
- payment_method_type_v2: None,
- payment_method_subtype: None,
+ payment_method_type_v2: payment_method_type,
+ payment_method_subtype,
payment_method_data: encrypted_payment_method_data,
network_token_requestor_reference_id: nt_data
.clone()
@@ -1903,6 +1903,8 @@ pub async fn update_payment_method_core(
&payment_method,
request.connector_token_details,
None,
+ None,
+ None,
)
.await
.attach_printable("Unable to create Payment method data")?;