feat(connector): [Recurly] add invoice sync support along with transaction monitoring (#7867)

Co-authored-by: Nishanth Challa <nishanth.challa@Nishanth-Challa-C0WGKCFHLF.local>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
This commit is contained in:
CHALLA NISHANTH BABU
2025-05-02 17:10:48 +05:30
committed by GitHub
parent af5e56ef9d
commit bcc57ebb2d
31 changed files with 824 additions and 1168 deletions

View File

@ -20,6 +20,7 @@ use hyperswitch_domain_models::{
use crate::connector_integration_v2::ConnectorIntegrationV2;
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
/// trait RevenueRecoveryV2
pub trait RevenueRecoveryV2:
BillingConnectorPaymentsSyncIntegrationV2
@ -28,6 +29,10 @@ pub trait RevenueRecoveryV2:
{
}
#[cfg(not(all(feature = "v2", feature = "revenue_recovery")))]
/// trait RevenueRecoveryV2
pub trait RevenueRecoveryV2 {}
/// trait BillingConnectorPaymentsSyncIntegrationV2
pub trait BillingConnectorPaymentsSyncIntegrationV2:
ConnectorIntegrationV2<

View File

@ -9,9 +9,10 @@ use hyperswitch_domain_models::{
router_data::{self, RouterData},
router_data_v2::{
flow_common_types::{
AccessTokenFlowData, BillingConnectorPaymentsSyncFlowData, DisputesFlowData,
ExternalAuthenticationFlowData, FilesFlowData, MandateRevokeFlowData, PaymentFlowData,
RefundFlowData, RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData,
AccessTokenFlowData, BillingConnectorInvoiceSyncFlowData,
BillingConnectorPaymentsSyncFlowData, DisputesFlowData, ExternalAuthenticationFlowData,
FilesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData,
RevenueRecoveryRecordBackData, UasFlowData, WebhookSourceVerifyData,
},
RouterDataV2,
},
@ -840,3 +841,42 @@ impl<T, Req: Clone, Resp: Clone> RouterDataConversion<T, Req, Resp>
})
}
}
impl<T, Req: Clone, Resp: Clone> RouterDataConversion<T, Req, Resp>
for BillingConnectorInvoiceSyncFlowData
{
fn from_old_router_data(
old_router_data: &RouterData<T, Req, Resp>,
) -> CustomResult<RouterDataV2<T, Self, Req, Resp>, ConnectorError>
where
Self: Sized,
{
let resource_common_data = Self {};
Ok(RouterDataV2 {
flow: std::marker::PhantomData,
tenant_id: old_router_data.tenant_id.clone(),
resource_common_data,
connector_auth_type: old_router_data.connector_auth_type.clone(),
request: old_router_data.request.clone(),
response: old_router_data.response.clone(),
})
}
fn to_old_router_data(
new_router_data: RouterDataV2<T, Self, Req, Resp>,
) -> CustomResult<RouterData<T, Req, Resp>, ConnectorError>
where
Self: Sized,
{
let router_data = get_default_router_data(
new_router_data.tenant_id.clone(),
"BillingConnectorInvoiceSync",
new_router_data.request,
new_router_data.response,
);
Ok(RouterData {
connector_auth_type: new_router_data.connector_auth_type.clone(),
..router_data
})
}
}

View File

@ -2,6 +2,7 @@
use hyperswitch_domain_models::{
router_data::AccessToken,
router_data_v2::flow_common_types,
router_flow_types::{
access_token_auth::AccessTokenAuth,
dispute::{Accept, Defend, Evidence},
@ -61,7 +62,7 @@ use hyperswitch_domain_models::{
router_response_types::PayoutsResponseData,
};
use crate::api::ConnectorIntegration;
use crate::{api::ConnectorIntegration, connector_integration_v2::ConnectorIntegrationV2};
/// struct Response
#[derive(Clone, Debug)]
pub struct Response {
@ -257,3 +258,27 @@ pub type BillingConnectorInvoiceSyncType = dyn ConnectorIntegration<
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>;
/// Type alias for `ConnectorIntegrationV2<RecoveryRecordBack, RevenueRecoveryRecordBackData, RevenueRecoveryRecordBackRequest, RevenueRecoveryRecordBackResponse>`
pub type RevenueRecoveryRecordBackTypeV2 = dyn ConnectorIntegrationV2<
RecoveryRecordBack,
flow_common_types::RevenueRecoveryRecordBackData,
RevenueRecoveryRecordBackRequest,
RevenueRecoveryRecordBackResponse,
>;
/// Type alias for `ConnectorIntegrationV2<BillingConnectorPaymentsSync, BillingConnectorPaymentsSyncRequest, BillingConnectorPaymentsSyncResponse>`
pub type BillingConnectorPaymentsSyncTypeV2 = dyn ConnectorIntegrationV2<
BillingConnectorPaymentsSync,
flow_common_types::BillingConnectorPaymentsSyncFlowData,
BillingConnectorPaymentsSyncRequest,
BillingConnectorPaymentsSyncResponse,
>;
/// Type alias for `ConnectorIntegrationV2<BillingConnectorInvoiceSync, BillingConnectorInvoiceSyncFlowData, BillingConnectorInvoiceSyncRequest, BillingConnectorInvoiceSyncResponse>`
pub type BillingConnectorInvoiceSyncTypeV2 = dyn ConnectorIntegrationV2<
BillingConnectorInvoiceSync,
flow_common_types::BillingConnectorInvoiceSyncFlowData,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>;

View File

@ -304,16 +304,4 @@ pub trait IncomingWebhook: ConnectorCommon + Sync {
)
.into())
}
/// get billing address for invoice if present in the webhook
#[cfg(all(feature = "revenue_recovery", feature = "v2"))]
fn get_billing_address_for_invoice(
&self,
_request: &IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::payments::Address, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented(
"get_billing_address_for_invoice method".to_string(),
)
.into())
}
}