mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +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": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"destination_account_number",
|
||||
"date_of_birth"
|
||||
],
|
||||
"properties": {
|
||||
"destination_account_number": {
|
||||
"type": "string"
|
||||
},
|
||||
"date_of_birth": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
|
||||
@ -2580,8 +2580,6 @@ pub struct SwishQrData {}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
pub struct MifinityData {
|
||||
#[schema(value_type = String)]
|
||||
pub destination_account_number: Secret<String>,
|
||||
#[schema(value_type = Date)]
|
||||
pub date_of_birth: Secret<Date>,
|
||||
}
|
||||
|
||||
@ -101,6 +101,7 @@ pub struct ApiModelMetaData {
|
||||
pub klarna_region: Option<KlarnaEndpoint>,
|
||||
pub source_balance_account: Option<String>,
|
||||
pub brand_id: Option<String>,
|
||||
pub destination_account_number: Option<String>,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
@ -217,4 +218,5 @@ pub struct DashboardMetaData {
|
||||
pub klarna_region: Option<KlarnaEndpoint>,
|
||||
pub source_balance_account: 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 source_balance_account: Option<String>,
|
||||
pub brand_id: Option<String>,
|
||||
pub destination_account_number: Option<String>,
|
||||
}
|
||||
|
||||
#[serde_with::skip_serializing_none]
|
||||
|
||||
@ -337,6 +337,7 @@ impl From<ApiModelMetaData> for DashboardMetaData {
|
||||
klarna_region: api_model.klarna_region,
|
||||
source_balance_account: api_model.source_balance_account,
|
||||
brand_id: api_model.brand_id,
|
||||
destination_account_number: api_model.destination_account_number,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,6 +203,7 @@ impl DashboardRequestPayload {
|
||||
klarna_region: None,
|
||||
source_balance_account: None,
|
||||
brand_id: None,
|
||||
destination_account_number: None,
|
||||
};
|
||||
let meta_data = match request.metadata {
|
||||
Some(data) => data,
|
||||
@ -231,6 +232,7 @@ impl DashboardRequestPayload {
|
||||
let klarna_region = meta_data.klarna_region;
|
||||
let source_balance_account = meta_data.source_balance_account;
|
||||
let brand_id = meta_data.brand_id;
|
||||
let destination_account_number = meta_data.destination_account_number;
|
||||
|
||||
Some(ApiModelMetaData {
|
||||
google_pay,
|
||||
@ -255,6 +257,7 @@ impl DashboardRequestPayload {
|
||||
klarna_region,
|
||||
source_balance_account,
|
||||
brand_id,
|
||||
destination_account_number,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1168,6 +1168,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
||||
api_key="key"
|
||||
[mifinity.metadata]
|
||||
brand_id="Brand ID"
|
||||
destination_account_number="Destination Account Number"
|
||||
|
||||
[mollie]
|
||||
[[mollie.credit]]
|
||||
|
||||
@ -973,6 +973,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
||||
api_key="key"
|
||||
[mifinity.metadata]
|
||||
brand_id="Brand ID"
|
||||
destination_account_number="Destination Account Number"
|
||||
|
||||
|
||||
[mollie]
|
||||
|
||||
@ -1168,6 +1168,7 @@ klarna_region=["Europe","NorthAmerica","Oceania"]
|
||||
api_key="key"
|
||||
[mifinity.metadata]
|
||||
brand_id="Brand ID"
|
||||
destination_account_number="Destination Account Number"
|
||||
|
||||
[mollie]
|
||||
[[mollie.credit]]
|
||||
|
||||
@ -117,7 +117,6 @@ pub enum WalletData {
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct MifinityData {
|
||||
pub destination_account_number: Secret<String>,
|
||||
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::Mifinity(mifinity_data) => {
|
||||
Self::Mifinity(MifinityData {
|
||||
destination_account_number: mifinity_data.destination_account_number,
|
||||
date_of_birth: mifinity_data.date_of_birth,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use common_utils::pii::{self, Email};
|
||||
use error_stack::ResultExt;
|
||||
use masking::{ExposeInterface, Secret};
|
||||
use masking::Secret;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::Date;
|
||||
|
||||
use crate::{
|
||||
connector::utils::{self, PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData},
|
||||
core::errors::{self, CustomResult},
|
||||
core::errors,
|
||||
services,
|
||||
types::{self, api, domain, storage::enums},
|
||||
};
|
||||
@ -36,6 +36,7 @@ pub mod auth_headers {
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct MifinityConnectorMetadataObject {
|
||||
pub brand_id: Secret<String>,
|
||||
pub destination_account_number: Secret<String>,
|
||||
}
|
||||
|
||||
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)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MifinityPaymentsRequest {
|
||||
@ -103,6 +96,11 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin
|
||||
fn try_from(
|
||||
item: &MifinityRouterData<&types::PaymentsAuthorizeRouterData>,
|
||||
) -> 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() {
|
||||
domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data {
|
||||
domain::WalletData::Mifinity(data) => {
|
||||
@ -135,10 +133,9 @@ impl TryFrom<&MifinityRouterData<&types::PaymentsAuthorizeRouterData>> for Mifin
|
||||
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 brand_id =
|
||||
Secret::new(get_brand_id(&item.router_data.connector_meta_data)?);
|
||||
let brand_id = metadata.brand_id;
|
||||
Ok(Self {
|
||||
money,
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user