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): payments overcapture support for V1 #6824

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e5b3cb7
feat(router): add always_request_overcapture to business_profile
AkshayaFoiger Dec 9, 2024
86091fd
feat(core): add field request_overcapture to payment_intent
AkshayaFoiger Dec 11, 2024
48d2eff
fix(clippy_v2): make always_request_overcapture optional in ProfileUp…
AkshayaFoiger Dec 11, 2024
2f49343
chore: generate openapi_spec
AkshayaFoiger Dec 11, 2024
4ad3cd3
chore: run formatter
hyperswitch-bot[bot] Dec 12, 2024
2b7c165
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Dec 12, 2024
251ccc1
feat(router): add parameters to payment_attepmt and router data
AkshayaFoiger Dec 15, 2024
0af1c04
feat(router): add fields to PaymentResponse
AkshayaFoiger Dec 15, 2024
41f5d38
Merge branch 'main' into over-capture
AkshayaFoiger Dec 16, 2024
c3e7343
chore: run formatter
hyperswitch-bot[bot] Dec 16, 2024
1c1510f
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Dec 16, 2024
702da2d
refactor(router): Remove fields from PaymentAttemptUpdate
AkshayaFoiger Dec 19, 2024
3641266
refactor(router): add overcapture validation to validate_amount_to_ca…
AkshayaFoiger Dec 19, 2024
b54e293
refactor(core): change the struct of overcapture request data
AkshayaFoiger Dec 23, 2024
bd8d0a0
chore: remove logger
AkshayaFoiger Dec 23, 2024
a4617b6
fix(connector): rename StripeOvercaptureStatus values
AkshayaFoiger Dec 23, 2024
1f14100
Merge branch 'main' into over-capture
AkshayaFoiger Dec 23, 2024
e7e8f38
chore: resolve conflicts
AkshayaFoiger Dec 23, 2024
e87b8d6
chore: fix formatting errors
AkshayaFoiger Dec 23, 2024
6436466
chroe: fix spell check error
AkshayaFoiger Dec 23, 2024
7c37b4d
chore: remove get_should_always_enable_overcapture()
AkshayaFoiger Dec 24, 2024
fa626b1
chore: remove logger
AkshayaFoiger Dec 24, 2024
d017d89
Merge branch 'main' into over-capture
AkshayaFoiger Dec 24, 2024
e1ef76e
Merge branch 'main' into over-capture
AkshayaFoiger Dec 24, 2024
e5250e7
chore: fix cypress test
AkshayaFoiger Dec 24, 2024
d0fb6c7
chore: fix diesel migration error
AkshayaFoiger Dec 24, 2024
2ce4a12
Merge branch 'main' into over-capture
AkshayaFoiger Dec 24, 2024
2e06db8
fix(router): add fields to schema_v2.rs
AkshayaFoiger Dec 26, 2024
00e953a
fix(router): remove overcapture_details from v2 PaymentAttempt Update
AkshayaFoiger Dec 26, 2024
c72690f
chore: run formatter
hyperswitch-bot[bot] Dec 26, 2024
a10e7aa
fix(core): Add overcapture_details to payment attempt for manual capture
AkshayaFoiger Dec 27, 2024
f6503f0
chore: run formatter
hyperswitch-bot[bot] Dec 27, 2024
f6fad46
fix(clippy): add v1 flag to update_or_add_overcapture_details_if_requ…
AkshayaFoiger Dec 27, 2024
0ad3547
refactor(core): remove request_overcapture from router data connecto…
AkshayaFoiger Jan 3, 2025
8b0523e
refactor(core): add request_overcapture to PaymentsAuthorizeData
AkshayaFoiger Jan 3, 2025
2386449
refactor(router): remove overcapture_applied and maximum_amount_captu…
AkshayaFoiger Jan 6, 2025
a7ad547
chore: run formatter
hyperswitch-bot[bot] Jan 6, 2025
a5d2d22
chore: undo DB changes
AkshayaFoiger Jan 6, 2025
7cf1a5f
refactor(router): add overcapture_applied to ConnectorResponseData
AkshayaFoiger Jan 6, 2025
0da2fba
refactor(core): replace overcapture_data with overcapture_applied and…
AkshayaFoiger Jan 6, 2025
132a124
chore: run formatter
hyperswitch-bot[bot] Jan 6, 2025
61a6ddb
refactor(router): remove maximum_capturable_amount from PaymentsResponse
AkshayaFoiger Jan 6, 2025
a5e03da
refactor(router): change the datatype of overcapture_data
AkshayaFoiger Jan 6, 2025
e6fb341
refactor(router): undo debug statements and comments, impl in stripe
AkshayaFoiger Jan 7, 2025
4d844f8
chore: run formatter
hyperswitch-bot[bot] Jan 7, 2025
b82bf8c
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jan 7, 2025
1fdff4f
chore: fix clippy errors
AkshayaFoiger Jan 7, 2025
bac2bad
chore: run formatter
hyperswitch-bot[bot] Jan 7, 2025
69a8282
Merge branch 'main' into over-capture
AkshayaFoiger Jan 7, 2025
b081c08
refactor(core): change the datatype of request_overcapture and overca…
AkshayaFoiger Jan 7, 2025
794aea5
chore: fix v2 clippy error
AkshayaFoiger Jan 7, 2025
09cbc25
chore: fix clippy error
AkshayaFoiger Jan 8, 2025
c5a8f45
Update crates/router/src/connector/utils.rs
AkshayaFoiger Jan 8, 2025
772edc6
chore: run formatter
hyperswitch-bot[bot] Jan 8, 2025
5bfc439
refactor(router): fix comments
AkshayaFoiger Jan 8, 2025
70b8d58
chore: run formatter
hyperswitch-bot[bot] Jan 8, 2025
5b1ce51
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jan 8, 2025
dc4875f
refactor(router): replace or with unwrap_or
AkshayaFoiger Jan 8, 2025
ea75734
chore: fix clippy errors
AkshayaFoiger Jan 9, 2025
97252aa
refactor(router): remove request_overcapture from v2 PaymentsRequest
AkshayaFoiger Jan 9, 2025
05625ce
chore: run formatter
hyperswitch-bot[bot] Jan 9, 2025
02a2c7f
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jan 9, 2025
376d0fa
refactor(core): change the error message
AkshayaFoiger Jan 9, 2025
555c33c
refactor(router): update request_overcapture during confirm call
AkshayaFoiger Jan 12, 2025
b38ff2e
chore: run formatter
hyperswitch-bot[bot] Jan 12, 2025
754bd56
refactor(router): resolve comment
AkshayaFoiger Jan 21, 2025
d3ff1f3
Merge branch 'main' into over-capture
AkshayaFoiger Jan 21, 2025
d4563d3
Merge branch 'main' into over-capture
AkshayaFoiger Jan 22, 2025
92ffe4c
chore: run formatter
hyperswitch-bot[bot] Jan 22, 2025
b9ed824
refaactor(router): remove is_enabled for overcapturerequest
AkshayaFoiger Jan 22, 2025
895c8cf
remove the impl function
AkshayaFoiger Jan 22, 2025
b75a2a8
chore: run formatter
hyperswitch-bot[bot] Jan 22, 2025
ab38c58
Merge branch 'main' into over-capture
AkshayaFoiger Jan 22, 2025
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
32 changes: 32 additions & 0 deletions api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -12397,6 +12397,22 @@
}
}
},
"OverCaptureRequest": {
"type": "string",
"description": "Whether overcapture is requested or not",
"enum": [
"enable",
"skip"
]
},
"OverCaptureStatus": {
"type": "string",
"description": "Whether overcapture is allowed by the connector",
"enum": [
"applicable",
"not_applicable"
]
},
"PayLaterData": {
"oneOf": [
{
Expand Down Expand Up @@ -15476,6 +15492,14 @@
"type": "string",
"description": "Connector Identifier for the payment method",
"nullable": true
},
"overcapture_status": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureStatus"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -16376,6 +16400,14 @@
"type": "string",
"description": "Connector Identifier for the payment method",
"nullable": true
},
"overcapture_status": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureStatus"
}
],
"nullable": true
}
}
},
Expand Down
76 changes: 76 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -15517,6 +15517,22 @@
}
}
},
"OverCaptureRequest": {
"type": "string",
"description": "Whether overcapture is requested or not",
"enum": [
"enable",
"skip"
]
},
"OverCaptureStatus": {
"type": "string",
"description": "Whether overcapture is allowed by the connector",
"enum": [
"applicable",
"not_applicable"
]
},
"PayLaterData": {
"oneOf": [
{
Expand Down Expand Up @@ -17904,6 +17920,14 @@
}
],
"nullable": true
},
"request_overcapture": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureRequest"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -18297,6 +18321,14 @@
}
],
"nullable": true
},
"request_overcapture": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureRequest"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -18836,6 +18868,14 @@
"type": "string",
"description": "Connector Identifier for the payment method",
"nullable": true
},
"overcapture_status": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureStatus"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -19514,6 +19554,14 @@
}
],
"nullable": true
},
"request_overcapture": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureRequest"
}
],
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -20079,6 +20127,14 @@
"type": "string",
"description": "Connector Identifier for the payment method",
"nullable": true
},
"overcapture_status": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureStatus"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -20570,6 +20626,14 @@
}
],
"nullable": true
},
"request_overcapture": {
"allOf": [
{
"$ref": "#/components/schemas/OverCaptureRequest"
}
],
"nullable": true
}
}
},
Expand Down Expand Up @@ -22536,6 +22600,11 @@
"type": "object",
"description": "Product authentication ids",
"nullable": true
},
"always_request_overcapture": {
"type": "boolean",
"description": "Indicates if the overcapture is always requested or not.",
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -22777,6 +22846,13 @@
"type": "object",
"description": "Product authentication ids",
"nullable": true
},
"always_request_overcapture": {
"type": "boolean",
"description": "Indicates if the overcapture is always requested or not.",
"default": false,
"example": false,
"nullable": true
}
}
},
Expand Down
12 changes: 12 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,10 @@ pub struct ProfileCreate {
/// Product authentication ids
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub authentication_product_ids: Option<HashMap<String, id_type::MerchantConnectorAccountId>>,

/// Indicates if the overcapture is always requested or not.
#[serde(default)]
pub always_request_overcapture: Option<bool>,
AkshayaFoiger marked this conversation as resolved.
Show resolved Hide resolved
}

#[nutype::nutype(
Expand Down Expand Up @@ -2117,6 +2121,10 @@ pub struct ProfileResponse {
/// Product authentication ids
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub authentication_product_ids: Option<serde_json::Value>,

/// Indicates if the overcapture is always requested or not.
#[schema(default = false, example = false)]
pub always_request_overcapture: Option<bool>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -2370,6 +2378,10 @@ pub struct ProfileUpdate {
/// Product authentication ids
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)]
pub authentication_product_ids: Option<HashMap<String, id_type::MerchantConnectorAccountId>>,

/// Indicates if the overcapture is always requested or not.
#[schema(default = false, example = false)]
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no default false during ProfileUpdate

pub always_request_overcapture: Option<bool>,
}

#[cfg(feature = "v2")]
Expand Down
8 changes: 8 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ pub struct PaymentsRequest {
/// Service details for click to pay external authentication
#[schema(value_type = Option<CtpServiceDetails>)]
pub ctp_service_details: Option<CtpServiceDetails>,

/// Whether to request overcapture on this payment
#[schema(value_type = Option<OverCaptureRequest>)]
pub request_overcapture: Option<api_enums::OverCaptureRequest>,
}

#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
Expand Down Expand Up @@ -4746,6 +4750,10 @@ pub struct PaymentsResponse {

/// Connector Identifier for the payment method
pub connector_mandate_id: Option<String>,

/// Whether the payment is overcaptureable or not
#[schema(value_type = Option<OverCaptureStatus>)]
pub overcapture_status: Option<common_enums::OverCaptureStatus>,
}

// Serialize is implemented because, this will be serialized in the api events.
Expand Down
2 changes: 1 addition & 1 deletion crates/common_enums/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ openapi = []
payouts = []

[dependencies]
diesel = { version = "2.2.3", features = ["postgres"] }
diesel = { version = "2.2.3", features = ["postgres", "128-column-tables"]}
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
strum = { version = "0.26", features = ["derive"] }
Expand Down
54 changes: 54 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3379,6 +3379,60 @@ pub enum External3dsAuthenticationRequest {
Skip,
}

/// Whether overcapture is requested or not
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
Hash,
PartialEq,
ToSchema,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumIter,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum OverCaptureRequest {
/// Request for applying overcapture
Enable,
/// Skip overcapture
#[default]
Skip,
}

/// Whether overcapture is allowed by the connector
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
Hash,
PartialEq,
ToSchema,
serde::Deserialize,
serde::Serialize,
strum::Display,
strum::EnumIter,
strum::EnumString,
)]
#[router_derive::diesel_enum(storage_type = "text")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum OverCaptureStatus {
/// Overcapture is allowed
Applicable,
/// Overcapture is not allowed
#[default]
NotApplicable,
}

/// Whether payment link is requested to be enabled or not for this transaction
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, Default, ToSchema)]
pub enum EnablePaymentLinkRequest {
Expand Down
38 changes: 38 additions & 0 deletions crates/common_enums/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,44 @@ impl super::External3dsAuthenticationRequest {
}
}

impl From<bool> for super::OverCaptureRequest {
fn from(value: bool) -> Self {
match value {
true => Self::Enable,
_ => Self::Skip,
}
}
}

/// Get the boolean value of the `OverCaptureRequest`.
impl super::OverCaptureRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Enable => true,
Self::Skip => false,
}
}
}

impl From<Option<bool>> for super::OverCaptureStatus {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Applicable,
_ => Self::NotApplicable,
}
}
}

/// Get the boolean value of the `OverCaptureStatus`.
impl super::OverCaptureStatus {
pub fn as_bool(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

All of this bool conversions could simply be impl based fns, something like OverCaptureStatus::is_applicable()

match self {
Self::Applicable => true,
Self::NotApplicable => false,
}
}
}

impl super::EnablePaymentLinkRequest {
pub fn as_bool(&self) -> bool {
match self {
Expand Down
2 changes: 1 addition & 1 deletion crates/diesel_models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ payment_methods_v2 = []

[dependencies]
async-bb8-diesel = { git = "https://github.com/jarnura/async-bb8-diesel", rev = "53b4ab901aab7635c8215fd1c2d542c8db443094" }
diesel = { version = "2.2.3", features = ["postgres", "serde_json", "time", "64-column-tables"] }
diesel = { version = "2.2.3", features = ["postgres", "serde_json", "time", "128-column-tables"] }
error-stack = "0.4.1"
rustc-hash = "1.1.0"
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
Loading
Loading