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

feat(connector): [fiuu] Add support for payment and refund webhooks (#6315)

chikke srujand04a87be9e76
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index f4523cf617..e20054c59b 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -4189,4 +4189,7 @@ label="Payment Processing Details At"
placeholder="Enter Payment Processing Details At"
required=true
type="Radio"
-options=["Connector","Hyperswitch"]
\ No newline at end of file
+options=["Connector","Hyperswitch"]
+
+[fiuu.connector_webhook_details]
+merchant_secret="Source verification key"
\ No newline at end of file
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index e0d83ff57f..e840b0ed55 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -3184,4 +3184,7 @@ label="Payment Processing Details At"
placeholder="Enter Payment Processing Details At"
required=true
type="Radio"
-options=["Connector","Hyperswitch"]
\ No newline at end of file
+options=["Connector","Hyperswitch"]
+
+[fiuu.connector_webhook_details]
+merchant_secret="Source verification key"
\ No newline at end of file
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 80a3af60c4..c694d59195 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -4183,4 +4183,7 @@ label="Payment Processing Details At"
placeholder="Enter Payment Processing Details At"
required=true
type="Radio"
-options=["Connector","Hyperswitch"]
\ No newline at end of file
+options=["Connector","Hyperswitch"]
+
+[fiuu.connector_webhook_details]
+merchant_secret="Source verification key"
\ No newline at end of file
diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs
index c17de26d7e..31d87ceedc 100644
--- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs
+++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs
@@ -4,12 +4,13 @@ use std::collections::HashMap;
use common_enums::{CaptureMethod, PaymentMethodType};
use common_utils::{
+ crypto::{self, GenerateDigest},
errors::{self as common_errors, CustomResult},
- ext_traits::BytesExt,
+ ext_traits::{ByteSliceExt, BytesExt},
request::{Method, Request, RequestBuilder, RequestContent},
types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector},
};
-use error_stack::{report, ResultExt};
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
@@ -36,11 +37,11 @@ use hyperswitch_interfaces::{
types::{self, Response},
webhooks,
};
-use masking::Secret;
+use masking::{ExposeInterface, PeekInterface, Secret};
use reqwest::multipart::Form;
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use transformers as fiuu;
+use transformers::{self as fiuu, FiuuWebhooksResponse};
use crate::{constants::headers, types::ResponseRouterData, utils};
@@ -354,15 +355,44 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Fiu
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
- let response: fiuu::FiuuPaymentSyncResponse = parse_response(&res.response)?;
- event_builder.map(|i| i.set_response_body(&response));
- router_env::logger::info!(connector_response=?response);
-
- RouterData::try_from(ResponseRouterData {
- response,
- data: data.clone(),
- http_code: res.status_code,
- })
+ match res.headers {
+ Some(headers) => {
+ let content_header = utils::get_http_header("Content-type", &headers)
+ .attach_printable("Missing content type in headers")
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+ let response: fiuu::FiuuPaymentResponse = if content_header
+ == "text/plain;charset=UTF-8"
+ {
+ parse_response(&res.response)
+ } else {
+ Err(errors::ConnectorError::ResponseDeserializationFailed)
+ .attach_printable(format!("Expected content type to be text/plain;charset=UTF-8 , but received different content type as {content_header} in response"))?
+ }?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+ }
+ None => {
+ // We don't get headers for payment webhook response handling
+ let response: fiuu::FiuuPaymentResponse = res
+ .response
+ .parse_struct("fiuu::FiuuPaymentResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+ }
+ }
}
fn get_error_response(
@@ -652,24 +682,184 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Fiuu {
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Fiuu {
- fn get_webhook_object_reference_id(
+ fn get_webhook_source_verification_algorithm(
&self,
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Box<dyn crypto::VerifySignature + Send>, errors::ConnectorError> {
+ Ok(Box::new(crypto::Md5))
+ }
+
+ fn get_webhook_source_verification_signature(
+ &self,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,
+ ) -> CustomResult<Vec<u8>, errors::ConnectorError> {
+ let header = utils::get_header_key_value("content-type", request.headers)?;
+ let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
+ serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(request.body)
+ .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
+ } else {
+ request
+ .body
+ .parse_struct("fiuu::FiuuWebhooksResponse")
+ .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
+ };
+
+ let signature = match resource {
+ FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
+ webhooks_payment_response.skey
+ }
+ FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
+ webhooks_refunds_response.signature
+ }
+ };
+ hex::decode(signature.expose())
+ .change_context(errors::ConnectorError::WebhookVerificationSecretInvalid)
+ }
+
+ fn get_webhook_source_verification_message(
+ &self,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ _merchant_id: &common_utils::id_type::MerchantId,
+ connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets,
+ ) -> CustomResult<Vec<u8>, errors::ConnectorError> {
+ let header = utils::get_header_key_value("content-type", request.headers)?;
+ let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
+ serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(request.body)
+ .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
+ } else {
+ request
+ .body
+ .parse_struct("fiuu::FiuuWebhooksResponse")
+ .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?
+ };
+ let verification_message = match resource {
+ FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
+ let key0 = format!(
+ "{}{}{}{}{}{}",
+ webhooks_payment_response.tran_id,
+ webhooks_payment_response.order_id,
+ webhooks_payment_response.status,
+ webhooks_payment_response.domain.clone().peek(),
+ webhooks_payment_response.amount.get_amount_as_string(),
+ webhooks_payment_response.currency
+ );
+ let md5_key0 = hex::encode(
+ crypto::Md5
+ .generate_digest(key0.as_bytes())
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?,
+ );
+ let key1 = format!(
+ "{}{}{}{}{}",
+ webhooks_payment_response.paydate,
+ webhooks_payment_response.domain.peek(),
+ md5_key0,
+ webhooks_payment_response.appcode.peek(),
+ String::from_utf8_lossy(&connector_webhook_secrets.secret)
+ );
+ key1
+ }
+ FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
+ format!(
+ "{}{}{}{}{}{}{}{}",
+ webhooks_refunds_response.refund_type,
+ webhooks_refunds_response.merchant_id.peek(),
+ webhooks_refunds_response.ref_id,
+ webhooks_refunds_response.refund_id,
+ webhooks_refunds_response.txn_id,
+ webhooks_refunds_response.amount.get_amount_as_string(),
+ webhooks_refunds_response.status,
+ String::from_utf8_lossy(&connector_webhook_secrets.secret)
+ )
+ }
+ };
+ Ok(verification_message.as_bytes().to_vec())
+ }
+
+ fn get_webhook_object_reference_id(
+ &self,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let header = utils::get_header_key_value("content-type", request.headers)?;
+ let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
+ serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(request.body)
+ .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?
+ } else {
+ request
+ .body
+ .parse_struct("fiuu::FiuuWebhooksResponse")
+ .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?
+ };
+ let resource_id = match resource {
+ FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => {
+ api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::PaymentAttemptId(
+ webhooks_payment_response.order_id,
+ ),
+ )
+ }
+ FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => {
+ api_models::webhooks::ObjectReferenceId::RefundId(
+ api_models::webhooks::RefundIdType::ConnectorRefundId(
+ webhooks_refunds_response.refund_id,
+ ),
+ )
+ }
+ };
+ Ok(resource_id)
}
fn get_webhook_event_type(
&self,
- _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let header = utils::get_header_key_value("content-type", request.headers)?;
+ let resource: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
+ serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(request.body)
+ .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?
+ } else {
+ request
+ .body
+ .parse_struct("fiuu::FiuuWebhooksResponse")
+ .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?
+ };
+
+ match resource {
+ FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhooks_payment_response) => Ok(
+ api_models::webhooks::IncomingWebhookEvent::from(webhooks_payment_response.status),
+ ),
+ FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhooks_refunds_response) => Ok(
+ api_models::webhooks::IncomingWebhookEvent::from(webhooks_refunds_response.status),
+ ),
+ }
}
fn get_webhook_resource_object(
&self,
- _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let header = utils::get_header_key_value("content-type", request.headers)?;
+ let payload: FiuuWebhooksResponse = if header == "application/x-www-form-urlencoded" {
+ serde_urlencoded::from_bytes::<FiuuWebhooksResponse>(request.body)
+ .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
+ } else {
+ request
+ .body
+ .parse_struct("fiuu::FiuuWebhooksResponse")
+ .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?
+ };
+
+ match payload.clone() {
+ FiuuWebhooksResponse::FiuuWebhookPaymentResponse(webhook_payment_response) => Ok(
+ Box::new(fiuu::FiuuPaymentResponse::FiuuWebhooksPaymentResponse(
+ webhook_payment_response,
+ )),
+ ),
+ FiuuWebhooksResponse::FiuuWebhookRefundResponse(webhook_refund_response) => {
+ Ok(Box::new(fiuu::FiuuRefundSyncResponse::Webhook(
+ webhook_refund_response,
+ )))
+ }
+ }
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
index c06f0a208e..a401af5100 100644
--- a/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs
@@ -27,7 +27,7 @@ use hyperswitch_domain_models::{
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
-use hyperswitch_interfaces::errors;
+use hyperswitch_interfaces::{consts, errors};
use masking::{PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use strum::Display;
@@ -43,7 +43,10 @@ use crate::{
PaymentsSyncResponseRouterData, RefundsResponseRouterData, ResponseRouterData,
},
unimplemented_payment_method,
- utils::{self, ApplePayDecrypt, PaymentsAuthorizeRequestData, QrImage, RouterData as _},
+ utils::{
+ self, ApplePayDecrypt, PaymentsAuthorizeRequestData, QrImage, RefundsRequestData,
+ RouterData as _,
+ },
};
pub struct FiuuRouterData<T> {
@@ -713,6 +716,8 @@ pub struct FiuuRefundRequest {
pub txn_id: String,
pub amount: StringMajorUnit,
pub signature: Secret<String>,
+ #[serde(rename = "notify_url")]
+ pub notify_url: Option<Url>,
}
#[derive(Debug, Serialize, Display)]
pub enum RefundType {
@@ -741,6 +746,10 @@ impl TryFrom<&FiuuRouterData<&RefundsRouterData<Execute>>> for FiuuRefundRequest
RefundType::Partial,
txn_amount.get_amount_as_string()
))?,
+ notify_url: Some(
+ Url::parse(&item.router_data.request.get_webhook_url()?)
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?,
+ ),
})
}
}
@@ -810,6 +819,13 @@ pub struct FiuuPaymentSyncRequest {
skey: Secret<String>,
}
+#[derive(Debug, Serialize, Deserialize, Clone)]
+#[serde(untagged)]
+pub enum FiuuPaymentResponse {
+ FiuuPaymentSyncResponse(FiuuPaymentSyncResponse),
+ FiuuWebhooksPaymentResponse(FiuuWebhooksPaymentResponse),
+}
+
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct FiuuPaymentSyncResponse {
@@ -881,44 +897,109 @@ impl TryFrom<&PaymentsSyncRouterData> for FiuuPaymentSyncRequest {
}
}
-impl TryFrom<PaymentsSyncResponseRouterData<FiuuPaymentSyncResponse>> for PaymentsSyncRouterData {
+impl TryFrom<PaymentsSyncResponseRouterData<FiuuPaymentResponse>> for PaymentsSyncRouterData {
type Error = Report<errors::ConnectorError>;
fn try_from(
- item: PaymentsSyncResponseRouterData<FiuuPaymentSyncResponse>,
+ item: PaymentsSyncResponseRouterData<FiuuPaymentResponse>,
) -> Result<Self, Self::Error> {
- let stat_name = item.response.stat_name;
- let stat_code = item.response.stat_code.clone();
- let status = enums::AttemptStatus::try_from(FiuuSyncStatus {
- stat_name,
- stat_code,
- })?;
- let error_response = if status == enums::AttemptStatus::Failure {
- Some(ErrorResponse {
- status_code: item.http_code,
- code: item.response.stat_code.to_string(),
- message: item.response.stat_name.clone().to_string(),
- reason: Some(item.response.stat_name.clone().to_string()),
- attempt_status: Some(enums::AttemptStatus::Failure),
- connector_transaction_id: None,
- })
- } else {
- None
- };
- let payments_response_data = PaymentsResponseData::TransactionResponse {
- resource_id: item.data.request.connector_transaction_id.clone(),
- redirection_data: None,
- mandate_reference: None,
- connector_metadata: None,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charge_id: None,
- };
- Ok(Self {
- status,
- response: error_response.map_or_else(|| Ok(payments_response_data), Err),
- ..item.data
- })
+ match item.response {
+ FiuuPaymentResponse::FiuuPaymentSyncResponse(response) => {
+ let stat_name = response.stat_name;
+ let stat_code = response.stat_code.clone();
+ let status = enums::AttemptStatus::try_from(FiuuSyncStatus {
+ stat_name,
+ stat_code,
+ })?;
+ let error_response = if status == enums::AttemptStatus::Failure {
+ Some(ErrorResponse {
+ status_code: item.http_code,
+ code: response.stat_code.to_string(),
+ message: response.stat_name.clone().to_string(),
+ reason: Some(response.stat_name.clone().to_string()),
+ attempt_status: Some(enums::AttemptStatus::Failure),
+ connector_transaction_id: None,
+ })
+ } else {
+ None
+ };
+ let payments_response_data = PaymentsResponseData::TransactionResponse {
+ resource_id: item.data.request.connector_transaction_id.clone(),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ };
+ Ok(Self {
+ status,
+ response: error_response.map_or_else(|| Ok(payments_response_data), Err),
+ ..item.data
+ })
+ }
+ FiuuPaymentResponse::FiuuWebhooksPaymentResponse(response) => {
+ let status = enums::AttemptStatus::try_from(FiuuWebhookStatus {
+ capture_method: item.data.request.capture_method,
+ status: response.status,
+ })?;
+ let error_response = if status == enums::AttemptStatus::Failure {
+ Some(ErrorResponse {
+ status_code: item.http_code,
+ code: response
+ .error_code
+ .clone()
+ .unwrap_or(consts::NO_ERROR_CODE.to_owned()),
+ message: response
+ .error_code
+ .clone()
+ .unwrap_or(consts::NO_ERROR_MESSAGE.to_owned()),
+ reason: response.error_desc.clone(),
+ attempt_status: Some(enums::AttemptStatus::Failure),
+ connector_transaction_id: None,
+ })
+ } else {
+ None
+ };
+ let payments_response_data = PaymentsResponseData::TransactionResponse {
+ resource_id: item.data.request.connector_transaction_id.clone(),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ };
+ Ok(Self {
+ status,
+ response: error_response.map_or_else(|| Ok(payments_response_data), Err),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+pub struct FiuuWebhookStatus {
+ pub capture_method: Option<CaptureMethod>,
+ pub status: FiuuPaymentWebhookStatus,
+}
+
+impl TryFrom<FiuuWebhookStatus> for enums::AttemptStatus {
+ type Error = Report<errors::ConnectorError>;
+ fn try_from(webhook_status: FiuuWebhookStatus) -> Result<Self, Self::Error> {
+ match webhook_status.status {
+ FiuuPaymentWebhookStatus::Success => match webhook_status.capture_method {
+ Some(CaptureMethod::Automatic) => Ok(Self::Charged),
+ Some(CaptureMethod::Manual) => Ok(Self::Authorized),
+ _ => Err(errors::ConnectorError::UnexpectedResponseError(
+ bytes::Bytes::from(webhook_status.status.to_string()),
+ ))?,
+ },
+ FiuuPaymentWebhookStatus::Failure => Ok(Self::Failure),
+ FiuuPaymentWebhookStatus::Pending => Ok(Self::AuthenticationPending),
+ }
}
}
@@ -1210,6 +1291,7 @@ impl TryFrom<&RefundSyncRouterData> for FiuuRefundSyncRequest {
pub enum FiuuRefundSyncResponse {
Success(Vec<RefundData>),
Error(FiuuErrorResponse),
+ Webhook(FiuuWebhooksRefundResponse),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -1264,6 +1346,15 @@ impl TryFrom<RefundsResponseRouterData<RSync, FiuuRefundSyncResponse>>
..item.data
})
}
+ FiuuRefundSyncResponse::Webhook(fiuu_webhooks_refund_response) => Ok(Self {
+ response: Ok(RefundsResponseData {
+ connector_refund_id: fiuu_webhooks_refund_response.refund_id,
+ refund_status: enums::RefundStatus::from(
+ fiuu_webhooks_refund_response.status.clone(),
+ ),
+ }),
+ ..item.data
+ }),
}
}
}
@@ -1301,3 +1392,132 @@ pub fn get_qr_metadata(
Ok(None)
}
}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+#[serde(untagged)]
+pub enum FiuuWebhooksResponse {
+ FiuuWebhookPaymentResponse(FiuuWebhooksPaymentResponse),
+ FiuuWebhookRefundResponse(FiuuWebhooksRefundResponse),
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+pub struct FiuuWebhooksPaymentResponse {
+ pub skey: Secret<String>,
+ pub status: FiuuPaymentWebhookStatus,
+ #[serde(rename = "orderid")]
+ pub order_id: String,
+ #[serde(rename = "tranID")]
+ pub tran_id: String,
+ pub nbcb: String,
+ pub amount: StringMajorUnit,
+ pub currency: String,
+ pub domain: Secret<String>,
+ pub appcode: Secret<String>,
+ pub paydate: String,
+ pub channel: String,
+ pub error_desc: Option<String>,
+ pub error_code: Option<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+#[serde(rename_all = "PascalCase")]
+pub struct FiuuWebhooksRefundResponse {
+ pub refund_type: FiuuWebhooksRefundType,
+ #[serde(rename = "MerchantID")]
+ pub merchant_id: Secret<String>,
+ #[serde(rename = "RefID")]
+ pub ref_id: String,
+ #[serde(rename = "RefundID")]
+ pub refund_id: String,
+ #[serde(rename = "TxnID")]
+ pub txn_id: String,
+ pub amount: StringMajorUnit,
+ pub status: FiuuRefundsWebhookStatus,
+ pub signature: Secret<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, strum::Display)]
+pub enum FiuuRefundsWebhookStatus {
+ #[strum(serialize = "00")]
+ #[serde(rename = "00")]
+ RefundSuccess,
+ #[strum(serialize = "11")]
+ #[serde(rename = "11")]
+ RefundFailure,
+ #[strum(serialize = "22")]
+ #[serde(rename = "22")]
+ RefundPending,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, strum::Display)]
+pub enum FiuuWebhooksRefundType {
+ P,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+pub struct FiuuWebhookSignauture {
+ pub skey: Secret<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+pub struct FiuuWebhookResourceId {
+ pub skey: Secret<String>,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone)]
+pub struct FiuWebhookEvent {
+ pub status: FiuuPaymentWebhookStatus,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, strum::Display)]
+pub enum FiuuPaymentWebhookStatus {
+ #[strum(serialize = "00")]
+ #[serde(rename = "00")]
+ Success,
+ #[strum(serialize = "11")]
+ #[serde(rename = "11")]
+ Failure,
+ #[strum(serialize = "22")]
+ #[serde(rename = "22")]
+ Pending,
+}
+
+impl From<FiuuPaymentWebhookStatus> for StatCode {
+ fn from(value: FiuuPaymentWebhookStatus) -> Self {
+ match value {
+ FiuuPaymentWebhookStatus::Success => Self::Success,
+ FiuuPaymentWebhookStatus::Failure => Self::Failure,
+ FiuuPaymentWebhookStatus::Pending => Self::Pending,
+ }
+ }
+}
+
+impl From<FiuuPaymentWebhookStatus> for api_models::webhooks::IncomingWebhookEvent {
+ fn from(value: FiuuPaymentWebhookStatus) -> Self {
+ match value {
+ FiuuPaymentWebhookStatus::Success => Self::PaymentIntentSuccess,
+ FiuuPaymentWebhookStatus::Failure => Self::PaymentIntentFailure,
+ FiuuPaymentWebhookStatus::Pending => Self::PaymentIntentProcessing,
+ }
+ }
+}
+
+impl From<FiuuRefundsWebhookStatus> for api_models::webhooks::IncomingWebhookEvent {
+ fn from(value: FiuuRefundsWebhookStatus) -> Self {
+ match value {
+ FiuuRefundsWebhookStatus::RefundSuccess => Self::RefundSuccess,
+ FiuuRefundsWebhookStatus::RefundFailure => Self::RefundFailure,
+ FiuuRefundsWebhookStatus::RefundPending => Self::EventNotSupported,
+ }
+ }
+}
+
+impl From<FiuuRefundsWebhookStatus> for enums::RefundStatus {
+ fn from(value: FiuuRefundsWebhookStatus) -> Self {
+ match value {
+ FiuuRefundsWebhookStatus::RefundFailure => Self::Failure,
+ FiuuRefundsWebhookStatus::RefundSuccess => Self::Success,
+ FiuuRefundsWebhookStatus::RefundPending => Self::Pending,
+ }
+ }
+}