mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
refactor: use hashmap deserializer for generic_link options (#5157)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -12,6 +12,7 @@ use diesel_models::{
|
||||
};
|
||||
use error_stack::{report, ResultExt};
|
||||
use hyperswitch_domain_models::payments::{payment_attempt::PaymentAttempt, PaymentIntent};
|
||||
use masking::PeekInterface;
|
||||
use router_env::{instrument, tracing};
|
||||
use time::Duration;
|
||||
|
||||
@ -145,11 +146,17 @@ pub async fn initiate_pm_collect_link(
|
||||
)?;
|
||||
|
||||
// Return response
|
||||
let url = pm_collect_link.url.peek();
|
||||
let response = payment_methods::PaymentMethodCollectLinkResponse {
|
||||
pm_collect_link_id: pm_collect_link.link_id,
|
||||
customer_id,
|
||||
expiry: pm_collect_link.expiry,
|
||||
link: pm_collect_link.url,
|
||||
link: url::Url::parse(url)
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable_lazy(|| {
|
||||
format!("Failed to parse the payment method collect link - {}", url)
|
||||
})?
|
||||
.into(),
|
||||
return_url: pm_collect_link.return_url,
|
||||
ui_config: pm_collect_link.link_data.ui_config,
|
||||
enabled_payment_methods: pm_collect_link.link_data.enabled_payment_methods,
|
||||
@ -214,7 +221,7 @@ pub async fn render_pm_collect_link(
|
||||
let link_data = pm_collect_link.link_data;
|
||||
let default_config = &state.conf.generic_link.payment_method_collect;
|
||||
let default_ui_config = default_config.ui_config.clone();
|
||||
let ui_config_data = common_utils::link_utils::GenericLinkUIConfigFormData {
|
||||
let ui_config_data = common_utils::link_utils::GenericLinkUiConfigFormData {
|
||||
merchant_name: link_data
|
||||
.ui_config
|
||||
.merchant_name
|
||||
@ -295,7 +302,7 @@ pub async fn render_pm_collect_link(
|
||||
let generic_form_data = services::GenericLinkFormData {
|
||||
js_data: serialized_js_content,
|
||||
css_data: serialized_css_content,
|
||||
sdk_url: default_config.sdk_url.clone(),
|
||||
sdk_url: default_config.sdk_url.to_string(),
|
||||
html_meta_tags: String::new(),
|
||||
};
|
||||
Ok(services::ApplicationResponse::GenericLinkForm(Box::new(
|
||||
@ -310,7 +317,15 @@ pub async fn render_pm_collect_link(
|
||||
pm_collect_link_id: pm_collect_link.link_id,
|
||||
customer_id: link_data.customer_id,
|
||||
session_expiry: pm_collect_link.expiry,
|
||||
return_url: pm_collect_link.return_url,
|
||||
return_url: pm_collect_link
|
||||
.return_url
|
||||
.as_ref()
|
||||
.map(|url| url::Url::parse(url))
|
||||
.transpose()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable(
|
||||
"Failed to parse return URL for payment method collect's status link",
|
||||
)?,
|
||||
ui_config: ui_config_data,
|
||||
status,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user