Skip to content

Commit 3d0dd5b

Browse files
NISHANTH1221Nishanth Challahyperswitch-bot[bot]
authored
feat(core): Adds Billing Connector Invoice Sync flow in Revenue Recovery (#7799)
Co-authored-by: Nishanth Challa <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 6001372 commit 3d0dd5b

File tree

14 files changed

+294
-34
lines changed

14 files changed

+294
-34
lines changed

crates/hyperswitch_connectors/src/default_implementations.rs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,3 +4520,109 @@ default_imp_for_revenue_recovery_record_back!(
45204520
connectors::Zen,
45214521
connectors::Zsl
45224522
);
4523+
4524+
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
4525+
macro_rules! default_imp_for_billing_connector_invoice_sync {
4526+
($($path:ident::$connector:ident),*) => {
4527+
$( impl recovery_traits::BillingConnectorInvoiceSyncIntegration for $path::$connector {}
4528+
impl
4529+
ConnectorIntegration<
4530+
recovery_router_flows::BillingConnectorInvoiceSync,
4531+
recovery_request::BillingConnectorInvoiceSyncRequest,
4532+
recovery_response::BillingConnectorInvoiceSyncResponse
4533+
> for $path::$connector
4534+
{}
4535+
)*
4536+
};
4537+
}
4538+
4539+
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
4540+
default_imp_for_billing_connector_invoice_sync!(
4541+
connectors::Aci,
4542+
connectors::Adyen,
4543+
connectors::Airwallex,
4544+
connectors::Amazonpay,
4545+
connectors::Authorizedotnet,
4546+
connectors::Bambora,
4547+
connectors::Bamboraapac,
4548+
connectors::Bankofamerica,
4549+
connectors::Billwerk,
4550+
connectors::Bluesnap,
4551+
connectors::Bitpay,
4552+
connectors::Braintree,
4553+
connectors::Boku,
4554+
connectors::Cashtocode,
4555+
connectors::Chargebee,
4556+
connectors::Checkout,
4557+
connectors::Coinbase,
4558+
connectors::Coingate,
4559+
connectors::Cryptopay,
4560+
connectors::CtpMastercard,
4561+
connectors::Cybersource,
4562+
connectors::Datatrans,
4563+
connectors::Deutschebank,
4564+
connectors::Digitalvirgo,
4565+
connectors::Dlocal,
4566+
connectors::Elavon,
4567+
connectors::Facilitapay,
4568+
connectors::Fiserv,
4569+
connectors::Fiservemea,
4570+
connectors::Fiuu,
4571+
connectors::Forte,
4572+
connectors::Getnet,
4573+
connectors::Globalpay,
4574+
connectors::Globepay,
4575+
connectors::Gocardless,
4576+
connectors::Helcim,
4577+
connectors::Hipay,
4578+
connectors::Iatapay,
4579+
connectors::Inespay,
4580+
connectors::Itaubank,
4581+
connectors::Juspaythreedsserver,
4582+
connectors::Jpmorgan,
4583+
connectors::Klarna,
4584+
connectors::Nomupay,
4585+
connectors::Nmi,
4586+
connectors::Noon,
4587+
connectors::Novalnet,
4588+
connectors::Nexinets,
4589+
connectors::Nexixpay,
4590+
connectors::Nuvei,
4591+
connectors::Opayo,
4592+
connectors::Opennode,
4593+
connectors::Payeezy,
4594+
connectors::Paystack,
4595+
connectors::Payu,
4596+
connectors::Paypal,
4597+
connectors::Powertranz,
4598+
connectors::Prophetpay,
4599+
connectors::Mifinity,
4600+
connectors::Mollie,
4601+
connectors::Moneris,
4602+
connectors::Multisafepay,
4603+
connectors::Paybox,
4604+
connectors::Payme,
4605+
connectors::Payone,
4606+
connectors::Placetopay,
4607+
connectors::Rapyd,
4608+
connectors::Razorpay,
4609+
connectors::Recurly,
4610+
connectors::Redsys,
4611+
connectors::Riskified,
4612+
connectors::Shift4,
4613+
connectors::Stax,
4614+
connectors::Square,
4615+
connectors::Stripebilling,
4616+
connectors::Taxjar,
4617+
connectors::Thunes,
4618+
connectors::Trustpay,
4619+
connectors::Tsys,
4620+
connectors::UnifiedAuthenticationService,
4621+
connectors::Worldline,
4622+
connectors::Worldpay,
4623+
connectors::Wellsfargo,
4624+
connectors::Volt,
4625+
connectors::Xendit,
4626+
connectors::Zen,
4627+
connectors::Zsl
4628+
);

crates/hyperswitch_connectors/src/default_implementations_v2.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use hyperswitch_domain_models::{
22
router_data::AccessToken,
33
router_data_v2::{
44
flow_common_types::{
5-
BillingConnectorPaymentsSyncFlowData, DisputesFlowData, MandateRevokeFlowData,
6-
PaymentFlowData, RefundFlowData, RevenueRecoveryRecordBackData,
7-
WebhookSourceVerifyData,
5+
BillingConnectorInvoiceSyncFlowData, BillingConnectorPaymentsSyncFlowData,
6+
DisputesFlowData, MandateRevokeFlowData, PaymentFlowData, RefundFlowData,
7+
RevenueRecoveryRecordBackData, WebhookSourceVerifyData,
88
},
99
AccessTokenFlowData, ExternalAuthenticationFlowData, FilesFlowData,
1010
},
@@ -22,13 +22,18 @@ use hyperswitch_domain_models::{
2222
SetupMandate, UpdateMetadata, Void,
2323
},
2424
refunds::{Execute, RSync},
25-
revenue_recovery::{BillingConnectorPaymentsSync, RecoveryRecordBack},
25+
revenue_recovery::{
26+
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
27+
},
2628
webhooks::VerifyWebhookSource,
2729
AccessTokenAuth,
2830
},
2931
router_request_types::{
3032
authentication,
31-
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
33+
revenue_recovery::{
34+
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
35+
RevenueRecoveryRecordBackRequest,
36+
},
3237
AcceptDisputeRequestData, AccessTokenRequestData, AuthorizeSessionTokenData,
3338
CompleteAuthorizeData, ConnectorCustomerData, DefendDisputeRequestData,
3439
MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsApproveData,
@@ -42,7 +47,8 @@ use hyperswitch_domain_models::{
4247
},
4348
router_response_types::{
4449
revenue_recovery::{
45-
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
50+
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
51+
RevenueRecoveryRecordBackResponse,
4652
},
4753
AcceptDisputeResponse, AuthenticationResponseData, DefendDisputeResponse,
4854
MandateRevokeResponseData, PaymentsResponseData, RefundsResponseData, RetrieveFileResponse,
@@ -98,8 +104,8 @@ use hyperswitch_interfaces::{
98104
},
99105
refunds_v2::{RefundExecuteV2, RefundSyncV2, RefundV2},
100106
revenue_recovery_v2::{
101-
BillingConnectorPaymentsSyncIntegrationV2, RevenueRecoveryRecordBackV2,
102-
RevenueRecoveryV2,
107+
BillingConnectorInvoiceSyncIntegrationV2, BillingConnectorPaymentsSyncIntegrationV2,
108+
RevenueRecoveryRecordBackV2, RevenueRecoveryV2,
103109
},
104110
ConnectorAccessTokenV2, ConnectorMandateRevokeV2, ConnectorVerifyWebhookSourceV2,
105111
},
@@ -2757,13 +2763,14 @@ macro_rules! default_imp_for_new_connector_integration_revenue_recovery {
27572763
$( impl RevenueRecoveryV2 for $path::$connector {}
27582764
impl BillingConnectorPaymentsSyncIntegrationV2 for $path::$connector {}
27592765
impl RevenueRecoveryRecordBackV2 for $path::$connector {}
2766+
impl BillingConnectorInvoiceSyncIntegrationV2 for $path::$connector {}
27602767
impl
27612768
ConnectorIntegrationV2<
2762-
RecoveryRecordBack,
2763-
RevenueRecoveryRecordBackData,
2764-
RevenueRecoveryRecordBackRequest,
2765-
RevenueRecoveryRecordBackResponse,
2766-
> for $path::$connector
2769+
RecoveryRecordBack,
2770+
RevenueRecoveryRecordBackData,
2771+
RevenueRecoveryRecordBackRequest,
2772+
RevenueRecoveryRecordBackResponse,
2773+
> for $path::$connector
27672774
{}
27682775
impl
27692776
ConnectorIntegrationV2<
@@ -2773,6 +2780,14 @@ macro_rules! default_imp_for_new_connector_integration_revenue_recovery {
27732780
BillingConnectorPaymentsSyncResponse,
27742781
> for $path::$connector
27752782
{}
2783+
impl
2784+
ConnectorIntegrationV2<
2785+
BillingConnectorInvoiceSync,
2786+
BillingConnectorInvoiceSyncFlowData,
2787+
BillingConnectorInvoiceSyncRequest,
2788+
BillingConnectorInvoiceSyncResponse,
2789+
> for $path::$connector
2790+
{}
27762791
)*
27772792
};
27782793
}

crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,6 @@ pub struct UasFlowData {
155155

156156
#[derive(Debug, Clone)]
157157
pub struct BillingConnectorPaymentsSyncFlowData;
158+
159+
#[derive(Debug, Clone)]
160+
pub struct BillingConnectorInvoiceSyncFlowData;

crates/hyperswitch_domain_models/src/router_flow_types/revenue_recovery.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
pub struct BillingConnectorPaymentsSync;
33
#[derive(Debug, Clone)]
44
pub struct RecoveryRecordBack;
5+
6+
#[derive(Debug, Clone)]
7+
pub struct BillingConnectorInvoiceSync;

crates/hyperswitch_domain_models/src/router_request_types/revenue_recovery.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ pub struct RevenueRecoveryRecordBackRequest {
1515
pub attempt_status: common_enums::AttemptStatus,
1616
pub connector_transaction_id: Option<common_utils::types::ConnectorTransactionId>,
1717
}
18+
19+
#[derive(Debug, Clone)]
20+
pub struct BillingConnectorInvoiceSyncRequest {
21+
pub billing_connector_invoice_id: String,
22+
}

crates/hyperswitch_domain_models/src/router_response_types/revenue_recovery.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ pub struct BillingConnectorPaymentsSyncResponse {
3434
pub struct RevenueRecoveryRecordBackResponse {
3535
pub merchant_reference_id: common_utils::id_type::PaymentReferenceId,
3636
}
37+
38+
pub struct BillingConnectorInvoiceSyncResponse {
39+
/// transaction amount against invoice, accepted in minor unit.
40+
pub amount: MinorUnit,
41+
/// currency of the transaction
42+
pub currency: common_enums::enums::Currency,
43+
/// merchant reference id at billing connector. ex: invoice_id
44+
pub merchant_reference_id: common_utils::id_type::PaymentReferenceId,
45+
/// No of attempts made against an invoice
46+
pub retry_count: Option<u16>,
47+
/// Billing Address of the customer for Invoice
48+
pub billing_address: Option<api_models::payments::Address>,
49+
/// creation time of the invoice
50+
pub created_at: Option<PrimitiveDateTime>,
51+
/// Ending time of Invoice
52+
pub ends_at: Option<PrimitiveDateTime>,
53+
}

crates/hyperswitch_domain_models/src/types.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ use crate::{
55
router_flow_types::{
66
mandate_revoke::MandateRevoke, revenue_recovery::RecoveryRecordBack, AccessTokenAuth,
77
Authenticate, AuthenticationConfirmation, Authorize, AuthorizeSessionToken,
8-
BillingConnectorPaymentsSync, CalculateTax, Capture, CompleteAuthorize,
9-
CreateConnectorCustomer, Execute, IncrementalAuthorization, PSync, PaymentMethodToken,
10-
PostAuthenticate, PostSessionTokens, PreAuthenticate, PreProcessing, RSync,
11-
SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, VerifyWebhookSource, Void,
8+
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, CalculateTax, Capture,
9+
CompleteAuthorize, CreateConnectorCustomer, Execute, IncrementalAuthorization, PSync,
10+
PaymentMethodToken, PostAuthenticate, PostSessionTokens, PreAuthenticate, PreProcessing,
11+
RSync, SdkSessionUpdate, Session, SetupMandate, UpdateMetadata, VerifyWebhookSource, Void,
1212
},
1313
router_request_types::{
14-
revenue_recovery::{BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest},
14+
revenue_recovery::{
15+
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
16+
RevenueRecoveryRecordBackRequest,
17+
},
1518
unified_authentication_service::{
1619
UasAuthenticationRequestData, UasAuthenticationResponseData,
1720
UasConfirmationRequestData, UasPostAuthenticationRequestData,
@@ -27,7 +30,8 @@ use crate::{
2730
},
2831
router_response_types::{
2932
revenue_recovery::{
30-
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
33+
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
34+
RevenueRecoveryRecordBackResponse,
3135
},
3236
MandateRevokeResponseData, PaymentsResponseData, RefundsResponseData,
3337
TaxCalculationResponseData, VerifyWebhookSourceResponseData,
@@ -109,3 +113,9 @@ pub type BillingConnectorPaymentsSyncRouterData = RouterData<
109113
BillingConnectorPaymentsSyncRequest,
110114
BillingConnectorPaymentsSyncResponse,
111115
>;
116+
117+
pub type BillingConnectorInvoiceSyncRouterData = RouterData<
118+
BillingConnectorInvoiceSync,
119+
BillingConnectorInvoiceSyncRequest,
120+
BillingConnectorInvoiceSyncResponse,
121+
>;

crates/hyperswitch_interfaces/src/api/revenue_recovery.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
//! Revenue Recovery Interface
22
33
use hyperswitch_domain_models::{
4-
router_flow_types::{BillingConnectorPaymentsSync, RecoveryRecordBack},
4+
router_flow_types::{
5+
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
6+
},
57
router_request_types::revenue_recovery::{
6-
BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest,
8+
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
9+
RevenueRecoveryRecordBackRequest,
710
},
811
router_response_types::revenue_recovery::{
9-
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
12+
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
13+
RevenueRecoveryRecordBackResponse,
1014
},
1115
};
1216

@@ -17,7 +21,10 @@ use super::ConnectorIntegration;
1721
/// trait RevenueRecovery
1822
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
1923
pub trait RevenueRecovery:
20-
ConnectorCommon + BillingConnectorPaymentsSyncIntegration + RevenueRecoveryRecordBack
24+
ConnectorCommon
25+
+ BillingConnectorPaymentsSyncIntegration
26+
+ RevenueRecoveryRecordBack
27+
+ BillingConnectorInvoiceSyncIntegration
2128
{
2229
}
2330

@@ -41,6 +48,16 @@ pub trait RevenueRecoveryRecordBack:
4148
{
4249
}
4350

51+
/// trait BillingConnectorInvoiceSyncIntegration
52+
pub trait BillingConnectorInvoiceSyncIntegration:
53+
ConnectorIntegration<
54+
BillingConnectorInvoiceSync,
55+
BillingConnectorInvoiceSyncRequest,
56+
BillingConnectorInvoiceSyncResponse,
57+
>
58+
{
59+
}
60+
4461
#[cfg(not(all(feature = "v2", feature = "revenue_recovery")))]
4562
/// trait RevenueRecovery
4663
pub trait RevenueRecovery {}

crates/hyperswitch_interfaces/src/api/revenue_recovery_v2.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,29 @@
22
33
use hyperswitch_domain_models::{
44
router_data_v2::flow_common_types::{
5-
BillingConnectorPaymentsSyncFlowData, RevenueRecoveryRecordBackData,
5+
BillingConnectorInvoiceSyncFlowData, BillingConnectorPaymentsSyncFlowData,
6+
RevenueRecoveryRecordBackData,
7+
},
8+
router_flow_types::{
9+
BillingConnectorInvoiceSync, BillingConnectorPaymentsSync, RecoveryRecordBack,
610
},
7-
router_flow_types::{BillingConnectorPaymentsSync, RecoveryRecordBack},
811
router_request_types::revenue_recovery::{
9-
BillingConnectorPaymentsSyncRequest, RevenueRecoveryRecordBackRequest,
12+
BillingConnectorInvoiceSyncRequest, BillingConnectorPaymentsSyncRequest,
13+
RevenueRecoveryRecordBackRequest,
1014
},
1115
router_response_types::revenue_recovery::{
12-
BillingConnectorPaymentsSyncResponse, RevenueRecoveryRecordBackResponse,
16+
BillingConnectorInvoiceSyncResponse, BillingConnectorPaymentsSyncResponse,
17+
RevenueRecoveryRecordBackResponse,
1318
},
1419
};
1520

1621
use crate::connector_integration_v2::ConnectorIntegrationV2;
1722

1823
/// trait RevenueRecoveryV2
1924
pub trait RevenueRecoveryV2:
20-
BillingConnectorPaymentsSyncIntegrationV2 + RevenueRecoveryRecordBackV2
25+
BillingConnectorPaymentsSyncIntegrationV2
26+
+ RevenueRecoveryRecordBackV2
27+
+ BillingConnectorInvoiceSyncIntegrationV2
2128
{
2229
}
2330

@@ -42,3 +49,14 @@ pub trait RevenueRecoveryRecordBackV2:
4249
>
4350
{
4451
}
52+
53+
/// trait BillingConnectorInvoiceSyncIntegrationV2
54+
pub trait BillingConnectorInvoiceSyncIntegrationV2:
55+
ConnectorIntegrationV2<
56+
BillingConnectorInvoiceSync,
57+
BillingConnectorInvoiceSyncFlowData,
58+
BillingConnectorInvoiceSyncRequest,
59+
BillingConnectorInvoiceSyncResponse,
60+
>
61+
{
62+
}

0 commit comments

Comments
 (0)