Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add Support for Payments Dynamic Tax Calculation Based on Shipping Address #5619

Merged
merged 50 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6c808db
feat: add taxjar api
swangi-kumari Aug 10, 2024
6cf9a5a
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 13, 2024
b6514e0
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 13, 2024
9564f4e
chore: run formatter
hyperswitch-bot[bot] Aug 13, 2024
39f8e50
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Aug 13, 2024
337b7ba
refactor: merege main
swangi-kumari Aug 13, 2024
4bc9a19
Merge branch 'tax-jar-api' of https://github.com/juspay/hyperswitch i…
swangi-kumari Aug 13, 2024
461c6aa
refactor: resolve clippy
swangi-kumari Aug 13, 2024
bc79ada
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 16, 2024
3cd1f09
feat: update order_tax_amount in payment_data_payment_intent_tax_details
swangi-kumari Aug 22, 2024
60cbfb1
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 22, 2024
51f8c11
refactor: formatting
swangi-kumari Aug 22, 2024
72e9e13
refactor: resolve clippy errors
swangi-kumari Aug 22, 2024
0428e30
refactor: add session update api
swangi-kumari Aug 22, 2024
7441b2b
refactor: change type of shipping and order details
swangi-kumari Aug 23, 2024
73d7923
chore: run formatter
hyperswitch-bot[bot] Aug 23, 2024
a27d6af
refactor: tax jar integration
swangi-kumari Aug 24, 2024
778a14f
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Aug 24, 2024
a794c41
feat: update trackers
swangi-kumari Aug 24, 2024
0d4243b
Merge branch 'tax-jar-api' of https://github.com/juspay/hyperswitch i…
swangi-kumari Aug 25, 2024
d888f61
feat: call tax jar in payment create and update
swangi-kumari Aug 25, 2024
503d79d
feat: connector call succesfu
swangi-kumari Aug 27, 2024
9f8589d
refactor: formatting
swangi-kumari Aug 27, 2024
541af03
refactor: add shipping_addres_id
swangi-kumari Aug 27, 2024
82db69f
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 27, 2024
1533be1
refactor: update shipping add id and populate net amount in response
swangi-kumari Aug 27, 2024
5e03bbd
refactor: remove println and some refactoring
swangi-kumari Aug 28, 2024
ea3decd
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Aug 28, 2024
4785eae
refactor: solve clippy and generate schema_v2
swangi-kumari Aug 29, 2024
52b7dbf
refactor: rename trait
swangi-kumari Aug 30, 2024
3702622
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Sep 2, 2024
d64919c
refactor: generate open-api
swangi-kumari Sep 2, 2024
7669161
refactor: clippy
swangi-kumari Sep 2, 2024
f87bfe3
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Sep 2, 2024
03a932b
refactor: resolve conflicts
swangi-kumari Sep 3, 2024
57f6678
refactor: resolve comments
swangi-kumari Sep 3, 2024
090b345
refactor: add Dynamic Tax Calculation to openapi
swangi-kumari Sep 3, 2024
128e2fe
refactor: resolve comments
swangi-kumari Sep 4, 2024
4de2043
refactor: update payment_method_type in payment attempt of get tracker
swangi-kumari Sep 4, 2024
4714515
refactor: amount changes
swangi-kumari Sep 4, 2024
59275e0
refactor: resolve comments
swangi-kumari Sep 4, 2024
b645321
refactor: add update_by and shipping details
swangi-kumari Sep 4, 2024
5636e60
refactor: amount
swangi-kumari Sep 4, 2024
b1e6041
refactor: remove
swangi-kumari Sep 4, 2024
398d845
Merge remote-tracking branch 'origin' into tax-jar-api
swangi-kumari Sep 4, 2024
4b0d9aa
refactor: solve clippy
swangi-kumari Sep 4, 2024
0b69be0
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Sep 4, 2024
09d8890
refactor: resolve clippy_v2
swangi-kumari Sep 5, 2024
ee4782d
refactor: fix
swangi-kumari Sep 5, 2024
05932ee
refactor: resolve comments
swangi-kumari Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4508,6 +4508,7 @@
"square",
"stax",
"stripe",
"taxjar",
"threedsecureio",
"trustpay",
"tsys",
Expand Down Expand Up @@ -4622,7 +4623,8 @@
"non_banking_finance",
"payout_processor",
"payment_method_auth",
"authentication_processor"
"authentication_processor",
"tax_processor"
]
},
"ConnectorVolumeSplit": {
Expand Down Expand Up @@ -9336,6 +9338,11 @@
}
],
"nullable": true
},
"product_tax_code": {
"type": "string",
"description": "The tax code for the product",
"nullable": true
}
}
},
Expand Down Expand Up @@ -9401,6 +9408,11 @@
}
],
"nullable": true
},
"product_tax_code": {
"type": "string",
"description": "The tax code for the product",
"nullable": true
}
}
},
Expand Down Expand Up @@ -11580,6 +11592,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -11925,6 +11944,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -12898,6 +12924,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -13996,6 +14029,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down
62 changes: 61 additions & 1 deletion api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -8155,6 +8155,7 @@
"square",
"stax",
"stripe",
"taxjar",
"threedsecureio",
"trustpay",
"tsys",
Expand Down Expand Up @@ -8269,7 +8270,8 @@
"non_banking_finance",
"payout_processor",
"payment_method_auth",
"authentication_processor"
"authentication_processor",
"tax_processor"
]
},
"ConnectorVolumeSplit": {
Expand Down Expand Up @@ -13346,6 +13348,11 @@
}
],
"nullable": true
},
"product_tax_code": {
"type": "string",
"description": "The tax code for the product",
"nullable": true
}
}
},
Expand Down Expand Up @@ -13411,6 +13418,11 @@
}
],
"nullable": true
},
"product_tax_code": {
"type": "string",
"description": "The tax code for the product",
"nullable": true
}
}
},
Expand Down Expand Up @@ -15583,6 +15595,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -15928,6 +15947,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -16782,6 +16808,26 @@
}
}
},
"PaymentsDynamicTaxCalculationRequest": {
"type": "object",
"required": [
"shipping",
"client_secret",
"payment_method_type"
],
"properties": {
"shipping": {
"$ref": "#/components/schemas/Address"
},
"client_secret": {
"type": "string",
"description": "Client Secret"
},
"payment_method_type": {
"$ref": "#/components/schemas/PaymentMethodType"
}
}
},
"PaymentsExternalAuthenticationRequest": {
"type": "object",
"required": [
Expand Down Expand Up @@ -16901,6 +16947,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down Expand Up @@ -17999,6 +18052,13 @@
"example": 6540,
"nullable": true
},
"shipping_cost": {
"type": "integer",
"format": "int64",
"description": "The shipping cost for the payment. This is required for tax calculation in some regions.",
"example": 6540,
"nullable": true
},
"payment_id": {
"type": "string",
"description": "Unique identifier for the payment. This ensures idempotency for multiple payments\nthat 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.",
Expand Down
18 changes: 12 additions & 6 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
29 changes: 27 additions & 2 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub enum Connector {
Square,
Stax,
Stripe,
// Taxjar,
Taxjar,
Threedsecureio,
Trustpay,
Tsys,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -264,6 +264,7 @@ impl Connector {
| Self::Shift4
| Self::Square
| Self::Stax
| Self::Taxjar
| Self::Trustpay
| Self::Tsys
| Self::Volt
Expand Down Expand Up @@ -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,
)]
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion crates/api_models/src/events/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
})
Comment on lines +68 to +70
Copy link
Member

Choose a reason for hiding this comment

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

Is this part of the payment lifecycle ?,
if not this can be none

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this is part of payment life cycle.

}
}

impl ApiEventMetric for PaymentsDynamicTaxCalculationResponse {}

impl ApiEventMetric for PaymentsCancelRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand Down
Loading
Loading