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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(migration): perform card validation only for allowed payment methods (#9131)
Kashif04578801b622
diff --git a/crates/payment_methods/src/core/migration/payment_methods.rs b/crates/payment_methods/src/core/migration/payment_methods.rsindex 5c30698f61..494e1987e2 100644--- a/crates/payment_methods/src/core/migration/payment_methods.rs+++ b/crates/payment_methods/src/core/migration/payment_methods.rs@@ -51,8 +51,12 @@ pub async fn migrate_payment_method(let card_number_validation_result =cards::CardNumber::from_str(card_details.card_number.peek());- let card_bin_details =- populate_bin_details_for_masked_card(card_details, &*state.store).await?;+ let card_bin_details = populate_bin_details_for_masked_card(+ card_details,+ &*state.store,+ req.payment_method_type.as_ref(),+ )+ .await?;req.card = Some(api_models::payment_methods::MigrateCardDetail {card_issuing_country: card_bin_details.issuer_country.clone(),@@ -176,8 +180,23 @@ pub async fn migrate_payment_method(pub async fn populate_bin_details_for_masked_card(card_details: &api_models::payment_methods::MigrateCardDetail,db: &dyn state::PaymentMethodsStorageInterface,+ payment_method_type: Option<&enums::PaymentMethodType>,) -> CustomResult<pm_api::CardDetailFromLocker, errors::ApiErrorResponse> {- migration::validate_card_expiry(&card_details.card_exp_month, &card_details.card_exp_year)?;+ if let Some(+ // Cards+ enums::PaymentMethodType::Credit+ | enums::PaymentMethodType::Debit++ // Wallets+ | enums::PaymentMethodType::ApplePay+ | enums::PaymentMethodType::GooglePay,+ ) = payment_method_type {+ migration::validate_card_expiry(+ &card_details.card_exp_month,+ &card_details.card_exp_year,+ )?;+ }+let card_number = card_details.card_number.clone();let (card_isin, _last4_digits) = get_card_bin_and_last4_digits_for_masked_card(