feat(core): Adds Billing Connector Invoice Sync flow in Revenue Recovery (#7799)

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>
This commit is contained in:
CHALLA NISHANTH BABU
2025-04-29 12:25:31 +05:30
committed by GitHub
parent 600137275f
commit 3d0dd5bd1a
14 changed files with 294 additions and 34 deletions

View File

@ -4520,3 +4520,109 @@ default_imp_for_revenue_recovery_record_back!(
connectors::Zen,
connectors::Zsl
);
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
macro_rules! default_imp_for_billing_connector_invoice_sync {
($($path:ident::$connector:ident),*) => {
$( impl recovery_traits::BillingConnectorInvoiceSyncIntegration for $path::$connector {}
impl
ConnectorIntegration<
recovery_router_flows::BillingConnectorInvoiceSync,
recovery_request::BillingConnectorInvoiceSyncRequest,
recovery_response::BillingConnectorInvoiceSyncResponse
> for $path::$connector
{}
)*
};
}
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
default_imp_for_billing_connector_invoice_sync!(
connectors::Aci,
connectors::Adyen,
connectors::Airwallex,
connectors::Amazonpay,
connectors::Authorizedotnet,
connectors::Bambora,
connectors::Bamboraapac,
connectors::Bankofamerica,
connectors::Billwerk,
connectors::Bluesnap,
connectors::Bitpay,
connectors::Braintree,
connectors::Boku,
connectors::Cashtocode,
connectors::Chargebee,
connectors::Checkout,
connectors::Coinbase,
connectors::Coingate,
connectors::Cryptopay,
connectors::CtpMastercard,
connectors::Cybersource,
connectors::Datatrans,
connectors::Deutschebank,
connectors::Digitalvirgo,
connectors::Dlocal,
connectors::Elavon,
connectors::Facilitapay,
connectors::Fiserv,
connectors::Fiservemea,
connectors::Fiuu,
connectors::Forte,
connectors::Getnet,
connectors::Globalpay,
connectors::Globepay,
connectors::Gocardless,
connectors::Helcim,
connectors::Hipay,
connectors::Iatapay,
connectors::Inespay,
connectors::Itaubank,
connectors::Juspaythreedsserver,
connectors::Jpmorgan,
connectors::Klarna,
connectors::Nomupay,
connectors::Nmi,
connectors::Noon,
connectors::Novalnet,
connectors::Nexinets,
connectors::Nexixpay,
connectors::Nuvei,
connectors::Opayo,
connectors::Opennode,
connectors::Payeezy,
connectors::Paystack,
connectors::Payu,
connectors::Paypal,
connectors::Powertranz,
connectors::Prophetpay,
connectors::Mifinity,
connectors::Mollie,
connectors::Moneris,
connectors::Multisafepay,
connectors::Paybox,
connectors::Payme,
connectors::Payone,
connectors::Placetopay,
connectors::Rapyd,
connectors::Razorpay,
connectors::Recurly,
connectors::Redsys,
connectors::Riskified,
connectors::Shift4,
connectors::Stax,
connectors::Square,
connectors::Stripebilling,
connectors::Taxjar,
connectors::Thunes,
connectors::Trustpay,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
connectors::Worldline,
connectors::Worldpay,
connectors::Wellsfargo,
connectors::Volt,
connectors::Xendit,
connectors::Zen,
connectors::Zsl
);

View File

@ -2,9 +2,9 @@ use hyperswitch_domain_models::{
router_data::AccessToken,
router_data_v2::{
flow_common_types::{
BillingConnectorPaymentsSyncFlowData, DisputesFlowData, MandateRevokeFlowData,
PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData,
WebhookSourceVerifyData,
BillingConnectorInvoiceSyncFlowData, BillingConnectorPaymentsSyncFlowData,
DisputesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData,
RevenueRecoveryRecordBackData, WebhookSourceVerifyData,
},
AccessTokenFlowData, ExternalAuthenticationFlowData, FilesFlowData,
},
@ -22,13 +22,18 @@ use hyperswitch_domain_models::{
SetupMandate, UpdateMetadata, Void,
},
refunds::{Execute, RSync},
revenue_recovery::{BillingConnectorPaymentsSync, RecoveryRecordBack},
revenue_recovery::{
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
},
webhooks::VerifyWebhookSource,
AccessTokenAuth,
},
router_request_types::{
authentication,
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
revenue_recovery::{
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
CompleteAuthorizeData, ConnectorCustomerData, DefendDisputeRequestData,
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsApproveData,
@ -42,7 +47,8 @@ use hyperswitch_domain_models::{
},
router_response_types::{
revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
AcceptDisputeResponse, AuthenticationResponseData, DefendDisputeResponse,
MandateRevokeResponseData, PaymentsResponseData, RefundsResponseData, RetrieveFileResponse,
@ -98,8 +104,8 @@ use hyperswitch_interfaces::{
},
refunds_v2::{RefundExecuteV2, RefundSyncV2, RefundV2},
revenue_recovery_v2::{
BillingConnectorPaymentsSyncIntegrationV2, RevenueRecoveryRecordBackV2,
RevenueRecoveryV2,
BillingConnectorInvoiceSyncIntegrationV2, BillingConnectorPaymentsSyncIntegrationV2,
RevenueRecoveryRecordBackV2, RevenueRecoveryV2,
},
ConnectorAccessTokenV2, ConnectorMandateRevokeV2, ConnectorVerifyWebhookSourceV2,
},
@ -2757,13 +2763,14 @@ macro_rules! default_imp_for_new_connector_integration_revenue_recovery {
$( impl RevenueRecoveryV2 for $path::$connector {}
impl BillingConnectorPaymentsSyncIntegrationV2 for $path::$connector {}
impl RevenueRecoveryRecordBackV2 for $path::$connector {}
impl BillingConnectorInvoiceSyncIntegrationV2 for $path::$connector {}
impl
ConnectorIntegrationV2<
RecoveryRecordBack,
RevenueRecoveryRecordBackData,
RevenueRecoveryRecordBackRequest,
RevenueRecoveryRecordBackResponse,
> for $path::$connector
RecoveryRecordBack,
RevenueRecoveryRecordBackData,
RevenueRecoveryRecordBackRequest,
RevenueRecoveryRecordBackResponse,
> for $path::$connector
{}
impl
ConnectorIntegrationV2<
@ -2773,6 +2780,14 @@ macro_rules! default_imp_for_new_connector_integration_revenue_recovery {
BillingConnectorPaymentsSyncResponse,
> for $path::$connector
{}
impl
ConnectorIntegrationV2<
BillingConnectorInvoiceSync,
BillingConnectorInvoiceSyncFlowData,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
> for $path::$connector
{}
)*
};
}

View File

@ -155,3 +155,6 @@ pub struct UasFlowData {
#[derive(Debug, Clone)]
pub struct BillingConnectorPaymentsSyncFlowData;
#[derive(Debug, Clone)]
pub struct BillingConnectorInvoiceSyncFlowData;

View File

@ -2,3 +2,6 @@
pub struct BillingConnectorPaymentsSync;
#[derive(Debug, Clone)]
pub struct RecoveryRecordBack;
#[derive(Debug, Clone)]
pub struct BillingConnectorInvoiceSync;

View File

@ -15,3 +15,8 @@ pub struct RevenueRecoveryRecordBackRequest {
pub attempt_status: common_enums::AttemptStatus,
pub connector_transaction_id: Option<common_utils::types::ConnectorTransactionId>,
}
#[derive(Debug, Clone)]
pub struct BillingConnectorInvoiceSyncRequest {
pub billing_connector_invoice_id: String,
}

View File

@ -34,3 +34,20 @@ pub struct BillingConnectorPaymentsSyncResponse {
pub struct RevenueRecoveryRecordBackResponse {
pub merchant_reference_id: common_utils::id_type::PaymentReferenceId,
}
pub struct BillingConnectorInvoiceSyncResponse {
/// transaction amount against invoice, accepted in minor unit.
pub amount: MinorUnit,
/// currency of the transaction
pub currency: common_enums::enums::Currency,
/// merchant reference id at billing connector. ex: invoice_id
pub merchant_reference_id: common_utils::id_type::PaymentReferenceId,
/// No of attempts made against an invoice
pub retry_count: Option<u16>,
/// Billing Address of the customer for Invoice
pub billing_address: Option<api_models::payments::Address>,
/// creation time of the invoice
pub created_at: Option<PrimitiveDateTime>,
/// Ending time of Invoice
pub ends_at: Option<PrimitiveDateTime>,
}

View File

@ -5,13 +5,16 @@ use crate::{
router_flow_types::{
mandate_revoke::MandateRevoke, revenue_recovery::RecoveryRecordBack, AccessTokenAuth,
Authenticate, AuthenticationConfirmation, Authorize, AuthorizeSessionToken,
BillingConnectorPaymentsSync, CalculateTax, Capture, CompleteAuthorize,
CreateConnectorCustomer, Execute, IncrementalAuthorization, PSync, PaymentMethodToken,
PostAuthenticate, PostSessionTokens, PreAuthenticate, PreProcessing, RSync,
SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, VerifyWebhookSource, Void,
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, CalculateTax, Capture,
CompleteAuthorize, CreateConnectorCustomer, Execute, IncrementalAuthorization, PSync,
PaymentMethodToken, PostAuthenticate, PostSessionTokens, PreAuthenticate, PreProcessing,
RSync, SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, VerifyWebhookSource, Void,
},
router_request_types::{
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
revenue_recovery::{
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
UasConfirmationRequestData, UasPostAuthenticationRequestData,
@ -27,7 +30,8 @@ use crate::{
},
router_response_types::{
revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
MandateRevokeResponseData, PaymentsResponseData, RefundsResponseData,
TaxCalculationResponseData, VerifyWebhookSourceResponseData,
@ -109,3 +113,9 @@ pub type BillingConnectorPaymentsSyncRouterData = RouterData<
BillingConnectorPaymentsSyncRequest,
BillingConnectorPaymentsSyncResponse,
>;
pub type BillingConnectorInvoiceSyncRouterData = RouterData<
BillingConnectorInvoiceSync,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>;

View File

@ -1,12 +1,16 @@
//! Revenue Recovery Interface
use hyperswitch_domain_models::{
router_flow_types::{BillingConnectorPaymentsSync, RecoveryRecordBack},
router_flow_types::{
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
},
router_request_types::revenue_recovery::{
BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest,
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
router_response_types::revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
};
@ -17,7 +21,10 @@ use super::ConnectorIntegration;
/// trait RevenueRecovery
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
pub trait RevenueRecovery:
ConnectorCommon + BillingConnectorPaymentsSyncIntegration + RevenueRecoveryRecordBack
ConnectorCommon
+ BillingConnectorPaymentsSyncIntegration
+ RevenueRecoveryRecordBack
+ BillingConnectorInvoiceSyncIntegration
{
}
@ -41,6 +48,16 @@ pub trait RevenueRecoveryRecordBack:
{
}
/// trait BillingConnectorInvoiceSyncIntegration
pub trait BillingConnectorInvoiceSyncIntegration:
ConnectorIntegration<
BillingConnectorInvoiceSync,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>
{
}
#[cfg(not(all(feature = "v2", feature = "revenue_recovery")))]
/// trait RevenueRecovery
pub trait RevenueRecovery {}

View File

@ -2,14 +2,19 @@
use hyperswitch_domain_models::{
router_data_v2::flow_common_types::{
BillingConnectorPaymentsSyncFlowData, RevenueRecoveryRecordBackData,
BillingConnectorInvoiceSyncFlowData, BillingConnectorPaymentsSyncFlowData,
RevenueRecoveryRecordBackData,
},
router_flow_types::{
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
},
router_flow_types::{BillingConnectorPaymentsSync, RecoveryRecordBack},
router_request_types::revenue_recovery::{
BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest,
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
router_response_types::revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
};
@ -17,7 +22,9 @@ use crate::connector_integration_v2::ConnectorIntegrationV2;
/// trait RevenueRecoveryV2
pub trait RevenueRecoveryV2:
BillingConnectorPaymentsSyncIntegrationV2 + RevenueRecoveryRecordBackV2
BillingConnectorPaymentsSyncIntegrationV2
+ RevenueRecoveryRecordBackV2
+ BillingConnectorInvoiceSyncIntegrationV2
{
}
@ -42,3 +49,14 @@ pub trait RevenueRecoveryRecordBackV2:
>
{
}
/// trait BillingConnectorInvoiceSyncIntegrationV2
pub trait BillingConnectorInvoiceSyncIntegrationV2:
ConnectorIntegrationV2<
BillingConnectorInvoiceSync,
BillingConnectorInvoiceSyncFlowData,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>
{
}

View File

@ -19,9 +19,13 @@ use hyperswitch_domain_models::{
Authenticate, AuthenticationConfirmation, PostAuthenticate, PreAuthenticate,
},
webhooks::VerifyWebhookSource,
BillingConnectorInvoiceSync,
},
router_request_types::{
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
revenue_recovery::{
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
UasConfirmationRequestData, UasPostAuthenticationRequestData,
@ -39,7 +43,8 @@ use hyperswitch_domain_models::{
},
router_response_types::{
revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
AcceptDisputeResponse, DefendDisputeResponse, MandateRevokeResponseData,
PaymentsResponseData, RefundsResponseData, RetrieveFileResponse, SubmitEvidenceResponse,
@ -245,3 +250,10 @@ pub type BillingConnectorPaymentsSyncType = dyn ConnectorIntegration<
BillingConnectorPaymentsSyncRequest,
BillingConnectorPaymentsSyncResponse,
>;
/// Type alias for `ConnectorIntegration<BillingConnectorInvoiceSync, BillingConnectorInvoiceSyncRequest, BillingConnectorInvoiceSyncResponse>`
pub type BillingConnectorInvoiceSyncType = dyn ConnectorIntegration<
BillingConnectorInvoiceSync,
BillingConnectorInvoiceSyncRequest,
BillingConnectorInvoiceSyncResponse,
>;

View File

@ -15,7 +15,7 @@ pub mod update_metadata_flow;
use async_trait::async_trait;
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
use hyperswitch_domain_models::router_flow_types::{
BillingConnectorPaymentsSync, RecoveryRecordBack,
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
};
use hyperswitch_domain_models::{
mandates::CustomerAcceptance,
@ -2018,3 +2018,45 @@ default_imp_for_revenue_recovery_record_back!(
connector::Wellsfargopayout,
connector::Wise
);
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
macro_rules! default_imp_for_billing_connector_invoice_sync {
($($path:ident::$connector:ident),*) => {
$(
impl api::BillingConnectorInvoiceSyncIntegration for $path::$connector {}
impl
services::ConnectorIntegration<
BillingConnectorInvoiceSync,
types::BillingConnectorInvoiceSyncRequest,
types::BillingConnectorInvoiceSyncResponse,
> for $path::$connector
{}
)*
};
}
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
#[cfg(feature = "dummy_connector")]
impl<const T: u8> api::BillingConnectorInvoiceSyncIntegration for connector::DummyConnector<T> {}
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
#[cfg(feature = "dummy_connector")]
impl<const T: u8>
services::ConnectorIntegration<
BillingConnectorInvoiceSync,
types::BillingConnectorInvoiceSyncRequest,
types::BillingConnectorInvoiceSyncResponse,
> for connector::DummyConnector<T>
{
}
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
default_imp_for_billing_connector_invoice_sync!(
connector::Adyenplatform,
connector::Ebanx,
connector::Gpayments,
connector::Netcetera,
connector::Plaid,
connector::Signifyd,
connector::Stripe,
connector::Threedsecureio,
connector::Wellsfargopayout,
connector::Wise
);

View File

@ -106,6 +106,13 @@ pub type BoxedFilesConnectorIntegrationInterface<T, Req, Resp> =
BoxedConnectorIntegrationInterface<T, common_types::FilesFlowData, Req, Resp>;
pub type BoxedRevenueRecoveryRecordBackInterface<T, Req, Res> =
BoxedConnectorIntegrationInterface<T, common_types::RevenueRecoveryRecordBackData, Req, Res>;
pub type BoxedBillingConnectorInvoiceSyncIntegrationInterface<T, Req, Res> =
BoxedConnectorIntegrationInterface<
T,
common_types::BillingConnectorInvoiceSyncFlowData,
Req,
Res,
>;
pub type BoxedUnifiedAuthenticationServiceInterface<T, Req, Resp> =
BoxedConnectorIntegrationInterface<T, common_types::UasFlowData, Req, Resp>;

View File

@ -57,7 +57,10 @@ pub use hyperswitch_domain_models::{
WebhookSourceVerifyData,
},
router_request_types::{
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
revenue_recovery::{
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
RevenueRecoveryRecordBackRequest,
},
unified_authentication_service::{
UasAuthenticationRequestData, UasAuthenticationResponseData,
UasConfirmationRequestData, UasPostAuthenticationRequestData,
@ -79,7 +82,8 @@ pub use hyperswitch_domain_models::{
},
router_response_types::{
revenue_recovery::{
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
RevenueRecoveryRecordBackResponse,
},
AcceptDisputeResponse, CaptureSyncResponse, DefendDisputeResponse, MandateReference,
MandateRevokeResponseData, PaymentsResponseData, PreprocessingResponseId,

View File

@ -57,7 +57,8 @@ pub use hyperswitch_interfaces::{
},
fraud_check::FraudCheck,
revenue_recovery::{
BillingConnectorPaymentsSyncIntegration, RevenueRecovery, RevenueRecoveryRecordBack,
BillingConnectorInvoiceSyncIntegration, BillingConnectorPaymentsSyncIntegration,
RevenueRecovery, RevenueRecoveryRecordBack,
},
revenue_recovery_v2::RevenueRecoveryV2,
BoxedConnector, Connector, ConnectorAccessToken, ConnectorAccessTokenV2, ConnectorCommon,