Skip to content

Conversation

GauravRawat369
Copy link
Contributor

@GauravRawat369 GauravRawat369 commented Sep 8, 2025

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

  • Added Chargebee subscription creation and record back request/response structures.
  • Implemented conversion traits for Chargebee subscription data.
  • Enhanced Recurly connector to support subscription creation and record back flows.
  • Introduced new router flow types and request/response types for subscriptions.
  • Updated default implementations to include subscription-related traits and integrations.
  • Added new traits for subscription management in the hyperswitch interfaces.
  • Implemented conversion logic for subscription data between old and new router data formats.
  • Updated API service to handle subscription connector integration.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

image image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@GauravRawat369 GauravRawat369 requested review from a team as code owners September 8, 2025 10:23
Copy link

semanticdiff-com bot commented Sep 8, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_domain_models/src/types.rs  62% smaller
  crates/hyperswitch_interfaces/src/connector_integration_v2.rs  53% smaller
  crates/hyperswitch_interfaces/src/api.rs  29% smaller
  crates/hyperswitch_connectors/src/connectors/recurly.rs  27% smaller
  crates/hyperswitch_connectors/src/default_implementations.rs  6% smaller
  crates/hyperswitch_interfaces/src/conversion_impls.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/chargebee/transformers.rs  3% smaller
  crates/hyperswitch_connectors/src/connectors/chargebee.rs  2% smaller
  crates/hyperswitch_connectors/Cargo.toml Unsupported file format
  crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_flow_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_flow_types/subscriptions.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_request_types/subscriptions.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_response_types.rs  0% smaller
  crates/hyperswitch_domain_models/src/router_response_types/subscriptions.rs  0% smaller
  crates/hyperswitch_interfaces/src/api/subscriptions.rs  0% smaller
  crates/hyperswitch_interfaces/src/api/subscriptions_v2.rs  0% smaller
  crates/hyperswitch_interfaces/src/types.rs  0% smaller
  crates/router/src/core/payments/helpers.rs  0% smaller
  crates/router/src/services/api.rs  0% smaller

@GauravRawat369 GauravRawat369 linked an issue Sep 8, 2025 that may be closed by this pull request
@GauravRawat369 GauravRawat369 self-assigned this Sep 8, 2025
@@ -309,6 +326,24 @@ pub type BillingConnectorInvoiceSyncTypeV2 = dyn ConnectorIntegrationV2<
BillingConnectorInvoiceSyncResponse,
>;

#[cfg(feature = "v1")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg(feature = "v1")]
#[cfg(feature = "v2")]

RevenueRecoveryRecordBackResponse,
>;

#[cfg(feature = "v1")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg(feature = "v1")]
#[cfg(feature = "v2")]

#[cfg(feature = "v1")]
/// Type alias for `ConnectorIntegration<SubscriptionRecordBack, SubscriptionsRecordBackRequest, RevenueRecoveryRecordBackResponse>`
pub type SubscriptionRecordBackType = dyn ConnectorIntegration<
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionRecordBack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionRecordBack,
SubscriptionRecordBack,

#[cfg(feature = "v1")]
/// Type alias for `ConnectorIntegration<SubscriptionCreate, SubscriptionCreateRequest, SubscriptionCreateResponse>`
pub type SubscriptionCreateType = dyn ConnectorIntegration<
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionCreate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionCreate,
SubscriptionCreate,

pub type SubscriptionCreateType = dyn ConnectorIntegration<
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionCreate,
SubscriptionCreateRequest,
hyperswitch_domain_models::router_response_types::subscriptions::SubscriptionCreateResponse,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyperswitch_domain_models::router_response_types::subscriptions::SubscriptionCreateResponse,
SubscriptionCreateResponse,

#[cfg(feature = "v1")]
/// Type alias for `ConnectorIntegrationV2<SubscriptionRecordBack, SubscriptionCreateData, SubscriptionsRecordBackRequest, RevenueRecoveryRecordBackResponse>`
pub type SubscriptionRecordBackTypeV2 = dyn ConnectorIntegrationV2<
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionRecordBack,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionRecordBack,
SubscriptionRecordBack,

Comment on lines 341 to 344
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionCreate,
flow_common_types::SubscriptionCreateData,
SubscriptionCreateRequest,
hyperswitch_domain_models::router_response_types::subscriptions::SubscriptionCreateResponse,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hyperswitch_domain_models::router_flow_types::subscriptions::SubscriptionCreate,
flow_common_types::SubscriptionCreateData,
SubscriptionCreateRequest,
hyperswitch_domain_models::router_response_types::subscriptions::SubscriptionCreateResponse,
SubscriptionCreate,
flow_common_types::SubscriptionCreateData,
SubscriptionCreateRequest,
SubscriptionCreateResponse,

{
fn get_headers(
&self,
req: &hyperswitch_domain_models::types::SubscriptionRecordBackRouterData,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
req: &hyperswitch_domain_models::types::SubscriptionRecordBackRouterData,
req: &SubscriptionRecordBackRouterData,

change it in other places also

Comment on lines 75 to 104
Ok(Self {
item_price_id: first_item.item_price_id.clone(),
quantity: first_item.quantity,
billing_address_line1: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.line1.as_ref().map(|line1| line1.clone().expose())),
billing_address_city: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.city.clone()),
billing_address_state: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.state.as_ref().map(|state| state.clone().expose())),
billing_address_zip: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.zip.as_ref().map(|zip| zip.clone().expose())),
billing_address_country: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.country.map(|country| country.to_string())),
auto_collection: req.auto_collection.clone(),
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ok(Self {
item_price_id: first_item.item_price_id.clone(),
quantity: first_item.quantity,
billing_address_line1: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.line1.as_ref().map(|line1| line1.clone().expose())),
billing_address_city: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.city.clone()),
billing_address_state: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.state.as_ref().map(|state| state.clone().expose())),
billing_address_zip: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.zip.as_ref().map(|zip| zip.clone().expose())),
billing_address_country: req
.billing_address
.address
.as_ref()
.and_then(|addr| addr.country.map(|country| country.to_string())),
auto_collection: req.auto_collection.clone(),
})
let address = req.billing_address.address.as_ref();
Ok(Self {
item_price_id: first_item.item_price_id.clone(),
quantity: first_item.quantity,
billing_address_line1: address.and_then(|addr| addr.line1.as_ref().map(|line1| line1.clone().expose())),
billing_address_city: address.and_then(|addr| addr.city.clone()),
billing_address_state: address.and_then(|addr| addr.state.as_ref().map(|state| state.clone().expose())),
billing_address_zip: address.and_then(|addr| addr.zip.as_ref().map(|zip| zip.clone().expose())),
billing_address_country: address.and_then(|addr| addr.country.map(|country| country.to_string())),
auto_collection: req.auto_collection.clone(),
})

Comment on lines +180 to +184
pub type SubscriptionRecordBackRouterData = RouterData<
SubscriptionRecordBack,
SubscriptionsRecordBackRequest,
RevenueRecoveryRecordBackResponse,
>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub type SubscriptionRecordBackRouterData = RouterData<
SubscriptionRecordBack,
SubscriptionsRecordBackRequest,
RevenueRecoveryRecordBackResponse,
>;
pub type SubscriptionInvoiceRecordBackRouterData = RouterData<
SubscriptionInvoiceRecordBack,
SubscriptionInvoiceRecordBackRequest,
SubscriptionInvoiceRecordBackResponse,
>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Subscription with autocollection off
2 participants