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

fix(connector): add metadata transformation with encode_to_value for MerchantAccountUpdate and merchant_account_update #3434

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub struct MerchantAccountUpdate {

/// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<pii::SecretSerdeValue>,
pub metadata: Option<MerchantAccountMetadata>,

/// API key that will be used for server side API access
#[schema(example = "AH3423bkjbkjdsfbkj")]
Expand Down
14 changes: 13 additions & 1 deletion crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ pub async fn merchant_account_update(
None
};

let metadata = req
.metadata
.as_ref()
.map(|meta| {
utils::Encode::<admin_types::MerchantAccountMetadata>::encode_to_value(meta)
.change_context(errors::ApiErrorResponse::InvalidDataValue {
field_name: "metadata",
})
})
.transpose()?
.map(Secret::new);

// Update the business profile, This is for backwards compatibility
update_business_profile_cascade(state.clone(), req.clone(), merchant_id.to_string()).await?;

Expand Down Expand Up @@ -581,7 +593,7 @@ pub async fn merchant_account_update(
payment_response_hash_key: req.payment_response_hash_key,
redirect_to_merchant_with_http_post: req.redirect_to_merchant_with_http_post,
locker_id: req.locker_id,
metadata: req.metadata,
metadata,
publishable_key: None,
primary_business_details,
frm_routing_algorithm: req.frm_routing_algorithm,
Expand Down
Loading