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(payment_methods): bank details support for payment method data in pmt #2385

Merged
merged 21 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
945fae2
feat(mca): Updated mca schema to accomodate for pm_auth_config
Sarthak1799 Sep 13, 2023
dd3087f
Merge branch 'main' into plaid-connector
Sarthak1799 Sep 14, 2023
51fd539
fix(mca): Updated mca query
Sarthak1799 Sep 16, 2023
2a66832
Merge branch 'main' into plaid-connector
Sarthak1799 Sep 16, 2023
6dc3c9b
fix(mca): Schema fix
Sarthak1799 Sep 16, 2023
43e827b
Revert "fix(mca): Schema fix"
Sarthak1799 Sep 16, 2023
d2247a3
fix(mca): Fixed schema
Sarthak1799 Sep 16, 2023
1036b73
fix(pm_auth): Fixed connector enum match
Sarthak1799 Sep 18, 2023
d35032a
fix(migration): Fixed migration inconsistencies
Sarthak1799 Sep 18, 2023
1b44bbb
fix(mca): Fixed clippy errors
Sarthak1799 Sep 18, 2023
d5df52a
fix(pm_auth): Fixed openApi Sepc
Sarthak1799 Sep 20, 2023
23b30c4
Merge remote-tracking branch 'origin/main' into plaid-connector
Sarthak1799 Sep 20, 2023
455f79c
Merge branch 'main' into plaid-connector
Sarthak1799 Sep 25, 2023
299462d
feat(pm_auth): Support for bank details in pmd
Sarthak1799 Sep 25, 2023
5fd770c
Merge branch 'plaid-connector' of github.com:juspay/hyperswitch into …
Sarthak1799 Sep 25, 2023
9a332e9
fix(pm_auth): Fixed imports
Sarthak1799 Sep 26, 2023
dee966a
Merge branch 'main' into plaid-connector
Sarthak1799 Sep 27, 2023
0740a29
Merge branch 'main' into plaid-connector
Sarthak1799 Sep 27, 2023
61bb607
Merge branch 'plaid-connector' of github.com:juspay/hyperswitch into …
Sarthak1799 Sep 27, 2023
39521ae
refactor(payment_methods): Refactored bank account access creds
Sarthak1799 Oct 3, 2023
e37177d
Merge branch 'main' into pmd-bank-details
Sarthak1799 Oct 4, 2023
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
20 changes: 20 additions & 0 deletions crates/api_models/src/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub struct PaymentMethodResponse {
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum PaymentMethodsData {
Card(CardDetailsPaymentMethod),
BankDetails(PaymentMethodDataBankCreds),
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct CardDetailsPaymentMethod {
Expand All @@ -158,6 +159,25 @@ pub struct CardDetailsPaymentMethod {
pub card_holder_name: Option<masking::Secret<String>>,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct PaymentMethodDataBankCreds {
pub mask: String,
pub hash: String,
pub payment_method_type: api_enums::PaymentMethodType,
pub connector_details: Vec<BankAccountConnectorDetails>,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct BankAccountConnectorDetails {
pub connector: String,
pub account_id: String,
pub access_token: BankAccountAccessCreds,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
pub enum BankAccountAccessCreds {
AccessToken(String),
}
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
pub struct CardDetailFromLocker {
pub scheme: Option<String>,
Expand Down
19 changes: 17 additions & 2 deletions crates/diesel_models/src/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@ pub struct TokenizeCoreWorkflow {

#[derive(Debug, Serialize, Deserialize)]
pub enum PaymentMethodUpdate {
MetadataUpdate { metadata: Option<serde_json::Value> },
MetadataUpdate {
metadata: Option<serde_json::Value>,
},
PaymentMethodDataUpdate {
payment_method_data: Option<Encryption>,
},
}

#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
#[diesel(table_name = payment_methods)]
pub struct PaymentMethodUpdateInternal {
metadata: Option<serde_json::Value>,
payment_method_data: Option<Encryption>,
}

impl PaymentMethodUpdateInternal {
Expand All @@ -119,7 +125,16 @@ impl PaymentMethodUpdateInternal {
impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
fn from(payment_method_update: PaymentMethodUpdate) -> Self {
match payment_method_update {
PaymentMethodUpdate::MetadataUpdate { metadata } => Self { metadata },
PaymentMethodUpdate::MetadataUpdate { metadata } => Self {
metadata,
payment_method_data: None,
},
PaymentMethodUpdate::PaymentMethodDataUpdate {
payment_method_data,
} => Self {
metadata: None,
payment_method_data,
},
}
}
}
5 changes: 3 additions & 2 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,8 +1954,9 @@ async fn get_card_details(
.flatten()
.map(|x| x.into_inner().expose())
.and_then(|v| serde_json::from_value::<PaymentMethodsData>(v).ok())
.map(|pmd| match pmd {
PaymentMethodsData::Card(crd) => api::CardDetailFromLocker::from(crd),
.and_then(|pmd| match pmd {
PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)),
_ => None,
});

Ok(Some(
Expand Down
Loading