Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
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
6 changes: 3 additions & 3 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ pub async fn make_pm_data<'a, F: Clone, R, Ctx: PaymentMethodRetrieve>(
}

(Some(_), _) => {
let payment_method_data = Ctx::retrieve_payment_method(
let (payment_method_data, payment_token) = Ctx::retrieve_payment_method(
request,
state,
&payment_data.payment_intent,
Expand All @@ -1753,9 +1753,9 @@ pub async fn make_pm_data<'a, F: Clone, R, Ctx: PaymentMethodRetrieve>(
)
.await?;

payment_data.token = payment_method_data.1;
payment_data.token = payment_token;

Ok((payment_method_data.0, None))
Ok((payment_method_data, None))
}
_ => Ok((None, None)),
}?;
Expand Down
32 changes: 32 additions & 0 deletions crates/router/src/core/payments/operations/payment_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
router_data: types::RouterData<F, T, types::PaymentsResponseData>,
storage_scheme: enums::MerchantStorageScheme,
) -> RouterResult<PaymentData<F>> {
payment_data.payment_method_status = router_data.payment_method_status;
let (capture_update, mut payment_attempt_update) = match router_data.response.clone() {
Err(err) => {
let (capture_update, attempt_update) = match payment_data.multiple_capture_data {
Expand Down Expand Up @@ -816,6 +817,7 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
},
};

update_payment_method_status(state, &mut payment_data, router_data.status).await?;
let m_db = state.clone().store;
let m_payment_data_payment_intent = payment_data.payment_intent.clone();
let m_payment_intent_update = payment_intent_update.clone();
Expand Down Expand Up @@ -871,6 +873,36 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
Ok(payment_data)
}

async fn update_payment_method_status<F: Clone>(
state: &AppState,
payment_data: &mut PaymentData<F>,
attempt_status: common_enums::AttemptStatus,
) -> RouterResult<()> {
if let Some(id) = &payment_data.payment_attempt.payment_method_id {
let pm = state
.store
.find_payment_method(id)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;

if pm.status != attempt_status.into() {
let updated_pm_status = common_enums::PaymentMethodStatus::from(attempt_status);

payment_data.payment_method_status = Some(updated_pm_status);
let pm_update = storage::PaymentMethodUpdate::StatusUpdate {
status: Some(updated_pm_status),
};
state
.store
.update_payment_method(pm, pm_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed to update payment method in db")?;
}
};
Ok(())
}

fn response_to_capture_update(
multiple_capture_data: &MultipleCaptureData,
response_list: HashMap<String, CaptureSyncResponse>,
Expand Down