Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(connector): [Loonio] add customer_info in psync response (#10125)
Swangi Kumari359fcc05c684
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 1da9cce90e..a364f69db7 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -11842,6 +11842,14 @@}],"nullable": true+ },+ "interac": {+ "allOf": [+ {+ "$ref": "#/components/schemas/InteracPaymentMethod"+ }+ ],+ "nullable": true}}}@@ -19745,6 +19753,15 @@}}},+ "InteracPaymentMethod": {+ "type": "object",+ "properties": {+ "customer_info": {+ "type": "object",+ "nullable": true+ }+ }+ },"Invoice": {"type": "object","required": [diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 256315c7a7..dd73ed4169 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -6802,6 +6802,14 @@}],"nullable": true+ },+ "interac": {+ "allOf": [+ {+ "$ref": "#/components/schemas/InteracPaymentMethod"+ }+ ],+ "nullable": true}}}@@ -13676,6 +13684,15 @@}}},+ "InteracPaymentMethod": {+ "type": "object",+ "properties": {+ "customer_info": {+ "type": "object",+ "nullable": true+ }+ }+ },"JCSVoucherData": {"type": "object","properties": {diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 6c47c6505a..4b0c54ee69 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -3284,6 +3284,7 @@ pub enum AdditionalPaymentData {bank_name: Option<common_enums::BankNames>,#[serde(flatten)]details: Option<additional_info::BankRedirectDetails>,+ interac: Option<InteracPaymentMethod>,},Wallet {apple_pay: Option<ApplepayPaymentMethod>,@@ -3355,6 +3356,12 @@ pub struct KlarnaSdkPaymentMethod {pub payment_type: Option<String>,}+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]+pub struct InteracPaymentMethod {+ #[schema(value_type = Option<Object>)]+ pub customer_info: Option<pii::SecretSerdeValue>,+}+#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]#[serde(rename_all = "snake_case")]pub enum BankRedirectData {@@ -4641,6 +4648,9 @@ pub struct BankRedirectResponse {#[serde(flatten)]#[schema(value_type = Option<BankRedirectDetails>)]pub details: Option<additional_info::BankRedirectDetails>,+ /// customer info for interac payment method+ #[schema(value_type = Option<InteracPaymentMethod>)]+ pub interac: Option<InteracPaymentMethod>,}#[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, ToSchema)]@@ -7159,9 +7169,15 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {})),_ => Self::Wallet(Box::new(WalletResponse { details: None })),},- AdditionalPaymentData::BankRedirect { bank_name, details } => {- Self::BankRedirect(Box::new(BankRedirectResponse { bank_name, details }))- }+ AdditionalPaymentData::BankRedirect {+ bank_name,+ details,+ interac,+ } => Self::BankRedirect(Box::new(BankRedirectResponse {+ bank_name,+ details,+ interac,+ })),AdditionalPaymentData::Crypto { details } => {Self::Crypto(Box::new(CryptoResponse { details }))}diff --git a/crates/hyperswitch_connectors/src/connectors/loonio/transformers.rs b/crates/hyperswitch_connectors/src/connectors/loonio/transformers.rsindex 23ae229e30..7e611d51d2 100644--- a/crates/hyperswitch_connectors/src/connectors/loonio/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/loonio/transformers.rs@@ -4,10 +4,18 @@ use std::collections::HashMap;use api_models::payouts::{BankRedirect, PayoutMethodData};use api_models::webhooks;use common_enums::{enums, Currency};-use common_utils::{id_type, pii::Email, request::Method, types::FloatMajorUnit};+use common_utils::{+ id_type,+ pii::{self, Email},+ request::Method,+ types::FloatMajorUnit,+};use hyperswitch_domain_models::{payment_method_data::{BankRedirectData, PaymentMethodData},- router_data::{ConnectorAuthType, RouterData},+ router_data::{+ AdditionalPaymentMethodConnectorResponse, ConnectorAuthType, ConnectorResponseData,+ InteracCustomerInfo, RouterData,+ },router_flow_types::refunds::{Execute, RSync},router_request_types::ResponseId,router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},@@ -208,6 +216,7 @@ impl From<LoonioTransactionStatus> for enums::AttemptStatus {pub struct LoonioTransactionSyncResponse {pub transaction_id: String,pub state: LoonioTransactionStatus,+ pub customer_bank_info: Option<pii::SecretSerdeValue>,}#[derive(Default, Debug, Serialize)]@@ -232,22 +241,49 @@ impl<F, T> TryFrom<ResponseRouterData<F, LoonioPaymentResponseData, T, PaymentsRitem: ResponseRouterData<F, LoonioPaymentResponseData, T, PaymentsResponseData>,) -> Result<Self, Self::Error> {match item.response {- LoonioPaymentResponseData::Sync(sync_response) => Ok(Self {- status: enums::AttemptStatus::from(sync_response.state),- response: Ok(PaymentsResponseData::TransactionResponse {- resource_id: ResponseId::ConnectorTransactionId(sync_response.transaction_id),- redirection_data: Box::new(None),- mandate_reference: Box::new(None),- connector_metadata: None,- network_txn_id: None,- connector_response_reference_id: None,- incremental_authorization_allowed: None,- charges: None,- }),- ..item.data- }),+ LoonioPaymentResponseData::Sync(sync_response) => {+ let connector_response =+ sync_response+ .customer_bank_info+ .as_ref()+ .map(|customer_info| {+ ConnectorResponseData::with_additional_payment_method_data(+ AdditionalPaymentMethodConnectorResponse::BankRedirect {+ interac: Some(InteracCustomerInfo {+ customer_info: Some(customer_info.clone()),+ }),+ },+ )+ });+ Ok(Self {+ status: enums::AttemptStatus::from(sync_response.state),+ response: Ok(PaymentsResponseData::TransactionResponse {+ resource_id: ResponseId::ConnectorTransactionId(+ sync_response.transaction_id,+ ),+ redirection_data: Box::new(None),+ mandate_reference: Box::new(None),+ connector_metadata: None,+ network_txn_id: None,+ connector_response_reference_id: None,+ incremental_authorization_allowed: None,+ charges: None,+ }),+ connector_response,+ ..item.data+ })+ }LoonioPaymentResponseData::Webhook(webhook_body) => {let payment_status = enums::AttemptStatus::from(&webhook_body.event_code);+ let connector_response = webhook_body.customer_info.as_ref().map(|customer_info| {+ ConnectorResponseData::with_additional_payment_method_data(+ AdditionalPaymentMethodConnectorResponse::BankRedirect {+ interac: Some(InteracCustomerInfo {+ customer_info: Some(customer_info.clone()),+ }),+ },+ )+ });Ok(Self {status: payment_status,response: Ok(PaymentsResponseData::TransactionResponse {@@ -262,6 +298,7 @@ impl<F, T> TryFrom<ResponseRouterData<F, LoonioPaymentResponseData, T, PaymentsRincremental_authorization_allowed: None,charges: None,}),+ connector_response,..item.data})}@@ -379,6 +416,7 @@ pub struct LoonioWebhookBody {pub id: i32,#[serde(rename = "type")]pub transaction_type: LoonioWebhookTransactionType,+ pub customer_info: Option<pii::SecretSerdeValue>,}#[derive(Debug, Serialize, Deserialize)]diff --git a/crates/hyperswitch_domain_models/src/router_data.rs b/crates/hyperswitch_domain_models/src/router_data.rsindex 1d4ac813af..00ba26df20 100644--- a/crates/hyperswitch_domain_models/src/router_data.rs+++ b/crates/hyperswitch_domain_models/src/router_data.rs@@ -675,6 +675,9 @@ pub enum AdditionalPaymentMethodConnectorResponse {PayLater {klarna_sdk: Option<KlarnaSdkResponse>,},+ BankRedirect {+ interac: Option<InteracCustomerInfo>,+ },}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -690,6 +693,11 @@ pub struct KlarnaSdkResponse {pub payment_type: Option<String>,}+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct InteracCustomerInfo {+ pub customer_info: Option<common_utils::pii::SecretSerdeValue>,+}+#[derive(Clone, Debug, Serialize)]pub struct ErrorResponse {pub code: String,diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex ee545a8acd..581e6fb145 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -818,6 +818,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::OpenBankingSessionToken,api_models::payments::BankDebitResponse,api_models::payments::BankRedirectResponse,+ api_models::payments::InteracPaymentMethod,api_models::payments::BankTransferResponse,api_models::payments::CardRedirectResponse,api_models::payments::CardTokenResponse,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex d1c78498e2..a057a99d8f 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -776,6 +776,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::OpenBankingSessionToken,api_models::payments::BankDebitResponse,api_models::payments::BankRedirectResponse,+ api_models::payments::InteracPaymentMethod,api_models::payments::BankTransferResponse,api_models::payments::CardRedirectResponse,api_models::payments::CardTokenResponse,diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 8749538998..80f0c19d09 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -44,7 +44,7 @@ use hyperswitch_domain_models::{self as domain_payments, payment_attempt::PaymentAttempt,payment_intent::PaymentIntentFetchConstraints, PaymentIntent,},- router_data::KlarnaSdkResponse,+ router_data::{InteracCustomerInfo, KlarnaSdkResponse},};pub use hyperswitch_interfaces::{api::ConnectorSpecifications,@@ -5202,24 +5202,28 @@ pub async fn get_additional_payment_data(api_models::payments::AdditionalPaymentData::BankRedirect {bank_name: bank_name.to_owned(),details: None,+ interac: None,},)),domain::BankRedirectData::Eft { .. } => Ok(Some(api_models::payments::AdditionalPaymentData::BankRedirect {bank_name: None,details: None,+ interac: None,},)),domain::BankRedirectData::OnlineBankingFpx { issuer } => Ok(Some(api_models::payments::AdditionalPaymentData::BankRedirect {bank_name: Some(issuer.to_owned()),details: None,+ interac: None,},)),domain::BankRedirectData::Ideal { bank_name, .. } => Ok(Some(api_models::payments::AdditionalPaymentData::BankRedirect {bank_name: bank_name.to_owned(),details: None,+ interac: None,},)),domain::BankRedirectData::BancontactCard {@@ -5240,6 +5244,7 @@ pub async fn get_additional_payment_data(},)),),+ interac: None,},)),domain::BankRedirectData::Blik { blik_code } => Ok(Some(@@ -5252,6 +5257,7 @@ pub async fn get_additional_payment_data(},))}),+ interac: None,},)),domain::BankRedirectData::Giropay {@@ -5274,12 +5280,14 @@ pub async fn get_additional_payment_data(},),)),+ interac: None,},)),_ => Ok(Some(api_models::payments::AdditionalPaymentData::BankRedirect {bank_name: None,details: None,+ interac: None,},)),},@@ -7019,6 +7027,16 @@ pub fn add_connector_response_to_additional_payment_data() => api_models::payments::AdditionalPaymentData::PayLater {klarna_sdk: Some(api_models::payments::KlarnaSdkPaymentMethod { payment_type }),},+ (+ api_models::payments::AdditionalPaymentData::BankRedirect { .. },+ AdditionalPaymentMethodConnectorResponse::BankRedirect {+ interac: Some(InteracCustomerInfo { customer_info }),+ },+ ) => api_models::payments::AdditionalPaymentData::BankRedirect {+ bank_name: None,+ details: None,+ interac: Some(api_models::payments::InteracPaymentMethod { customer_info }),+ },_ => additional_payment_data,}