From 16a931093752c1f40e3f0d2838b9dc2bf5ccd096 Mon Sep 17 00:00:00 2001 From: Sagnik Mitra Date: Mon, 28 Oct 2024 18:44:13 +0530 Subject: [PATCH] dispute currency type change to enum --- crates/api_models/src/disputes.rs | 11 +- crates/diesel_models/src/dispute.rs | 4 +- crates/diesel_models/src/schema.rs | 3 +- crates/diesel_models/src/schema_v2.rs | 3 +- .../src/connectors/airwallex.rs | 2 +- crates/hyperswitch_interfaces/src/disputes.rs | 2 +- .../src/compatibility/stripe/webhooks.rs | 4 +- crates/router/src/connector/adyen.rs | 2 +- crates/router/src/connector/bluesnap.rs | 2 +- crates/router/src/connector/braintree.rs | 2 +- crates/router/src/connector/checkout.rs | 2 +- crates/router/src/connector/payme.rs | 2 +- crates/router/src/connector/paypal.rs | 2 +- crates/router/src/connector/rapyd.rs | 2 +- crates/router/src/connector/stripe.rs | 2 +- crates/router/src/connector/trustpay.rs | 2 +- crates/router/src/connector/utils.rs | 163 ++++++++++++++++++ crates/router/src/db/dispute.rs | 4 +- crates/router/src/services/kafka/dispute.rs | 2 +- .../src/services/kafka/dispute_event.rs | 2 +- crates/router/src/types/storage/dispute.rs | 8 +- crates/router/src/utils/user/sample_data.rs | 3 +- .../down.sql | 2 + .../up.sql | 2 + 24 files changed, 196 insertions(+), 37 deletions(-) create mode 100644 migrations/2024-10-28-125949_change_currency_type_in_dispute/down.sql create mode 100644 migrations/2024-10-28-125949_change_currency_type_in_dispute/up.sql diff --git a/crates/api_models/src/disputes.rs b/crates/api_models/src/disputes.rs index 4ddb50af0f2a..c5448b0dfc6d 100644 --- a/crates/api_models/src/disputes.rs +++ b/crates/api_models/src/disputes.rs @@ -6,8 +6,8 @@ use serde::de::Error; use time::PrimitiveDateTime; use utoipa::ToSchema; -use super::enums::{DisputeStage, DisputeStatus}; -use crate::{admin::MerchantConnectorInfo, enums, files}; +use super::enums::{DisputeStage, DisputeStatus, Currency}; +use crate::{admin::MerchantConnectorInfo, files}; #[derive(Clone, Debug, Serialize, ToSchema, Eq, PartialEq)] pub struct DisputeResponse { @@ -21,7 +21,8 @@ pub struct DisputeResponse { /// The dispute amount pub amount: String, /// The three-letter ISO currency code - pub currency: String, + #[schema(value_type = Currency)] + pub currency: Currency, /// Stage of the dispute pub dispute_stage: DisputeStage, /// Status of the dispute @@ -137,7 +138,7 @@ pub struct DisputeListGetConstraints { pub connector: Option>, /// The comma separated list of currencies of the disputes #[serde(default, deserialize_with = "parse_comma_separated")] - pub currency: Option>, + pub currency: Option>, /// The merchant connector id to filter the disputes list pub merchant_connector_id: Option, /// The time range for which objects are needed. TimeRange has two fields start_time and end_time from which objects can be filtered as per required scenarios (created_at, time less than, greater than etc). @@ -150,7 +151,7 @@ pub struct DisputeListFilters { /// The map of available connector filters, where the key is the connector name and the value is a list of MerchantConnectorInfo instances pub connector: HashMap>, /// The list of available currency filters - pub currency: Vec, + pub currency: Vec, /// The list of available dispute status filters pub dispute_status: Vec, /// The list of available dispute stage filters diff --git a/crates/diesel_models/src/dispute.rs b/crates/diesel_models/src/dispute.rs index 130e46aa9cc1..649c2eeb6494 100644 --- a/crates/diesel_models/src/dispute.rs +++ b/crates/diesel_models/src/dispute.rs @@ -12,7 +12,7 @@ use crate::{enums as storage_enums, schema::dispute}; pub struct DisputeNew { pub dispute_id: String, pub amount: String, - pub currency: String, + pub currency: storage_enums::Currency, pub dispute_stage: storage_enums::DisputeStage, pub dispute_status: storage_enums::DisputeStatus, pub payment_id: common_utils::id_type::PaymentId, @@ -38,7 +38,7 @@ pub struct DisputeNew { pub struct Dispute { pub dispute_id: String, pub amount: String, - pub currency: String, + pub currency: storage_enums::Currency, pub dispute_stage: storage_enums::DisputeStage, pub dispute_status: storage_enums::DisputeStatus, pub payment_id: common_utils::id_type::PaymentId, diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index e2ab676b2d30..82c4b44c3ce3 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -351,8 +351,7 @@ diesel::table! { dispute_id -> Varchar, #[max_length = 255] amount -> Varchar, - #[max_length = 255] - currency -> Varchar, + currency -> Currency, dispute_stage -> DisputeStage, dispute_status -> DisputeStatus, #[max_length = 64] diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs index 5651bf95dd9d..56c1eaab9927 100644 --- a/crates/diesel_models/src/schema_v2.rs +++ b/crates/diesel_models/src/schema_v2.rs @@ -362,8 +362,7 @@ diesel::table! { dispute_id -> Varchar, #[max_length = 255] amount -> Varchar, - #[max_length = 255] - currency -> Varchar, + currency -> Currency, dispute_stage -> DisputeStage, dispute_status -> DisputeStatus, #[max_length = 64] diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 26bfcd1e07e3..fe7949d88b67 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -1074,7 +1074,7 @@ impl IncomingWebhook for Airwallex { .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(DisputePayload { amount: dispute_details.dispute_amount.to_string(), - currency: dispute_details.dispute_currency, + currency: connector_utils::string_to_currency(dispute_details.dispute_currency), dispute_stage: api_models::enums::DisputeStage::from(dispute_details.stage.clone()), connector_dispute_id: dispute_details.dispute_id, connector_reason: dispute_details.dispute_reason_type, diff --git a/crates/hyperswitch_interfaces/src/disputes.rs b/crates/hyperswitch_interfaces/src/disputes.rs index acc7b56e906e..55a6d13c91d1 100644 --- a/crates/hyperswitch_interfaces/src/disputes.rs +++ b/crates/hyperswitch_interfaces/src/disputes.rs @@ -8,7 +8,7 @@ pub struct DisputePayload { /// amount pub amount: String, /// currency - pub currency: String, + pub currency: common_enums::enums::Currency, /// dispute_stage pub dispute_stage: common_enums::enums::DisputeStage, /// connector_status diff --git a/crates/router/src/compatibility/stripe/webhooks.rs b/crates/router/src/compatibility/stripe/webhooks.rs index ddc291e6b139..999f2418a860 100644 --- a/crates/router/src/compatibility/stripe/webhooks.rs +++ b/crates/router/src/compatibility/stripe/webhooks.rs @@ -1,7 +1,7 @@ #[cfg(feature = "payouts")] use api_models::payouts as payout_models; use api_models::{ - enums::{DisputeStatus, MandateStatus}, + enums::{DisputeStatus, MandateStatus, Currency}, webhooks::{self as api}, }; #[cfg(feature = "payouts")] @@ -93,7 +93,7 @@ pub enum StripeWebhookObject { pub struct StripeDisputeResponse { pub id: String, pub amount: String, - pub currency: String, + pub currency: Currency, pub payment_intent: common_utils::id_type::PaymentId, pub reason: Option, pub status: StripeDisputeStatus, diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index e5215022e944..788e4909e298 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -1894,7 +1894,7 @@ impl api::IncomingWebhook for Adyen { .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::disputes::DisputePayload { amount: notif.amount.value.to_string(), - currency: notif.amount.currency.to_string(), + currency: notif.amount.currency, dispute_stage: api_models::enums::DisputeStage::from(notif.event_code.clone()), connector_dispute_id: notif.psp_reference, connector_reason: notif.reason, diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 468f68dc340c..181f1dbf3d7e 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -1149,7 +1149,7 @@ impl api::IncomingWebhook for Bluesnap { dispute_details.invoice_charge_amount.abs().to_string(), dispute_details.currency, )?, - currency: dispute_details.currency.to_string(), + currency: dispute_details.currency, dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id: dispute_details.reversal_ref_num, connector_reason: dispute_details.reversal_reason, diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index 85b310397b26..f8034755e627 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -1006,7 +1006,7 @@ impl api::IncomingWebhook for Braintree { dispute_data.amount_disputed.to_string(), currency, )?, - currency: dispute_data.currency_iso_code, + currency: connector_utils::string_to_currency(dispute_data.currency_iso_code), dispute_stage: transformers::get_dispute_stage(dispute_data.kind.as_str())?, connector_dispute_id: dispute_data.id, connector_reason: dispute_data.reason, diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 3fca0b86aeba..b96120acc9e7 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -1332,7 +1332,7 @@ impl api::IncomingWebhook for Checkout { .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?; Ok(api::disputes::DisputePayload { amount: dispute_details.data.amount.to_string(), - currency: dispute_details.data.currency, + currency: connector_utils::string_to_currency(dispute_details.data.currency), dispute_stage: api_models::enums::DisputeStage::from( dispute_details.transaction_type.clone(), ), diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 6bf26b4f60bd..bc5524e5c8fc 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -1280,7 +1280,7 @@ impl api::IncomingWebhook for Payme { Ok(api::disputes::DisputePayload { amount: webhook_object.price.to_string(), - currency: webhook_object.currency.to_string(), + currency: webhook_object.currency, dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id: webhook_object.payme_transaction_id, connector_reason: None, diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 48a35c78cc25..e79912f61ff2 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -2001,7 +2001,7 @@ impl api::IncomingWebhook for Paypal { payload.dispute_amount.value.get_amount_as_string(), payload.dispute_amount.currency_code, )?, - currency: payload.dispute_amount.currency_code.to_string(), + currency: payload.dispute_amount.currency_code, dispute_stage: api_models::enums::DisputeStage::from( payload.dispute_life_cycle_stage.clone(), ), diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index 196eb4ce73dd..64c3fcdf5a1b 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -974,7 +974,7 @@ impl api::IncomingWebhook for Rapyd { }?; Ok(api::disputes::DisputePayload { amount: webhook_dispute_data.amount.to_string(), - currency: webhook_dispute_data.currency.to_string(), + currency: webhook_dispute_data.currency, dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id: webhook_dispute_data.token, connector_reason: Some(webhook_dispute_data.dispute_reason_description), diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 1125c0af6dc8..3c908a962e5b 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -2432,7 +2432,7 @@ impl api::IncomingWebhook for Stripe { field_name: "amount", })? .to_string(), - currency: details.event_data.event_object.currency, + currency: connector_utils::string_to_currency(details.event_data.event_object.currency), dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id: details.event_data.event_object.id, connector_reason: details.event_data.event_object.reason, diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 6562ba319760..284438a786ec 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -990,7 +990,7 @@ impl api::IncomingWebhook for Trustpay { .ok_or(errors::ConnectorError::WebhookReferenceIdNotFound)?; Ok(api::disputes::DisputePayload { amount: payment_info.amount.amount.to_string(), - currency: payment_info.amount.currency, + currency: connector_utils::string_to_currency(payment_info.amount.currency), dispute_stage: api_models::enums::DisputeStage::Dispute, connector_dispute_id, connector_reason: reason.reason.reject_reason, diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs index 76def480cffe..a1d6477b3816 100644 --- a/crates/router/src/connector/utils.rs +++ b/crates/router/src/connector/utils.rs @@ -3139,3 +3139,166 @@ impl NetworkTokenData for domain::NetworkTokenData { Secret::new(year) } } + +pub fn string_to_currency(currency: String) -> enums::Currency { + match currency.to_lowercase().as_str() { + "aed" => enums::Currency::AED, + "afn" => enums::Currency::AFN, + "all" => enums::Currency::ALL, + "amd" => enums::Currency::AMD, + "ang" => enums::Currency::ANG, + "aoa" => enums::Currency::AOA, + "ars" => enums::Currency::ARS, + "aud" => enums::Currency::AUD, + "awg" => enums::Currency::AWG, + "azn" => enums::Currency::AZN, + "bam" => enums::Currency::BAM, + "bbd" => enums::Currency::BBD, + "bdt" => enums::Currency::BDT, + "bgn" => enums::Currency::BGN, + "bhd" => enums::Currency::BHD, + "bif" => enums::Currency::BIF, + "bmd" => enums::Currency::BMD, + "bnd" => enums::Currency::BND, + "bob" => enums::Currency::BOB, + "brl" => enums::Currency::BRL, + "bsd" => enums::Currency::BSD, + "btn" => enums::Currency::BTN, + "bwp" => enums::Currency::BWP, + "byn" => enums::Currency::BYN, + "bzd" => enums::Currency::BZD, + "cad" => enums::Currency::CAD, + "cdf" => enums::Currency::CDF, + "chf" => enums::Currency::CHF, + "clp" => enums::Currency::CLP, + "cny" => enums::Currency::CNY, + "cop" => enums::Currency::COP, + "crc" => enums::Currency::CRC, + "cup" => enums::Currency::CUP, + "cve" => enums::Currency::CVE, + "czk" => enums::Currency::CZK, + "djf" => enums::Currency::DJF, + "dkk" => enums::Currency::DKK, + "dop" => enums::Currency::DOP, + "dzd" => enums::Currency::DZD, + "egp" => enums::Currency::EGP, + "ern" => enums::Currency::ERN, + "etb" => enums::Currency::ETB, + "eur" => enums::Currency::EUR, + "fjd" => enums::Currency::FJD, + "fkp" => enums::Currency::FKP, + "gbp" => enums::Currency::GBP, + "gel" => enums::Currency::GEL, + "ghs" => enums::Currency::GHS, + "gip" => enums::Currency::GIP, + "gmd" => enums::Currency::GMD, + "gnf" => enums::Currency::GNF, + "gtq" => enums::Currency::GTQ, + "gyd" => enums::Currency::GYD, + "hkd" => enums::Currency::HKD, + "hnl" => enums::Currency::HNL, + "hrk" => enums::Currency::HRK, + "htg" => enums::Currency::HTG, + "huf" => enums::Currency::HUF, + "idr" => enums::Currency::IDR, + "ils" => enums::Currency::ILS, + "inr" => enums::Currency::INR, + "iqd" => enums::Currency::IQD, + "irr" => enums::Currency::IRR, + "isk" => enums::Currency::ISK, + "jmd" => enums::Currency::JMD, + "jod" => enums::Currency::JOD, + "jpy" => enums::Currency::JPY, + "kes" => enums::Currency::KES, + "kgs" => enums::Currency::KGS, + "khr" => enums::Currency::KHR, + "kmf" => enums::Currency::KMF, + "kpw" => enums::Currency::KPW, + "krw" => enums::Currency::KRW, + "kwd" => enums::Currency::KWD, + "kyd" => enums::Currency::KYD, + "kzt" => enums::Currency::KZT, + "lak" => enums::Currency::LAK, + "lbp" => enums::Currency::LBP, + "lkr" => enums::Currency::LKR, + "lrd" => enums::Currency::LRD, + "lsl" => enums::Currency::LSL, + "lyd" => enums::Currency::LYD, + "mad" => enums::Currency::MAD, + "mdl" => enums::Currency::MDL, + "mga" => enums::Currency::MGA, + "mkd" => enums::Currency::MKD, + "mmk" => enums::Currency::MMK, + "mnt" => enums::Currency::MNT, + "mop" => enums::Currency::MOP, + "mru" => enums::Currency::MRU, + "mur" => enums::Currency::MUR, + "mvr" => enums::Currency::MVR, + "mwk" => enums::Currency::MWK, + "mxn" => enums::Currency::MXN, + "myr" => enums::Currency::MYR, + "mzn" => enums::Currency::MZN, + "nad" => enums::Currency::NAD, + "ngn" => enums::Currency::NGN, + "nio" => enums::Currency::NIO, + "nok" => enums::Currency::NOK, + "npr" => enums::Currency::NPR, + "nzd" => enums::Currency::NZD, + "omr" => enums::Currency::OMR, + "pab" => enums::Currency::PAB, + "pen" => enums::Currency::PEN, + "pgk" => enums::Currency::PGK, + "php" => enums::Currency::PHP, + "pkr" => enums::Currency::PKR, + "pln" => enums::Currency::PLN, + "pyg" => enums::Currency::PYG, + "qar" => enums::Currency::QAR, + "ron" => enums::Currency::RON, + "rsd" => enums::Currency::RSD, + "rub" => enums::Currency::RUB, + "rwf" => enums::Currency::RWF, + "sar" => enums::Currency::SAR, + "sbd" => enums::Currency::SBD, + "scr" => enums::Currency::SCR, + "sdg" => enums::Currency::SDG, + "sek" => enums::Currency::SEK, + "sgd" => enums::Currency::SGD, + "shp" => enums::Currency::SHP, + "sle" => enums::Currency::SLE, + "sll" => enums::Currency::SLL, + "sos" => enums::Currency::SOS, + "srd" => enums::Currency::SRD, + "ssp" => enums::Currency::SSP, + "stn" => enums::Currency::STN, + "svc" => enums::Currency::SVC, + "syp" => enums::Currency::SYP, + "szl" => enums::Currency::SZL, + "thb" => enums::Currency::THB, + "tjs" => enums::Currency::TJS, + "tmt" => enums::Currency::TMT, + "tnd" => enums::Currency::TND, + "top" => enums::Currency::TOP, + "try" => enums::Currency::TRY, + "ttd" => enums::Currency::TTD, + "twd" => enums::Currency::TWD, + "tzs" => enums::Currency::TZS, + "uah" => enums::Currency::UAH, + "ugx" => enums::Currency::UGX, + "usd" => enums::Currency::USD, + "uyu" => enums::Currency::UYU, + "uzs" => enums::Currency::UZS, + "ves" => enums::Currency::VES, + "vnd" => enums::Currency::VND, + "vuv" => enums::Currency::VUV, + "wst" => enums::Currency::WST, + "xaf" => enums::Currency::XAF, + "xcd" => enums::Currency::XCD, + "xof" => enums::Currency::XOF, + "xpf" => enums::Currency::XPF, + "yer" => enums::Currency::YER, + "zar" => enums::Currency::ZAR, + "zmw" => enums::Currency::ZMW, + "zwl" => enums::Currency::ZWL, + _ => enums::Currency::USD, + } +} diff --git a/crates/router/src/db/dispute.rs b/crates/router/src/db/dispute.rs index d7f4af63015e..077629d2ce6c 100644 --- a/crates/router/src/db/dispute.rs +++ b/crates/router/src/db/dispute.rs @@ -310,7 +310,7 @@ impl DisputeInterface for MockDb { .map_or(true, |currencies| { currencies .iter() - .any(|currency| dispute.currency.as_str() == currency.to_string()) + .any(|currency| &dispute.currency == currency) }) && dispute_constraints .time_range @@ -483,7 +483,7 @@ mod tests { DisputeNew { dispute_id: dispute_ids.dispute_id, amount: "amount".into(), - currency: "currency".into(), + currency: common_enums::Currency::USD, dispute_stage: DisputeStage::Dispute, dispute_status: DisputeStatus::DisputeOpened, payment_id: dispute_ids.payment_id, diff --git a/crates/router/src/services/kafka/dispute.rs b/crates/router/src/services/kafka/dispute.rs index 2afb41cc8673..16f2d2336fbe 100644 --- a/crates/router/src/services/kafka/dispute.rs +++ b/crates/router/src/services/kafka/dispute.rs @@ -9,7 +9,7 @@ use crate::types::storage::dispute::Dispute; pub struct KafkaDispute<'a> { pub dispute_id: &'a String, pub dispute_amount: i64, - pub currency: &'a String, + pub currency: &'a storage_enums::Currency, pub dispute_stage: &'a storage_enums::DisputeStage, pub dispute_status: &'a storage_enums::DisputeStatus, pub payment_id: &'a id_type::PaymentId, diff --git a/crates/router/src/services/kafka/dispute_event.rs b/crates/router/src/services/kafka/dispute_event.rs index 057a060decda..25cc0c611fc9 100644 --- a/crates/router/src/services/kafka/dispute_event.rs +++ b/crates/router/src/services/kafka/dispute_event.rs @@ -9,7 +9,7 @@ use crate::types::storage::dispute::Dispute; pub struct KafkaDisputeEvent<'a> { pub dispute_id: &'a String, pub dispute_amount: i64, - pub currency: &'a String, + pub currency: &'a storage_enums::Currency, pub dispute_stage: &'a storage_enums::DisputeStage, pub dispute_status: &'a storage_enums::DisputeStatus, pub payment_id: &'a common_utils::id_type::PaymentId, diff --git a/crates/router/src/types/storage/dispute.rs b/crates/router/src/types/storage/dispute.rs index 28a9573b3330..2ebc30e470ef 100644 --- a/crates/router/src/types/storage/dispute.rs +++ b/crates/router/src/types/storage/dispute.rs @@ -83,14 +83,8 @@ impl DisputeDbExt for Dispute { if let Some(dispute_status) = &dispute_list_constraints.dispute_status { filter = filter.filter(dsl::dispute_status.eq_any(dispute_status.clone())); } - if let Some(currency_list) = &dispute_list_constraints.currency { - let currency: Vec = currency_list - .iter() - .map(|currency| currency.to_string()) - .collect(); - - filter = filter.filter(dsl::currency.eq_any(currency)); + filter = filter.filter(dsl::currency.eq_any(currency_list.clone())); } if let Some(merchant_connector_id) = &dispute_list_constraints.merchant_connector_id { filter = filter.filter(dsl::merchant_connector_id.eq(merchant_connector_id.clone())) diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs index 4f859d8e56a9..44258e75ddae 100644 --- a/crates/router/src/utils/user/sample_data.rs +++ b/crates/router/src/utils/user/sample_data.rs @@ -412,8 +412,7 @@ pub async fn generate_sample_data( amount: (amount * 100).to_string(), currency: payment_intent .currency - .unwrap_or(common_enums::Currency::USD) - .to_string(), + .unwrap_or(common_enums::Currency::USD), dispute_stage: storage_enums::DisputeStage::Dispute, dispute_status: storage_enums::DisputeStatus::DisputeOpened, payment_id: payment_id.clone(), diff --git a/migrations/2024-10-28-125949_change_currency_type_in_dispute/down.sql b/migrations/2024-10-28-125949_change_currency_type_in_dispute/down.sql new file mode 100644 index 000000000000..563d9e20b9ba --- /dev/null +++ b/migrations/2024-10-28-125949_change_currency_type_in_dispute/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE dispute ALTER COLUMN currency TYPE VARCHAR(255) USING currency::VARCHAR(255); \ No newline at end of file diff --git a/migrations/2024-10-28-125949_change_currency_type_in_dispute/up.sql b/migrations/2024-10-28-125949_change_currency_type_in_dispute/up.sql new file mode 100644 index 000000000000..47b5fa05e8db --- /dev/null +++ b/migrations/2024-10-28-125949_change_currency_type_in_dispute/up.sql @@ -0,0 +1,2 @@ +-- Your SQL goes here +ALTER TABLE dispute ALTER COLUMN currency TYPE "Currency" USING currency::"Currency"; \ No newline at end of file