mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix(router): configs table upsert for local tokenization flow (#392)
This commit is contained in:
@ -277,17 +277,31 @@ impl Vault {
|
|||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
.attach_printable("Failed to encode payment method as mock tokenize db value")?;
|
.attach_printable("Failed to encode payment method as mock tokenize db value")?;
|
||||||
|
|
||||||
let config = storage::ConfigNew {
|
let already_present = state.store.find_config_by_key(&lookup_key).await;
|
||||||
key: lookup_key.clone(),
|
|
||||||
config: value_string,
|
|
||||||
};
|
|
||||||
|
|
||||||
state
|
if already_present.is_err() {
|
||||||
.store
|
let config = storage::ConfigNew {
|
||||||
.insert_config(config)
|
key: lookup_key.clone(),
|
||||||
.await
|
config: value_string,
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
};
|
||||||
.attach_printable("Mock tokenization save to db failed")?;
|
|
||||||
|
state
|
||||||
|
.store
|
||||||
|
.insert_config(config)
|
||||||
|
.await
|
||||||
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
|
.attach_printable("Mock tokenization save to db failed insert")?;
|
||||||
|
} else {
|
||||||
|
let config_update = storage::ConfigUpdate::Update {
|
||||||
|
config: Some(value_string),
|
||||||
|
};
|
||||||
|
state
|
||||||
|
.store
|
||||||
|
.update_config_by_key(&lookup_key, config_update)
|
||||||
|
.await
|
||||||
|
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||||
|
.attach_printable("Mock tokenization save to db failed update")?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(lookup_key)
|
Ok(lookup_key)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user