mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 05:59:48 +08:00 
			
		
		
		
	refactor: insert requires cvv config to configs table if not found in db (#2208)
This commit is contained in:
		@ -1825,23 +1825,15 @@ pub async fn list_customer_payment_method(
 | 
				
			|||||||
    let key = key_store.key.get_inner().peek();
 | 
					    let key = key_store.key.get_inner().peek();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let is_requires_cvv = db
 | 
					    let is_requires_cvv = db
 | 
				
			||||||
        .find_config_by_key(format!("{}_requires_cvv", merchant_account.merchant_id).as_str())
 | 
					        .find_config_by_key_unwrap_or(
 | 
				
			||||||
        .await;
 | 
					            format!("{}_requires_cvv", merchant_account.merchant_id).as_str(),
 | 
				
			||||||
 | 
					            Some("true".to_string()),
 | 
				
			||||||
    let requires_cvv = match is_requires_cvv {
 | 
					        )
 | 
				
			||||||
        // If an entry is found with the config value as `false`, we set requires_cvv to false
 | 
					        .await
 | 
				
			||||||
        Ok(value) => value.config != "false",
 | 
					 | 
				
			||||||
        Err(err) => {
 | 
					 | 
				
			||||||
            if err.current_context().is_db_not_found() {
 | 
					 | 
				
			||||||
                // By default, cvv is made required field for all merchants
 | 
					 | 
				
			||||||
                true
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                Err(err
 | 
					 | 
				
			||||||
        .change_context(errors::ApiErrorResponse::InternalServerError)
 | 
					        .change_context(errors::ApiErrorResponse::InternalServerError)
 | 
				
			||||||
                    .attach_printable("Failed to fetch merchant_id config for requires_cvv"))?
 | 
					        .attach_printable("Failed to fetch merchant_id config for requires_cvv")?;
 | 
				
			||||||
            }
 | 
					
 | 
				
			||||||
        }
 | 
					    let requires_cvv = is_requires_cvv.config != "false";
 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let resp = db
 | 
					    let resp = db
 | 
				
			||||||
        .find_payment_method_by_customer_id_merchant_id_list(
 | 
					        .find_payment_method_by_customer_id_merchant_id_list(
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user