mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-03 13:30:39 +08:00
refactor(connector): [Mifinity]Move destination_account_number from pmd to Mifinity Metadata (#4962)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -11802,13 +11802,9 @@
|
|||||||
"MifinityData": {
|
"MifinityData": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"destination_account_number",
|
|
||||||
"date_of_birth"
|
"date_of_birth"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"destination_account_number": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"date_of_birth": {
|
"date_of_birth": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date"
|
"format": "date"
|
||||||
|
|||||||
@ -2580,8 +2580,6 @@ pub struct SwishQrData {}
|
|||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||||
pub struct MifinityData {
|
pub struct MifinityData {
|
||||||
#[schema(value_type = String)]
|
|
||||||
pub destination_account_number: Secret<String>,
|
|
||||||
#[schema(value_type = Date)]
|
#[schema(value_type = Date)]
|
||||||
pub date_of_birth: Secret<Date>,
|
pub date_of_birth: Secret<Date>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,7 @@ pub struct ApiModelMetaData {
|
|||||||
pub klarna_region: Option<KlarnaEndpoint>,
|
pub klarna_region: Option<KlarnaEndpoint>,
|
||||||
pub source_balance_account: Option<String>,
|
pub source_balance_account: Option<String>,
|
||||||
pub brand_id: Option<String>,
|
pub brand_id: Option<String>,
|
||||||
|
pub destination_account_number: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serde_with::skip_serializing_none]
|
#[serde_with::skip_serializing_none]
|
||||||
@ -217,4 +218,5 @@ pub struct DashboardMetaData {
|
|||||||
pub klarna_region: Option<KlarnaEndpoint>,
|
pub klarna_region: Option<KlarnaEndpoint>,
|
||||||
pub source_balance_account: Option<String>,
|
pub source_balance_account: Option<String>,
|
||||||
pub brand_id: Option<String>,
|
pub brand_id: Option<String>,
|
||||||
|
pub destination_account_number: Option<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,6 +104,7 @@ pub struct ConfigMetadata {
|
|||||||
pub klarna_region: Option<Vec<KlarnaEndpoint>>,
|
pub klarna_region: Option<Vec<KlarnaEndpoint>>,
|
||||||
pub source_balance_account: Option<String>,
|
pub source_balance_account: Option<String>,
|
||||||
pub brand_id: Option<String>,
|
pub brand_id: Option<String>,
|
||||||
|
pub destination_account_number: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serde_with::skip_serializing_none]
|
#[serde_with::skip_serializing_none]
|
||||||
|
|||||||
@ -337,6 +337,7 @@ impl From<ApiModelMetaData> for DashboardMetaData {
|
|||||||
klarna_region: api_model.klarna_region,
|
klarna_region: api_model.klarna_region,
|
||||||
source_balance_account: api_model.source_balance_account,
|
source_balance_account: api_model.source_balance_account,
|
||||||
brand_id: api_model.brand_id,
|
brand_id: api_model.brand_id,
|
||||||
|
destination_account_number: api_model.destination_account_number,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -203,6 +203,7 @@ impl DashboardRequestPayload {
|
|||||||
klarna_region: None,
|
klarna_region: None,
|
||||||
source_balance_account: None,
|
source_balance_account: None,
|
||||||
brand_id: None,
|
brand_id: None,
|
||||||
|
destination_account_number: None,
|
||||||
};
|
};
|
||||||
let meta_data = match request.metadata {
|
let meta_data = match request.metadata {
|
||||||
Some(data) => data,
|
Some(data) => data,
|
||||||
@ -231,6 +232,7 @@ impl DashboardRequestPayload {
|
|||||||
let klarna_region = meta_data.klarna_region;
|
let klarna_region = meta_data.klarna_region;
|
||||||
let source_balance_account = meta_data.source_balance_account;
|
let source_balance_account = meta_data.source_balance_account;
|
||||||
let brand_id = meta_data.brand_id;
|
let brand_id = meta_data.brand_id;
|
||||||
|
let destination_account_number = meta_data.destination_account_number;
|
||||||
|
|
||||||
Some(ApiModelMetaData {
|
Some(ApiModelMetaData {
|
||||||
google_pay,
|
google_pay,
|
||||||
@ -255,6 +257,7 @@ impl DashboardRequestPayload {
|
|||||||
klarna_region,
|
klarna_region,
|
||||||
source_balance_account,
|
source_balance_account,
|
||||||
brand_id,
|
brand_id,
|
||||||
|
destination_account_number,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1168,6 +1168,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
|||||||
api_key="key"
|
api_key="key"
|
||||||
[mifinity.metadata]
|
[mifinity.metadata]
|
||||||
brand_id="Brand ID"
|
brand_id="Brand ID"
|
||||||
|
destination_account_number="Destination Account Number"
|
||||||
|
|
||||||
[mollie]
|
[mollie]
|
||||||
[[mollie.credit]]
|
[[mollie.credit]]
|
||||||
|
|||||||
@ -973,6 +973,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
|||||||
api_key="key"
|
api_key="key"
|
||||||
[mifinity.metadata]
|
[mifinity.metadata]
|
||||||
brand_id="Brand ID"
|
brand_id="Brand ID"
|
||||||
|
destination_account_number="Destination Account Number"
|
||||||
|
|
||||||
|
|
||||||
[mollie]
|
[mollie]
|
||||||
|
|||||||
@ -1168,6 +1168,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
|||||||
api_key="key"
|
api_key="key"
|
||||||
[mifinity.metadata]
|
[mifinity.metadata]
|
||||||
brand_id="Brand ID"
|
brand_id="Brand ID"
|
||||||
|
destination_account_number="Destination Account Number"
|
||||||
|
|
||||||
[mollie]
|
[mollie]
|
||||||
[[mollie.credit]]
|
[[mollie.credit]]
|
||||||
|
|||||||
@ -117,7 +117,6 @@ pub enum WalletData {
|
|||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct MifinityData {
|
pub struct MifinityData {
|
||||||
pub destination_account_number: Secret<String>,
|
|
||||||
pub date_of_birth: Secret<Date>,
|
pub date_of_birth: Secret<Date>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,7 +593,6 @@ impl From<api_models::payments::WalletData> for WalletData {
|
|||||||
api_models::payments::WalletData::SwishQr(_) => Self::SwishQr(SwishQrData {}),
|
api_models::payments::WalletData::SwishQr(_) => Self::SwishQr(SwishQrData {}),
|
||||||
api_models::payments::WalletData::Mifinity(mifinity_data) => {
|
api_models::payments::WalletData::Mifinity(mifinity_data) => {
|
||||||
Self::Mifinity(MifinityData {
|
Self::Mifinity(MifinityData {
|
||||||
destination_account_number: mifinity_data.destination_account_number,
|
|
||||||
date_of_birth: mifinity_data.date_of_birth,
|
date_of_birth: mifinity_data.date_of_birth,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
use common_utils::pii::{self, Email};
|
use common_utils::pii::{self, Email};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
use masking::{ExposeInterface, Secret};
|
use masking::Secret;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use time::Date;
|
use time::Date;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
connector::utils::{self, PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData},
|
connector::utils::{self, PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData},
|
||||||
core::errors::{self, CustomResult},
|
core::errors,
|
||||||
services,
|
services,
|
||||||
types::{self, api, domain, storage::enums},
|
types::{self, api, domain, storage::enums},
|
||||||
};
|
};
|
||||||
@ -36,6 +36,7 @@ pub mod auth_headers {
|
|||||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||||
pub struct MifinityConnectorMetadataObject {
|
pub struct MifinityConnectorMetadataObject {
|
||||||
pub brand_id: Secret<String>,
|
pub brand_id: Secret<String>,
|
||||||
|
pub destination_account_number: Secret<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&Option<pii::SecretSerdeValue>> for MifinityConnectorMetadataObject {
|
impl TryFrom<&Option<pii::SecretSerdeValue>> for MifinityConnectorMetadataObject {
|
||||||
@ -49,14 +50,6 @@ impl TryFrom<&Option<pii::SecretSerdeValue>> for MifinityConnectorMetadataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_brand_id(
|
|
||||||
connector_metadata: &Option<pii::SecretSerdeValue>,
|
|
||||||
) -> CustomResult<String, errors::ConnectorError> {
|
|
||||||
let mifinity_metadata = MifinityConnectorMetadataObject::try_from(connector_metadata)?;
|
|
||||||
let brand_id = mifinity_metadata.brand_id.clone().expose();
|
|
||||||
Ok(brand_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, PartialEq)]
|
#[derive(Debug, Serialize, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct MifinityPaymentsRequest {
|
pub struct MifinityPaymentsRequest {
|
||||||
@ -103,6 +96,11 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin
|
|||||||
fn try_from(
|
fn try_from(
|
||||||
item: &MifinityRouterData<&types::PaymentsAuthorizeRouterData>,
|
item: &MifinityRouterData<&types::PaymentsAuthorizeRouterData>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
|
let metadata: MifinityConnectorMetadataObject =
|
||||||
|
utils::to_connector_meta_from_secret(item.router_data.connector_meta_data.clone())
|
||||||
|
.change_context(errors::ConnectorError::InvalidConnectorConfig {
|
||||||
|
config: "merchant_connector_account.metadata",
|
||||||
|
})?;
|
||||||
match item.router_data.request.payment_method_data.clone() {
|
match item.router_data.request.payment_method_data.clone() {
|
||||||
domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data {
|
domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data {
|
||||||
domain::WalletData::Mifinity(data) => {
|
domain::WalletData::Mifinity(data) => {
|
||||||
@ -135,10 +133,9 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin
|
|||||||
field_name: "client_reference",
|
field_name: "client_reference",
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let destination_account_number = data.destination_account_number;
|
let destination_account_number = metadata.destination_account_number;
|
||||||
let trace_id = item.router_data.connector_request_reference_id.clone();
|
let trace_id = item.router_data.connector_request_reference_id.clone();
|
||||||
let brand_id =
|
let brand_id = metadata.brand_id;
|
||||||
Secret::new(get_brand_id(&item.router_data.connector_meta_data)?);
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
money,
|
money,
|
||||||
client,
|
client,
|
||||||
|
|||||||
Reference in New Issue
Block a user