Skip to content

Commit

Permalink
fix(core): Add payment_link_data in PaymentData for Psync (#7205)
Browse files Browse the repository at this point in the history
Co-authored-by: pranav-arjunan <[email protected]>
  • Loading branch information
cookieg13 and pranav-arjunan authored Feb 7, 2025
1 parent 5247a3c commit 60f5a3e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4515,6 +4515,24 @@ impl CustomerDetailsExt for CustomerDetails {
}
}

pub async fn get_payment_link_response_from_id(
state: &SessionState,
payment_link_id: &str,
) -> CustomResult<api_models::payments::PaymentLinkResponse, errors::ApiErrorResponse> {
let db = &*state.store;

let payment_link_object = db
.find_payment_link_by_payment_link_id(payment_link_id)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentLinkNotFound)?;

Ok(api_models::payments::PaymentLinkResponse {
link: payment_link_object.link_to_pay.clone(),
secure_link: payment_link_object.secure_link,
payment_link_id: payment_link_object.payment_link_id,
})
}

#[cfg(feature = "v1")]
pub fn if_not_create_change_operation<'a, Op, F>(
status: storage_enums::IntentStatus,
Expand Down
9 changes: 8 additions & 1 deletion crates/router/src/core/payments/operations/payment_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ async fn get_tracker_for_sync<
}).await
.transpose()?;

let payment_link_data = payment_intent
.payment_link_id
.as_ref()
.async_map(|id| crate::core::payments::get_payment_link_response_from_id(state, id))
.await
.transpose()?;

let payment_data = PaymentData {
flow: PhantomData,
payment_intent,
Expand Down Expand Up @@ -512,7 +519,7 @@ async fn get_tracker_for_sync<
ephemeral_key: None,
multiple_capture_data,
redirect_response: None,
payment_link_data: None,
payment_link_data,
surcharge_details: None,
frm_message: frm_response,
incremental_authorization_details: None,
Expand Down

0 comments on commit 60f5a3e

Please sign in to comment.