Skip to content

Commit

Permalink
feat(router): add payments create-intent flow for v2 (#6193)
Browse files Browse the repository at this point in the history
Co-authored-by: hrithikesh026 <[email protected]>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Hrithikesh <[email protected]>
  • Loading branch information
4 people authored Oct 17, 2024
1 parent 9576ee3 commit afa803e
Show file tree
Hide file tree
Showing 64 changed files with 2,004 additions and 282 deletions.
21 changes: 12 additions & 9 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -13446,7 +13446,7 @@
"payment_link_config": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentCreatePaymentLinkConfig"
"$ref": "#/components/schemas/PaymentLinkConfigRequest"
}
],
"nullable": true
Expand Down Expand Up @@ -13486,6 +13486,7 @@
"PaymentsCreateIntentResponse": {
"type": "object",
"required": [
"id",
"amount_details",
"client_secret",
"capture_method",
Expand All @@ -13495,9 +13496,14 @@
"apply_mit_exemption",
"payment_link_enabled",
"request_incremental_authorization",
"expires_on",
"request_external_three_ds_authentication"
],
"properties": {
"id": {
"type": "string",
"description": "Global Payment Id for the payment"
},
"amount_details": {
"$ref": "#/components/schemas/AmountDetails"
},
Expand Down Expand Up @@ -13626,21 +13632,18 @@
"payment_link_config": {
"allOf": [
{
"$ref": "#/components/schemas/PaymentCreatePaymentLinkConfig"
"$ref": "#/components/schemas/PaymentLinkConfigRequest"
}
],
"nullable": true
},
"request_incremental_authorization": {
"$ref": "#/components/schemas/RequestIncrementalAuthorization"
},
"session_expiry": {
"type": "integer",
"format": "int32",
"description": "Will be used to expire client secret after certain amount of time to be supplied in seconds, if not sent it will be taken from profile config\n(900) for 15 mins",
"example": 900,
"nullable": true,
"minimum": 0
"expires_on": {
"type": "string",
"format": "date-time",
"description": "Will be used to expire client secret after certain amount of time to be supplied in seconds"
},
"frm_metadata": {
"type": "object",
Expand Down
41 changes: 41 additions & 0 deletions crates/api_models/src/events/payment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use common_utils::events::{ApiEventMetric, ApiEventsType};

#[cfg(feature = "v2")]
use super::PaymentsCreateIntentRequest;
#[cfg(feature = "v2")]
use super::PaymentsCreateIntentResponse;
#[cfg(all(
any(feature = "v2", feature = "v1"),
not(feature = "payment_methods_v2")
Expand Down Expand Up @@ -29,6 +33,8 @@ use crate::{
PaymentsStartRequest, RedirectionResponse,
},
};

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsRetrieveRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
match self.resource_id {
Expand All @@ -40,6 +46,7 @@ impl ApiEventMetric for PaymentsRetrieveRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsStartRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -48,6 +55,7 @@ impl ApiEventMetric for PaymentsStartRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsCaptureRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -56,6 +64,7 @@ impl ApiEventMetric for PaymentsCaptureRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsCompleteAuthorizeRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -64,6 +73,7 @@ impl ApiEventMetric for PaymentsCompleteAuthorizeRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsDynamicTaxCalculationRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -72,6 +82,7 @@ impl ApiEventMetric for PaymentsDynamicTaxCalculationRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsPostSessionTokensRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -80,6 +91,7 @@ impl ApiEventMetric for PaymentsPostSessionTokensRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsPostSessionTokensResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -88,8 +100,10 @@ impl ApiEventMetric for PaymentsPostSessionTokensResponse {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsDynamicTaxCalculationResponse {}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsCancelRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -98,6 +112,7 @@ impl ApiEventMetric for PaymentsCancelRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsApproveRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -106,6 +121,7 @@ impl ApiEventMetric for PaymentsApproveRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsRejectRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -114,6 +130,7 @@ impl ApiEventMetric for PaymentsRejectRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
match self.payment_id {
Expand All @@ -125,6 +142,23 @@ impl ApiEventMetric for PaymentsRequest {
}
}

#[cfg(feature = "v2")]
impl ApiEventMetric for PaymentsCreateIntentRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
None
}
}

#[cfg(feature = "v2")]
impl ApiEventMetric for PaymentsCreateIntentResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
payment_id: self.id.clone(),
})
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand Down Expand Up @@ -262,6 +296,7 @@ impl ApiEventMetric for PaymentsAggregateResponse {

impl ApiEventMetric for RedirectionResponse {}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsIncrementalAuthorizationRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -270,8 +305,10 @@ impl ApiEventMetric for PaymentsIncrementalAuthorizationRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsExternalAuthenticationResponse {}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsExternalAuthenticationRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -280,8 +317,10 @@ impl ApiEventMetric for PaymentsExternalAuthenticationRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for ExtendedCardInfoResponse {}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsManualUpdateRequest {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -290,6 +329,7 @@ impl ApiEventMetric for PaymentsManualUpdateRequest {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsManualUpdateResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand All @@ -298,6 +338,7 @@ impl ApiEventMetric for PaymentsManualUpdateResponse {
}
}

#[cfg(feature = "v1")]
impl ApiEventMetric for PaymentsSessionResponse {
fn get_api_event_type(&self) -> Option<ApiEventsType> {
Some(ApiEventsType::Payment {
Expand Down
Loading

0 comments on commit afa803e

Please sign in to comment.