Skip to content

Commit 6b9d025

Browse files
Chikke SrujanChikke Srujan
authored andcommitted
add support for 3ds mandates
1 parent 99dc851 commit 6b9d025

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ pub struct FiuuPaymentRequest {
271271
signature: Secret<String>,
272272
#[serde(rename = "ReturnURL")]
273273
return_url: Option<String>,
274+
#[serde(rename = "NotificationURL")]
275+
notification_url: Option<Url>,
274276
#[serde(flatten)]
275277
payment_method_data: FiuuPaymentMethodData,
276278
}
@@ -401,6 +403,10 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque
401403
false => 1,
402404
true => 0,
403405
};
406+
let notification_url = Some(
407+
Url::parse(&item.router_data.request.get_webhook_url()?)
408+
.change_context(errors::ConnectorError::RequestEncodingFailed)?,
409+
);
404410
let payment_method_data = match item.router_data.request.payment_method_data {
405411
PaymentMethodData::Card(ref card) => {
406412
FiuuPaymentMethodData::try_from((card, item.router_data))
@@ -530,6 +536,7 @@ impl TryFrom<&FiuuRouterData<&PaymentsAuthorizeRouterData>> for FiuuPaymentReque
530536
return_url,
531537
payment_method_data,
532538
signature,
539+
notification_url,
533540
})
534541
}
535542
}
@@ -714,7 +721,7 @@ pub struct NonThreeDSResponseData {
714721
pub error_desc: Option<String>,
715722
}
716723

717-
#[derive(Debug, Serialize, Deserialize)]
724+
#[derive(Debug, Serialize, Deserialize, Clone)]
718725
pub struct ExtraParameters {
719726
token: Option<Secret<String>>,
720727
}
@@ -1162,6 +1169,27 @@ impl TryFrom<PaymentsSyncResponseRouterData<FiuuPaymentResponse>> for PaymentsSy
11621169
capture_method: item.data.request.capture_method,
11631170
status: response.status,
11641171
})?;
1172+
let mandate_reference = response.extra_parameters.as_ref().and_then(|extra_p| {
1173+
let mandate_token: Result<ExtraParameters, _> = serde_json::from_str(extra_p);
1174+
match mandate_token {
1175+
Ok(token) => {
1176+
token.token.as_ref().map(|token| MandateReference {
1177+
connector_mandate_id: Some(token.clone().expose()),
1178+
payment_method_id: None,
1179+
mandate_metadata: None,
1180+
})
1181+
}
1182+
Err(err) => {
1183+
router_env::logger::warn!(
1184+
"Failed to convert 'extraP' from fiuu webhook response to fiuu::ExtraParameters. \
1185+
Input: '{}', Error: {}",
1186+
extra_p,
1187+
err
1188+
);
1189+
None
1190+
}
1191+
}
1192+
});
11651193
let error_response = if status == enums::AttemptStatus::Failure {
11661194
Some(ErrorResponse {
11671195
status_code: item.http_code,
@@ -1183,7 +1211,7 @@ impl TryFrom<PaymentsSyncResponseRouterData<FiuuPaymentResponse>> for PaymentsSy
11831211
let payments_response_data = PaymentsResponseData::TransactionResponse {
11841212
resource_id: item.data.request.connector_transaction_id.clone(),
11851213
redirection_data: None,
1186-
mandate_reference: None,
1214+
mandate_reference,
11871215
connector_metadata: None,
11881216
network_txn_id: None,
11891217
connector_response_reference_id: None,
@@ -1636,6 +1664,8 @@ pub struct FiuuWebhooksPaymentResponse {
16361664
pub channel: String,
16371665
pub error_desc: Option<String>,
16381666
pub error_code: Option<String>,
1667+
#[serde(rename = "extraP")]
1668+
pub extra_parameters: Option<String>,
16391669
}
16401670

16411671
#[derive(Debug, Deserialize, Serialize, Clone)]

0 commit comments

Comments
 (0)