Skip to content

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

Fix(connector): [BOA/CYBS] make rsync status optional (#4570)

AkshayaFoiger339da8b0c9a1
diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs
index 2d7b230703..2535cfaedb 100644
--- a/crates/router/src/connector/bankofamerica/transformers.rs
+++ b/crates/router/src/connector/bankofamerica/transformers.rs
@@ -2644,9 +2644,16 @@ pub struct RsyncApplicationInformation {
status: BankofamericaRefundStatus,
}
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum BankOfAmericaRsyncResponse {
+ RsyncApplicationResponse(Box<BankOfAmericaRsyncApplicationResponse>),
+ ErrorInformation(BankOfAmericaErrorInformationResponse),
+}
+
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct BankOfAmericaRsyncResponse {
+pub struct BankOfAmericaRsyncApplicationResponse {
id: String,
application_information: RsyncApplicationInformation,
}
@@ -2658,15 +2665,25 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, BankOfAmericaRsyncResp
fn try_from(
item: types::RefundsResponseRouterData<api::RSync, BankOfAmericaRsyncResponse>,
) -> Result<Self, Self::Error> {
- Ok(Self {
- response: Ok(types::RefundsResponseData {
- connector_refund_id: item.response.id,
- refund_status: enums::RefundStatus::from(
- item.response.application_information.status,
- ),
+ match item.response {
+ BankOfAmericaRsyncResponse::RsyncApplicationResponse(rsync_response) => Ok(Self {
+ response: Ok(types::RefundsResponseData {
+ connector_refund_id: rsync_response.id,
+ refund_status: enums::RefundStatus::from(
+ rsync_response.application_information.status,
+ ),
+ }),
+ ..item.data
}),
- ..item.data
- })
+ BankOfAmericaRsyncResponse::ErrorInformation(error_response) => Ok(Self {
+ status: item.data.status,
+ response: Ok(types::RefundsResponseData {
+ refund_status: common_enums::RefundStatus::Pending,
+ connector_refund_id: error_response.id.clone(),
+ }),
+ ..item.data
+ }),
+ }
}
}
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index 545ee672ed..fc1e3a6597 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -2742,11 +2742,18 @@ pub struct RsyncApplicationInformation {
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct CybersourceRsyncResponse {
+pub struct CybersourceRsyncApplicationResponse {
id: String,
application_information: RsyncApplicationInformation,
}
+#[derive(Debug, Deserialize, Serialize)]
+#[serde(untagged)]
+pub enum CybersourceRsyncResponse {
+ RsyncApplicationResponse(Box<CybersourceRsyncApplicationResponse>),
+ ErrorInformation(CybersourceErrorInformationResponse),
+}
+
impl TryFrom<types::RefundsResponseRouterData<api::RSync, CybersourceRsyncResponse>>
for types::RefundsRouterData<api::RSync>
{
@@ -2754,15 +2761,25 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, CybersourceRsyncRespon
fn try_from(
item: types::RefundsResponseRouterData<api::RSync, CybersourceRsyncResponse>,
) -> Result<Self, Self::Error> {
- Ok(Self {
- response: Ok(types::RefundsResponseData {
- connector_refund_id: item.response.id,
- refund_status: enums::RefundStatus::from(
- item.response.application_information.status,
- ),
+ match item.response {
+ CybersourceRsyncResponse::RsyncApplicationResponse(rsync_reponse) => Ok(Self {
+ response: Ok(types::RefundsResponseData {
+ connector_refund_id: rsync_reponse.id,
+ refund_status: enums::RefundStatus::from(
+ rsync_reponse.application_information.status,
+ ),
+ }),
+ ..item.data
}),
- ..item.data
- })
+ CybersourceRsyncResponse::ErrorInformation(error_response) => Ok(Self {
+ status: item.data.status,
+ response: Ok(types::RefundsResponseData {
+ refund_status: common_enums::RefundStatus::Pending,
+ connector_refund_id: error_response.id.clone(),
+ }),
+ ..item.data
+ }),
+ }
}
}