Skip to content

Commit 7afc44e

Browse files
Narayanbhat166AkshayaFoigerhyperswitch-bot[bot]
authored
feat: store payment check codes and authentication data from processors (#3958)
Co-authored-by: AkshayaFoiger <[email protected]> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent f3141ec commit 7afc44e

File tree

39 files changed

+1065
-16
lines changed

39 files changed

+1065
-16
lines changed

crates/api_models/src/payments.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ impl PaymentMethodData {
12401240
self.to_owned()
12411241
}
12421242
}
1243+
12431244
pub fn get_payment_method(&self) -> Option<api_enums::PaymentMethod> {
12441245
match self {
12451246
Self::Card(_) => Some(api_enums::PaymentMethod::Card),
@@ -1443,17 +1444,40 @@ pub struct GiftCardDetails {
14431444
#[derive(Default, Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
14441445
#[serde(rename_all = "snake_case")]
14451446
pub struct AdditionalCardInfo {
1447+
/// The name of issuer of the card
14461448
pub card_issuer: Option<String>,
1449+
1450+
/// Card network of the card
14471451
pub card_network: Option<api_enums::CardNetwork>,
1452+
1453+
/// Card type, can be either `credit` or `debit`
14481454
pub card_type: Option<String>,
1455+
14491456
pub card_issuing_country: Option<String>,
14501457
pub bank_code: Option<String>,
1458+
1459+
/// Last 4 digits of the card number
14511460
pub last4: Option<String>,
1461+
1462+
/// The ISIN of the card
14521463
pub card_isin: Option<String>,
1464+
1465+
/// Extended bin of card, contains the first 8 digits of card number
14531466
pub card_extended_bin: Option<String>,
1467+
14541468
pub card_exp_month: Option<Secret<String>>,
1469+
14551470
pub card_exp_year: Option<Secret<String>>,
1471+
14561472
pub card_holder_name: Option<Secret<String>>,
1473+
1474+
/// Additional payment checks done on the cvv and billing address by the processors.
1475+
/// This is a free form field and the structure varies from processor to processor
1476+
pub payment_checks: Option<serde_json::Value>,
1477+
1478+
/// Details about the threeds environment.
1479+
/// This is a free form field and the structure varies from processor to processor
1480+
pub authentication_data: Option<serde_json::Value>,
14571481
}
14581482

14591483
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
@@ -2001,6 +2025,8 @@ pub struct CardResponse {
20012025
pub card_exp_month: Option<Secret<String>>,
20022026
pub card_exp_year: Option<Secret<String>>,
20032027
pub card_holder_name: Option<Secret<String>>,
2028+
pub payment_checks: Option<serde_json::Value>,
2029+
pub authentication_data: Option<serde_json::Value>,
20042030
}
20052031

20062032
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
@@ -3003,6 +3029,8 @@ impl From<AdditionalCardInfo> for CardResponse {
30033029
card_exp_month: card.card_exp_month,
30043030
card_exp_year: card.card_exp_year,
30053031
card_holder_name: card.card_holder_name,
3032+
payment_checks: card.payment_checks,
3033+
authentication_data: card.authentication_data,
30063034
}
30073035
}
30083036
}

crates/data_models/src/payments/payment_attempt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ pub enum PaymentAttemptUpdate {
361361
encoded_data: Option<String>,
362362
unified_code: Option<Option<String>>,
363363
unified_message: Option<Option<String>>,
364+
payment_method_data: Option<serde_json::Value>,
364365
},
365366
UnresolvedResponseUpdate {
366367
status: storage_enums::AttemptStatus,
@@ -388,6 +389,7 @@ pub enum PaymentAttemptUpdate {
388389
unified_code: Option<Option<String>>,
389390
unified_message: Option<Option<String>>,
390391
connector_transaction_id: Option<String>,
392+
payment_method_data: Option<serde_json::Value>,
391393
},
392394
CaptureUpdate {
393395
amount_to_capture: Option<i64>,

crates/diesel_models/src/payment_attempt.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub enum PaymentAttemptUpdate {
268268
encoded_data: Option<String>,
269269
unified_code: Option<Option<String>>,
270270
unified_message: Option<Option<String>>,
271+
payment_method_data: Option<serde_json::Value>,
271272
},
272273
UnresolvedResponseUpdate {
273274
status: storage_enums::AttemptStatus,
@@ -295,6 +296,7 @@ pub enum PaymentAttemptUpdate {
295296
unified_code: Option<Option<String>>,
296297
unified_message: Option<Option<String>>,
297298
connector_transaction_id: Option<String>,
299+
payment_method_data: Option<serde_json::Value>,
298300
},
299301
CaptureUpdate {
300302
amount_to_capture: Option<i64>,
@@ -661,6 +663,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
661663
encoded_data,
662664
unified_code,
663665
unified_message,
666+
payment_method_data,
664667
} => Self {
665668
status: Some(status),
666669
connector: connector.map(Some),
@@ -681,6 +684,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
681684
encoded_data,
682685
unified_code,
683686
unified_message,
687+
payment_method_data,
684688
..Default::default()
685689
},
686690
PaymentAttemptUpdate::ErrorUpdate {
@@ -694,6 +698,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
694698
unified_code,
695699
unified_message,
696700
connector_transaction_id,
701+
payment_method_data,
697702
} => Self {
698703
connector: connector.map(Some),
699704
status: Some(status),
@@ -706,6 +711,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
706711
unified_code,
707712
unified_message,
708713
connector_transaction_id,
714+
payment_method_data,
709715
..Default::default()
710716
},
711717
PaymentAttemptUpdate::StatusUpdate { status, updated_by } => Self {

crates/router/src/connector/stripe.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,10 @@ impl
673673

674674
match id.get_connector_transaction_id() {
675675
Ok(x) if x.starts_with("set") => Ok(format!(
676-
"{}{}/{}",
676+
"{}{}/{}?expand[0]=latest_attempt", // expand latest attempt to extract payment checks and three_d_secure data
677677
self.base_url(connectors),
678678
"v1/setup_intents",
679-
x
679+
x,
680680
)),
681681
Ok(x) => Ok(format!(
682682
"{}{}/{}{}",
@@ -711,7 +711,6 @@ impl
711711
res: types::Response,
712712
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError>
713713
where
714-
types::PaymentsAuthorizeData: Clone,
715714
types::PaymentsResponseData: Clone,
716715
{
717716
let id = data.request.connector_transaction_id.clone();

0 commit comments

Comments
 (0)