mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(core): Add Support for Payments Dynamic Tax Calculation Based on Shipping Address (#5619)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1911,7 +1911,8 @@ pub struct BusinessProfileCreate {
|
||||
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
@ -2014,7 +2015,8 @@ pub struct BusinessProfileCreate {
|
||||
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
@ -2131,7 +2133,8 @@ pub struct BusinessProfileResponse {
|
||||
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, Secret<String>>>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
@ -2238,7 +2241,8 @@ pub struct BusinessProfileResponse {
|
||||
pub order_fulfillment_time_origin: Option<api_enums::OrderFulfillmentTimeOrigin>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
@ -2346,7 +2350,8 @@ pub struct BusinessProfileUpdate {
|
||||
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
@ -2445,7 +2450,8 @@ pub struct BusinessProfileUpdate {
|
||||
pub outgoing_webhook_custom_http_headers: Option<HashMap<String, String>>,
|
||||
|
||||
/// Merchant Connector id to be stored for tax_calculator connector
|
||||
pub tax_connector_id: Option<String>,
|
||||
#[schema(value_type = Option<String>)]
|
||||
pub tax_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
|
||||
/// Indicates if tax_calculator connector is enabled or not.
|
||||
/// If set to `true` tax_connector_id will be checked.
|
||||
|
||||
@ -135,7 +135,7 @@ pub enum Connector {
|
||||
Square,
|
||||
Stax,
|
||||
Stripe,
|
||||
// Taxjar,
|
||||
Taxjar,
|
||||
Threedsecureio,
|
||||
Trustpay,
|
||||
Tsys,
|
||||
@ -215,7 +215,7 @@ impl Connector {
|
||||
// Add Separate authentication support for connectors
|
||||
// | Self::Novalnet
|
||||
// | Self::Nexixpay
|
||||
// | Self::Taxjar
|
||||
// | Self::Fiuu
|
||||
| Self::Adyen
|
||||
| Self::Adyenplatform
|
||||
| Self::Airwallex
|
||||
@ -264,6 +264,7 @@ impl Connector {
|
||||
| Self::Shift4
|
||||
| Self::Square
|
||||
| Self::Stax
|
||||
| Self::Taxjar
|
||||
| Self::Trustpay
|
||||
| Self::Tsys
|
||||
| Self::Volt
|
||||
@ -415,6 +416,26 @@ pub enum FrmConnectors {
|
||||
Riskified,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialEq,
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
strum::Display,
|
||||
strum::EnumString,
|
||||
ToSchema,
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
|
||||
pub enum TaxConnectors {
|
||||
Taxjar,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString, ToSchema,
|
||||
)]
|
||||
@ -656,6 +677,10 @@ pub fn convert_authentication_connector(connector_name: &str) -> Option<Authenti
|
||||
AuthenticationConnectors::from_str(connector_name).ok()
|
||||
}
|
||||
|
||||
pub fn convert_tax_connector(connector_name: &str) -> Option<TaxConnectors> {
|
||||
TaxConnectors::from_str(connector_name).ok()
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
|
||||
@ -20,7 +20,8 @@ use crate::{
|
||||
PaymentListFilterConstraints, PaymentListFilters, PaymentListFiltersV2,
|
||||
PaymentListResponse, PaymentListResponseV2, PaymentsAggregateResponse,
|
||||
PaymentsApproveRequest, PaymentsCancelRequest, PaymentsCaptureRequest,
|
||||
PaymentsCompleteAuthorizeRequest, PaymentsExternalAuthenticationRequest,
|
||||
PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest,
|
||||
PaymentsDynamicTaxCalculationResponse, PaymentsExternalAuthenticationRequest,
|
||||
PaymentsExternalAuthenticationResponse, PaymentsIncrementalAuthorizationRequest,
|
||||
PaymentsManualUpdateRequest, PaymentsManualUpdateResponse, PaymentsRejectRequest,
|
||||
PaymentsRequest, PaymentsResponse, PaymentsRetrieveRequest, PaymentsSessionResponse,
|
||||
@ -62,6 +63,16 @@ impl ApiEventMetric for PaymentsCompleteAuthorizeRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for PaymentsDynamicTaxCalculationRequest {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
payment_id: self.payment_id.clone(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiEventMetric for PaymentsDynamicTaxCalculationResponse {}
|
||||
|
||||
impl ApiEventMetric for PaymentsCancelRequest {
|
||||
fn get_api_event_type(&self) -> Option<ApiEventsType> {
|
||||
Some(ApiEventsType::Payment {
|
||||
|
||||
@ -294,6 +294,10 @@ pub struct PaymentsRequest {
|
||||
#[schema(value_type = Option<i64>, example = 6540)]
|
||||
pub amount_to_capture: Option<MinorUnit>,
|
||||
|
||||
/// The shipping cost for the payment. This is required for tax calculation in some regions.
|
||||
#[schema(value_type = Option<i64>, example = 6540)]
|
||||
pub shipping_cost: Option<MinorUnit>,
|
||||
|
||||
/// Unique identifier for the payment. This ensures idempotency for multiple payments
|
||||
/// that have been done by a single merchant. The value for this field can be specified in the request, it will be auto generated otherwise and returned in the API response.
|
||||
#[schema(
|
||||
@ -4391,6 +4395,8 @@ pub struct OrderDetailsWithAmount {
|
||||
pub brand: Option<String>,
|
||||
/// Type of the product that is being purchased
|
||||
pub product_type: Option<ProductType>,
|
||||
/// The tax code for the product
|
||||
pub product_tax_code: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
@ -4427,6 +4433,8 @@ pub struct OrderDetails {
|
||||
pub brand: Option<String>,
|
||||
/// Type of the product that is being purchased
|
||||
pub product_type: Option<ProductType>,
|
||||
/// The tax code for the product
|
||||
pub product_tax_code: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
|
||||
@ -4452,6 +4460,28 @@ pub struct PaymentsSessionRequest {
|
||||
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct PaymentsDynamicTaxCalculationRequest {
|
||||
/// The unique identifier for the payment
|
||||
#[serde(skip_deserializing)]
|
||||
#[schema(value_type = String)]
|
||||
pub payment_id: id_type::PaymentId,
|
||||
/// The shipping address for the payment
|
||||
pub shipping: Address,
|
||||
/// Client Secret
|
||||
#[schema(value_type = String)]
|
||||
pub client_secret: Secret<String>,
|
||||
/// Payment method type
|
||||
#[schema(value_type = PaymentMethodType)]
|
||||
pub payment_method_type: api_enums::PaymentMethodType,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
|
||||
pub struct PaymentsDynamicTaxCalculationResponse {
|
||||
/// net amount
|
||||
pub net_amount: MinorUnit,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
|
||||
pub struct GpayAllowedMethodsParameters {
|
||||
/// The list of allowed auth methods (ex: 3DS, No3DS, PAN_ONLY etc)
|
||||
|
||||
Reference in New Issue
Block a user