Skip to content

Commit c354e62

Browse files
feat(router): add support for partial authorization (#8833)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 654c15e commit c354e62

File tree

67 files changed

+537
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+537
-79
lines changed

api-reference/v1/openapi_spec_v1.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7972,6 +7972,7 @@
79727972
"void_failed",
79737973
"auto_refunded",
79747974
"partial_charged",
7975+
"partially_authorized",
79757976
"partial_charged_and_chargeable",
79767977
"unresolved",
79777978
"pending",
@@ -14810,6 +14811,7 @@
1481014811
"payment_cancelled",
1481114812
"payment_cancelled_post_capture",
1481214813
"payment_authorized",
14814+
"payment_partially_authorized",
1481314815
"payment_captured",
1481414816
"payment_expired",
1481514817
"action_required",
@@ -16665,6 +16667,7 @@
1666516667
"requires_capture",
1666616668
"partially_captured",
1666716669
"partially_captured_and_capturable",
16670+
"partially_authorized_and_requires_capture",
1666816671
"conflicted",
1666916672
"expired"
1667016673
]
@@ -22697,6 +22700,11 @@
2269722700
"format": "date-time",
2269822701
"description": "Date the payer placed the order.",
2269922702
"nullable": true
22703+
},
22704+
"enable_partial_authorization": {
22705+
"type": "boolean",
22706+
"description": "Allow partial authorization for this payment",
22707+
"nullable": true
2270022708
}
2270122709
}
2270222710
},
@@ -23165,6 +23173,11 @@
2316523173
"format": "date-time",
2316623174
"description": "Date the payer placed the order.",
2316723175
"nullable": true
23176+
},
23177+
"enable_partial_authorization": {
23178+
"type": "boolean",
23179+
"description": "Allow partial authorization for this payment",
23180+
"nullable": true
2316823181
}
2316923182
}
2317023183
},
@@ -23766,6 +23779,11 @@
2376623779
"type": "string",
2376723780
"description": "Contains whole connector response",
2376823781
"nullable": true
23782+
},
23783+
"enable_partial_authorization": {
23784+
"type": "boolean",
23785+
"description": "Allow partial authorization for this payment",
23786+
"nullable": true
2376923787
}
2377023788
}
2377123789
},
@@ -24524,6 +24542,11 @@
2452424542
"format": "date-time",
2452524543
"description": "Date the payer placed the order.",
2452624544
"nullable": true
24545+
},
24546+
"enable_partial_authorization": {
24547+
"type": "boolean",
24548+
"description": "Allow partial authorization for this payment",
24549+
"nullable": true
2452724550
}
2452824551
},
2452924552
"additionalProperties": false
@@ -25151,6 +25174,11 @@
2515125174
"type": "string",
2515225175
"description": "Contains whole connector response",
2515325176
"nullable": true
25177+
},
25178+
"enable_partial_authorization": {
25179+
"type": "boolean",
25180+
"description": "Allow partial authorization for this payment",
25181+
"nullable": true
2515425182
}
2515525183
}
2515625184
},
@@ -25752,6 +25780,11 @@
2575225780
"format": "date-time",
2575325781
"description": "Date the payer placed the order.",
2575425782
"nullable": true
25783+
},
25784+
"enable_partial_authorization": {
25785+
"type": "boolean",
25786+
"description": "Allow partial authorization for this payment",
25787+
"nullable": true
2575525788
}
2575625789
}
2575725790
},

api-reference/v2/openapi_spec_v2.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4909,6 +4909,7 @@
49094909
"void_failed",
49104910
"auto_refunded",
49114911
"partial_charged",
4912+
"partially_authorized",
49124913
"partial_charged_and_chargeable",
49134914
"unresolved",
49144915
"pending",
@@ -10786,6 +10787,7 @@
1078610787
"payment_cancelled",
1078710788
"payment_cancelled_post_capture",
1078810789
"payment_authorized",
10790+
"payment_partially_authorized",
1078910791
"payment_captured",
1079010792
"payment_expired",
1079110793
"action_required",
@@ -12753,6 +12755,7 @@
1275312755
"requires_capture",
1275412756
"partially_captured",
1275512757
"partially_captured_and_capturable",
12758+
"partially_authorized_and_requires_capture",
1275612759
"conflicted",
1275712760
"expired"
1275812761
]

crates/api_models/src/payments.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,9 @@ pub struct PaymentsRequest {
12141214
/// Date the payer placed the order.
12151215
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
12161216
pub order_date: Option<PrimitiveDateTime>,
1217+
1218+
/// Allow partial authorization for this payment
1219+
pub enable_partial_authorization: Option<bool>,
12171220
}
12181221

12191222
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
@@ -5272,6 +5275,9 @@ pub struct PaymentsResponse {
52725275
/// Contains whole connector response
52735276
#[schema(value_type = Option<String>)]
52745277
pub whole_connector_response: Option<Secret<String>>,
5278+
5279+
/// Allow partial authorization for this payment
5280+
pub enable_partial_authorization: Option<bool>,
52755281
}
52765282

52775283
#[cfg(feature = "v2")]

crates/common_enums/src/enums.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub enum AttemptStatus {
148148
VoidFailed,
149149
AutoRefunded,
150150
PartialCharged,
151+
PartiallyAuthorized,
151152
PartialChargedAndChargeable,
152153
Unresolved,
153154
#[default]
@@ -178,6 +179,7 @@ impl AttemptStatus {
178179
| Self::AuthenticationPending
179180
| Self::AuthenticationSuccessful
180181
| Self::Authorized
182+
| Self::PartiallyAuthorized
181183
| Self::AuthorizationFailed
182184
| Self::Authorizing
183185
| Self::CodInitiated
@@ -1560,6 +1562,7 @@ pub enum EventType {
15601562
PaymentCancelled,
15611563
PaymentCancelledPostCapture,
15621564
PaymentAuthorized,
1565+
PaymentPartiallyAuthorized,
15631566
PaymentCaptured,
15641567
PaymentExpired,
15651568
ActionRequired,
@@ -1683,6 +1686,8 @@ pub enum IntentStatus {
16831686
PartiallyCaptured,
16841687
/// The payment has been captured partially and the remaining amount is capturable
16851688
PartiallyCapturedAndCapturable,
1689+
/// The payment has been authorized for a partial amount and requires capture
1690+
PartiallyAuthorizedAndRequiresCapture,
16861691
/// There has been a discrepancy between the amount/currency sent in the request and the amount/currency received by the processor
16871692
Conflicted,
16881693
/// The payment expired before it could be captured.
@@ -1706,6 +1711,7 @@ impl IntentStatus {
17061711
| Self::RequiresConfirmation
17071712
| Self::RequiresCapture
17081713
| Self::PartiallyCapturedAndCapturable
1714+
| Self::PartiallyAuthorizedAndRequiresCapture
17091715
| Self::Conflicted => false,
17101716
}
17111717
}
@@ -1727,7 +1733,7 @@ impl IntentStatus {
17271733
| Self::RequiresCustomerAction
17281734
| Self::RequiresMerchantAction
17291735
| Self::PartiallyCapturedAndCapturable
1730-
=> true,
1736+
| Self::PartiallyAuthorizedAndRequiresCapture => true,
17311737
}
17321738
}
17331739
}
@@ -1853,6 +1859,7 @@ impl From<AttemptStatus> for PaymentMethodStatus {
18531859
| AttemptStatus::AutoRefunded
18541860
| AttemptStatus::PartialCharged
18551861
| AttemptStatus::PartialChargedAndChargeable
1862+
| AttemptStatus::PartiallyAuthorized
18561863
| AttemptStatus::ConfirmationAwaited
18571864
| AttemptStatus::DeviceDataCollectionPending
18581865
| AttemptStatus::IntegrityFailure

crates/common_enums/src/transformers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,7 @@ impl From<AttemptStatus> for IntentStatus {
21252125
AttemptStatus::Voided => Self::Cancelled,
21262126
AttemptStatus::VoidedPostCharge => Self::CancelledPostCapture,
21272127
AttemptStatus::Expired => Self::Expired,
2128+
AttemptStatus::PartiallyAuthorized => Self::PartiallyAuthorizedAndRequiresCapture,
21282129
}
21292130
}
21302131
}
@@ -2146,6 +2147,9 @@ impl From<IntentStatus> for Option<EventType> {
21462147
}
21472148
IntentStatus::RequiresCapture => Some(EventType::PaymentAuthorized),
21482149
IntentStatus::RequiresPaymentMethod | IntentStatus::RequiresConfirmation => None,
2150+
IntentStatus::PartiallyAuthorizedAndRequiresCapture => {
2151+
Some(EventType::PaymentPartiallyAuthorized)
2152+
}
21492153
}
21502154
}
21512155
}

crates/diesel_models/src/payment_attempt.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ pub enum PaymentAttemptUpdate {
487487
straight_through_algorithm: Option<serde_json::Value>,
488488
error_code: Option<Option<String>>,
489489
error_message: Option<Option<String>>,
490-
amount_capturable: Option<MinorUnit>,
491490
surcharge_amount: Option<MinorUnit>,
492491
tax_amount: Option<MinorUnit>,
493492
fingerprint_id: Option<String>,
@@ -2461,7 +2460,6 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
24612460
straight_through_algorithm,
24622461
error_code,
24632462
error_message,
2464-
amount_capturable,
24652463
updated_by,
24662464
merchant_connector_id,
24672465
surcharge_amount,
@@ -2498,7 +2496,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
24982496
straight_through_algorithm,
24992497
error_code,
25002498
error_message,
2501-
amount_capturable,
2499+
amount_capturable: None,
25022500
updated_by,
25032501
merchant_connector_id: merchant_connector_id.map(Some),
25042502
surcharge_amount,

0 commit comments

Comments
 (0)