Skip to content
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
357839d
chore: updated payment's response with pm_id
prajjwalkumar17 Feb 29, 2024
4fbcbfe
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Feb 29, 2024
4caaa73
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Feb 29, 2024
eecca8f
chore: updated payment's response with pm_status
prajjwalkumar17 Feb 29, 2024
b9e4404
Merge branch 'feat/core_pm_id_in_response' of https://github.com/jusp…
prajjwalkumar17 Feb 29, 2024
bde1ef5
chore: run formatter
hyperswitch-bot[bot] Feb 29, 2024
a4b55c4
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Feb 29, 2024
4fe11d5
chore: updated payment's response with pm_status
prajjwalkumar17 Mar 1, 2024
56a7aeb
chore: updated payment's response with pm_status
prajjwalkumar17 Mar 1, 2024
2597535
chore: run formatter
hyperswitch-bot[bot] Mar 1, 2024
23c2b77
chore: updated openapi spec
prajjwalkumar17 Mar 1, 2024
29db657
chore: updated openapi spec
prajjwalkumar17 Mar 1, 2024
2bd0a61
chore: updated openapi spec
prajjwalkumar17 Mar 1, 2024
0a4ea1d
chore: updated openapi spec
prajjwalkumar17 Mar 1, 2024
8590483
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 1, 2024
cf16db5
Merge remote-tracking branch 'origin' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 4, 2024
32184cc
Merge branch 'feat/core_pm_id_in_response' of https://github.com/jusp…
prajjwalkumar17 Mar 4, 2024
d351c1f
chore: addressed the comments
prajjwalkumar17 Mar 4, 2024
09a601f
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 5, 2024
230c058
chore: removed the status failing check
prajjwalkumar17 Mar 5, 2024
a9f2c60
Merge branch 'feat/core_pm_id_in_response', remote-tracking branch 'o…
prajjwalkumar17 Mar 5, 2024
6962509
chore: ¯dd the payment_method_status for 3ds payments
prajjwalkumar17 Mar 5, 2024
e9f38fb
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 6, 2024
293be30
chore: restored connector file
prajjwalkumar17 Mar 6, 2024
8972f1a
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 6, 2024
836c990
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 6, 2024
287dc22
Merge branch 'feat/core_pm_id_in_response' of https://github.com/jusp…
prajjwalkumar17 Mar 6, 2024
4c65af3
chore: update pm_status in db
prajjwalkumar17 Mar 7, 2024
676a5cb
chore: run formatter
hyperswitch-bot[bot] Mar 7, 2024
5008df8
chore: resolve conflicts
prajjwalkumar17 Mar 7, 2024
20a0bce
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 7, 2024
06e28b1
chore: resolve conflicts
prajjwalkumar17 Mar 7, 2024
38e1474
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 7, 2024
cb4a025
chore: run formatter
hyperswitch-bot[bot] Mar 7, 2024
933db1a
chore: add pm_id and pm_status froom setup mandate flow
prajjwalkumar17 Mar 7, 2024
662d128
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 7, 2024
cdb8095
chore: resolved commits
prajjwalkumar17 Mar 7, 2024
d88003d
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 7, 2024
39c06dd
chore: run formatter
hyperswitch-bot[bot] Mar 7, 2024
a9e9577
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 7, 2024
d8e3202
chore: debug logs
prajjwalkumar17 Mar 7, 2024
37ea666
Merge branch 'feat/core_pm_id_in_response' of https://github.com/jusp…
prajjwalkumar17 Mar 7, 2024
9a8e0fb
chore: debug logs
prajjwalkumar17 Mar 7, 2024
56b8cc7
chore: removed trailing spaces
prajjwalkumar17 Mar 7, 2024
112e814
chore: updated development.toml
prajjwalkumar17 Mar 7, 2024
fe1ff87
chore: addressed the comments
prajjwalkumar17 Mar 7, 2024
eb24ecb
chore: run formatter
hyperswitch-bot[bot] Mar 7, 2024
3c2317f
chore: resolved the devlopment
prajjwalkumar17 Mar 7, 2024
6d54474
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 7, 2024
4abb8b9
chore: fixed tests
prajjwalkumar17 Mar 7, 2024
84f8af3
Merge branch 'refactor/status_handling_for_pm' of https://github.com/…
prajjwalkumar17 Mar 7, 2024
d810874
chore: fixed tests
prajjwalkumar17 Mar 7, 2024
cc6e496
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 7, 2024
e5ecd9b
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 7, 2024
c109748
chore: resolved tests
prajjwalkumar17 Mar 7, 2024
3bf4876
Merge branch 'feat/core_pm_id_in_response' of https://github.com/jusp…
prajjwalkumar17 Mar 7, 2024
f1be400
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 7, 2024
2d84eda
chore: resolved comments
prajjwalkumar17 Mar 8, 2024
ca65bc1
chore: run formatter
hyperswitch-bot[bot] Mar 8, 2024
a2b170e
Merge branch 'main' into feat/core_pm_id_in_response
prajjwalkumar17 Mar 8, 2024
32bdd95
chore: resolved comments
prajjwalkumar17 Mar 8, 2024
d66a539
chore: resolved comments
prajjwalkumar17 Mar 8, 2024
46fa9ea
Merge branch 'feat/core_pm_id_in_response' into refactor/status_handl…
prajjwalkumar17 Mar 8, 2024
e10d4bf
chore: updated flow
prajjwalkumar17 Mar 8, 2024
fa33a3f
Merge branch 'refactor/status_handling_for_pm' of https://github.com/…
prajjwalkumar17 Mar 8, 2024
d347e9e
chore: fixed tests
prajjwalkumar17 Mar 8, 2024
6e3833a
Merge branch 'main' into refactor/status_handling_for_pm
prajjwalkumar17 Mar 11, 2024
fefd45e
chore: fixed conflicts
prajjwalkumar17 Mar 11, 2024
0061e4e
chore: fixed conflicts
prajjwalkumar17 Mar 11, 2024
13a1c6b
chore: refactored changes of payment token
prajjwalkumar17 Mar 11, 2024
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
7 changes: 7 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,13 @@ pub struct PaymentsResponse {

/// Payment Fingerprint
pub fingerprint: Option<String>,

/// Payment Method Id
pub payment_method_id: Option<String>,

/// Payment Method Status
#[schema(value_type = Option<PaymentMethodStatus>)]
pub payment_method_status: Option<common_enums::PaymentMethodStatus>,
}

#[derive(Setter, Clone, Default, Debug, PartialEq, serde::Serialize, ToSchema)]
Expand Down
30 changes: 30 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,36 @@ pub enum PaymentMethodStatus {
Processing,
}

impl From<AttemptStatus> for PaymentMethodStatus {
fn from(attempt_status: AttemptStatus) -> Self {
match attempt_status {
AttemptStatus::Charged | AttemptStatus::Authorized => Self::Active,
AttemptStatus::Failure => Self::Inactive,
AttemptStatus::Voided
| AttemptStatus::Started
| AttemptStatus::Pending
| AttemptStatus::Unresolved
| AttemptStatus::CodInitiated
| AttemptStatus::Authorizing
| AttemptStatus::VoidInitiated
| AttemptStatus::AuthorizationFailed
| AttemptStatus::RouterDeclined
| AttemptStatus::AuthenticationSuccessful
| AttemptStatus::PaymentMethodAwaited
| AttemptStatus::AuthenticationFailed
| AttemptStatus::AuthenticationPending
| AttemptStatus::CaptureInitiated
| AttemptStatus::CaptureFailed
| AttemptStatus::VoidFailed
| AttemptStatus::AutoRefunded
| AttemptStatus::PartialCharged
| AttemptStatus::PartialChargedAndChargeable
| AttemptStatus::ConfirmationAwaited
| AttemptStatus::DeviceDataCollectionPending => Self::Processing,
}
}
}

/// To indicate the type of payment experience that the customer would go through
#[derive(
Eq,
Expand Down
1 change: 1 addition & 0 deletions crates/data_models/src/payments/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ pub enum PaymentAttemptUpdate {
authentication_id: Option<String>,
payment_method_billing_address_id: Option<String>,
fingerprint_id: Option<String>,
payment_method_id: Option<String>,
},
RejectUpdate {
status: storage_enums::AttemptStatus,
Expand Down
3 changes: 3 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub enum PaymentAttemptUpdate {
fingerprint_id: Option<String>,
updated_by: String,
merchant_connector_id: Option<String>,
payment_method_id: Option<String>,
external_three_ds_authentication_attempted: Option<bool>,
authentication_connector: Option<String>,
authentication_id: Option<String>,
Expand Down Expand Up @@ -574,6 +575,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
authentication_id,
payment_method_billing_address_id,
fingerprint_id,
payment_method_id,
} => Self {
amount: Some(amount),
currency: Some(currency),
Expand Down Expand Up @@ -601,6 +603,7 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
authentication_id,
payment_method_billing_address_id,
fingerprint_id,
payment_method_id: payment_method_id.map(Some),
..Default::default()
},
PaymentAttemptUpdate::VoidUpdate {
Expand Down
13 changes: 13 additions & 0 deletions crates/diesel_models/src/payment_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ pub enum PaymentMethodUpdate {
LastUsedUpdate {
last_used_at: PrimitiveDateTime,
},
StatusUpdate {
status: Option<storage_enums::PaymentMethodStatus>,
},
}

#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]
Expand All @@ -131,6 +134,7 @@ pub struct PaymentMethodUpdateInternal {
metadata: Option<serde_json::Value>,
payment_method_data: Option<Encryption>,
last_used_at: Option<PrimitiveDateTime>,
status: Option<storage_enums::PaymentMethodStatus>,
}

impl PaymentMethodUpdateInternal {
Expand All @@ -148,18 +152,27 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {
metadata,
payment_method_data: None,
last_used_at: None,
status: None,
},
PaymentMethodUpdate::PaymentMethodDataUpdate {
payment_method_data,
} => Self {
metadata: None,
payment_method_data,
last_used_at: None,
status: None,
},
PaymentMethodUpdate::LastUsedUpdate { last_used_at } => Self {
metadata: None,
payment_method_data: None,
last_used_at: Some(last_used_at),
status: None,
},
PaymentMethodUpdate::StatusUpdate { status } => Self {
metadata: None,
payment_method_data: None,
last_used_at: None,
status,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::ReconStatus,
api_models::enums::ConnectorStatus,
api_models::enums::AuthorizationStatus,
api_models::enums::PaymentMethodStatus,
api_models::admin::MerchantConnectorCreate,
api_models::admin::MerchantConnectorUpdate,
api_models::admin::PrimaryBusinessDetails,
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/checkout_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl ConstructFlowSpecificData<frm_api::Checkout, FraudCheckCheckoutData, FraudC
description: None,
return_url: None,
payment_method_id: None,
payment_method_status: None,
address: self.address.clone(),
auth_type: storage_enums::AuthenticationType::NoThreeDs,
connector_meta_data: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub async fn construct_fulfillment_router_data<'a>(
auth_type: payment_attempt.authentication_type.unwrap_or_default(),
connector_meta_data: merchant_connector_account.get_metadata(),
amount_captured: payment_intent.amount_captured,
payment_method_status: None,
request: FraudCheckFulfillmentData {
amount: payment_attempt.amount,
order_details: payment_intent.order_details.clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/record_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl ConstructFlowSpecificData<RecordReturn, FraudCheckRecordReturnData, FraudCh
payment_method_token: None,
connector_customer: None,
preprocessing_id: None,
payment_method_status: None,
connector_request_reference_id: uuid::Uuid::new_v4().to_string(),
test_mode: None,
recurring_mandate_payment_data: None,
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/fraud_check/flows/sale_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl ConstructFlowSpecificData<frm_api::Sale, FraudCheckSaleData, FraudCheckResp
payment_method_token: None,
connector_customer: None,
preprocessing_id: None,
payment_method_status: None,
connector_request_reference_id: uuid::Uuid::new_v4().to_string(),
test_mode: None,
recurring_mandate_payment_data: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl
connector_http_status_code: None,
external_latency: None,
connector_api_version: None,
payment_method_status: None,
apple_pay_flow: None,
frm_metadata: None,
refund_id: None,
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/mandate/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub async fn construct_mandate_revoke_router_data(
preprocessing_id: None,
payment_method_balance: None,
connector_api_version: None,
payment_method_status: None,
request: types::MandateRevokeRequestData {
mandate_id: mandate.mandate_id,
connector_mandate_id: mandate.connector_mandate_id,
Expand Down
83 changes: 68 additions & 15 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ use data_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
use diesel_models::enums;

use crate::{
core::{
errors::RouterResult,
payments::helpers,
pm_auth::{self as core_pm_auth},
},
core::{errors::RouterResult, payments::helpers, pm_auth as core_pm_auth},
routes::AppState,
types::{
api::{self, payments},
Expand All @@ -44,7 +40,7 @@ pub trait PaymentMethodRetrieve {
payment_intent: &PaymentIntent,
card_token_data: Option<&CardToken>,
customer: &Option<domain::Customer>,
) -> RouterResult<Option<(payments::PaymentMethodData, enums::PaymentMethod)>>;
) -> RouterResult<storage::PaymentMethodDataWithId>;
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -128,8 +124,8 @@ impl PaymentMethodRetrieve for Oss {
payment_intent: &PaymentIntent,
card_token_data: Option<&CardToken>,
customer: &Option<domain::Customer>,
) -> RouterResult<Option<(payments::PaymentMethodData, enums::PaymentMethod)>> {
match token_data {
) -> RouterResult<storage::PaymentMethodDataWithId> {
let token = match token_data {
storage::PaymentTokenData::TemporaryGeneric(generic_token) => {
helpers::retrieve_payment_method_with_temporary_token(
state,
Expand All @@ -138,7 +134,15 @@ impl PaymentMethodRetrieve for Oss {
merchant_key_store,
card_token_data,
)
.await
.await?
.map(
|(payment_method_data, payment_method)| storage::PaymentMethodDataWithId {
payment_method_data: Some(payment_method_data),
payment_method: Some(payment_method),
payment_method_id: None,
},
)
.unwrap_or_default()
}

storage::PaymentTokenData::Temporary(generic_token) => {
Expand All @@ -149,7 +153,15 @@ impl PaymentMethodRetrieve for Oss {
merchant_key_store,
card_token_data,
)
.await
.await?
.map(
|(payment_method_data, payment_method)| storage::PaymentMethodDataWithId {
payment_method_data: Some(payment_method_data),
payment_method: Some(payment_method),
payment_method_id: None,
},
)
.unwrap_or_default()
}

storage::PaymentTokenData::Permanent(card_token) => {
Expand All @@ -164,7 +176,21 @@ impl PaymentMethodRetrieve for Oss {
card_token_data,
)
.await
.map(|card| Some((card, enums::PaymentMethod::Card)))
.map(|card| Some((card, enums::PaymentMethod::Card)))?
.map(
|(payment_method_data, payment_method)| storage::PaymentMethodDataWithId {
payment_method_data: Some(payment_method_data),
payment_method: Some(payment_method),
payment_method_id: Some(
card_token
.payment_method_id
.as_ref()
.unwrap_or(&card_token.token)
.to_string(),
),
},
)
.unwrap_or_default()
}

storage::PaymentTokenData::PermanentCard(card_token) => {
Expand All @@ -179,7 +205,21 @@ impl PaymentMethodRetrieve for Oss {
card_token_data,
)
.await
.map(|card| Some((card, enums::PaymentMethod::Card)))
.map(|card| Some((card, enums::PaymentMethod::Card)))?
.map(
|(payment_method_data, payment_method)| storage::PaymentMethodDataWithId {
payment_method_data: Some(payment_method_data),
payment_method: Some(payment_method),
payment_method_id: Some(
card_token
.payment_method_id
.as_ref()
.unwrap_or(&card_token.token)
.to_string(),
),
},
)
.unwrap_or_default()
}

storage::PaymentTokenData::AuthBankDebit(auth_token) => {
Expand All @@ -190,10 +230,23 @@ impl PaymentMethodRetrieve for Oss {
payment_intent,
customer,
)
.await
.await?
.map(
|(payment_method_data, payment_method)| storage::PaymentMethodDataWithId {
payment_method_data: Some(payment_method_data),
payment_method: Some(payment_method),
payment_method_id: None,
},
)
.unwrap_or_default()
}

storage::PaymentTokenData::WalletToken(_) => Ok(None),
}
storage::PaymentTokenData::WalletToken(_) => storage::PaymentMethodDataWithId {
payment_method: None,
payment_method_data: None,
payment_method_id: None,
},
};
Ok(token)
}
}
12 changes: 9 additions & 3 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ where
None,
)
.await?;

let operation = Box::new(PaymentResponse);

connector_http_status_code = router_data.connector_http_status_code;
Expand Down Expand Up @@ -1924,7 +1925,7 @@ where

let connector_tokenization_action = match payment_method_action {
TokenizationAction::TokenizeInRouter => {
let (_operation, payment_method_data) = operation
let (_operation, payment_method_data, pm_id) = operation
.to_domain()?
.make_pm_data(
state,
Expand All @@ -1935,12 +1936,14 @@ where
)
.await?;
payment_data.payment_method_data = payment_method_data;
payment_data.payment_attempt.payment_method_id = pm_id;

TokenizationAction::SkipConnectorTokenization
}

TokenizationAction::TokenizeInConnector => TokenizationAction::TokenizeInConnector,
TokenizationAction::TokenizeInConnectorAndRouter => {
let (_operation, payment_method_data) = operation
let (_operation, payment_method_data, pm_id) = operation
.to_domain()?
.make_pm_data(
state,
Expand All @@ -1952,6 +1955,7 @@ where
.await?;

payment_data.payment_method_data = payment_method_data;
payment_data.payment_attempt.payment_method_id = pm_id;
TokenizationAction::TokenizeInConnector
}
TokenizationAction::ConnectorToken(token) => {
Expand Down Expand Up @@ -1993,7 +1997,7 @@ where
{
// On confirm is false and only router related
let payment_data = if !is_operation_confirm(operation) {
let (_operation, payment_method_data) = operation
let (_operation, payment_method_data, pm_id) = operation
.to_domain()?
.make_pm_data(
state,
Expand All @@ -2004,6 +2008,7 @@ where
)
.await?;
payment_data.payment_method_data = payment_method_data;
payment_data.payment_attempt.payment_method_id = pm_id;
payment_data
} else {
payment_data
Expand Down Expand Up @@ -2074,6 +2079,7 @@ where
pub incremental_authorization_details: Option<IncrementalAuthorizationDetails>,
pub authorizations: Vec<diesel_models::authorization::Authorization>,
pub frm_metadata: Option<serde_json::Value>,
pub payment_method_status: Option<common_enums::PaymentMethodStatus>,
}

#[derive(Debug, Default, Clone)]
Expand Down
Loading