refactor: Pass country and currency as json format in MCA (#523)

This commit is contained in:
Manoj Ghorela
2023-02-24 19:39:03 +05:30
committed by GitHub
parent 32de632ded
commit d27e6be599
5 changed files with 212 additions and 37 deletions

View File

@ -269,14 +269,16 @@ pub struct PaymentConnectorCreate {
"Discover",
"Discover"
],
"accepted_currencies": [
"AED",
"AED"
],
"accepted_countries": [
"in",
"us"
],
"accepted_currencies": {
"enable_all":false,
"disable_only": ["INR", "CAD", "AED","JPY"],
"enable_only": ["EUR","USD"]
},
"accepted_countries": {
"enable_all":false,
"disable_only": ["FR", "DE","IN"],
"enable_only": ["UK","AU"]
},
"minimum_amount": 1,
"maximum_amount": 68607706,
"recurring_enabled": true,
@ -305,11 +307,23 @@ pub struct PaymentMethods {
#[schema(example = json!(["MASTER","VISA","DINERS"]))]
pub payment_schemes: Option<Vec<String>>,
/// List of currencies accepted or has the processing capabilities of the processor
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD","EUR","AED"]))]
pub accepted_currencies: Option<Vec<api_enums::Currency>>,
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["INR", "CAD", "AED","JPY"],
"enable_only": ["EUR","USD"]
}
))]
pub accepted_currencies: Option<AcceptedCurrencies>,
/// List of Countries accepted or has the processing capabilities of the processor
#[schema(example = json!(["US","IN"]))]
pub accepted_countries: Option<Vec<String>>,
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["FR", "DE","IN"],
"enable_only": ["UK","AU"]
}
))]
pub accepted_countries: Option<AcceptedCountries>,
/// Minimum amount supported by the processor. To be represented in the lowest denomination of the target currency (For example, for USD it should be in cents)
#[schema(example = 1)]
pub minimum_amount: Option<i32>,
@ -328,6 +342,30 @@ pub struct PaymentMethods {
pub payment_experience: Option<Vec<api_enums::PaymentExperience>>,
}
/// List of enabled and disabled currencies
#[derive(Eq, PartialEq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AcceptedCurrencies {
/// True in case all currencies are supported
pub enable_all: bool,
/// List of disabled currencies, provide in case only few of currencies are not supported
pub disable_only: Option<Vec<api_enums::Currency>>,
/// List of enable currencies, provide in case only few of currencies are supported
pub enable_only: Option<Vec<api_enums::Currency>>,
}
/// List of enabled and disabled countries
#[derive(Eq, PartialEq, Hash, Debug, Clone, serde::Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AcceptedCountries {
/// True in case all countries are supported
pub enable_all: bool,
/// List of disabled countries, provide in case only few of countries are not supported
pub disable_only: Option<Vec<String>>,
/// List of enable countries, provide in case only few of countries are supported
pub enable_only: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct DeleteMcaResponse {
/// The identifier for the Merchant Account

View File

@ -4,7 +4,7 @@ use common_utils::pii;
use serde::de;
use utoipa::ToSchema;
use crate::enums as api_enums;
use crate::{admin, enums as api_enums};
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
@ -322,12 +322,24 @@ pub struct ListPaymentMethod {
pub payment_schemes: Option<Vec<String>>,
/// List of Countries accepted or has the processing capabilities of the processor
#[schema(example = json!(["US", "UK", "IN"]))]
pub accepted_countries: Option<Vec<String>>,
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["FR", "DE","IN"],
"enable_only": ["UK","AU"]
}
))]
pub accepted_countries: Option<admin::AcceptedCountries>,
/// List of currencies accepted or has the processing capabilities of the processor
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD", "EUR"]))]
pub accepted_currencies: Option<Vec<api_enums::Currency>>,
#[schema(example = json!(
{
"enable_all":false,
"disable_only": ["INR", "CAD", "AED","JPY"],
"enable_only": ["EUR","USD"]
}
))]
pub accepted_currencies: Option<admin::AcceptedCurrencies>,
/// Minimum amount supported by the processor. To be represented in the lowest denomination of
/// the target currency (For example, for USD it should be in cents)