-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[BUG] Add Create Merchant and Create Merchant Key Store in a DB transaction #1793
Comments
Hi @dracarys18 gonna take a look into this issue, also how can you tell me how should the I was experimenting with the logic and made changes in the following sections impl MerchantKeyStoreInterface for Store {
async fn insert_merchant_and_key_store(
&self,
merchant_account: domain::MerchantAccount,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantAccount, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
let val = conn.transaction_async(|e| async move {
merchant_key_store
.construct_new()
.await
.change_context(errors::StorageError::EncryptionError)?
.insert(&e)
.await
.map_err(Into::into)
.into_report()?
.convert(key)
.await
.change_context(errors::StorageError::DecryptionError);
merchant_account
.construct_new()
.await
.change_context(errors::StorageError::EncryptionError)?
.insert(&e)
.await
.map_err(Into::into)
.into_report()?
.convert(merchant_key_store.key.get_inner())
.await
.change_context(errors::StorageError::DecryptionError)
}).await;
val
} do let me know your thoughts about the approach |
Hey @artech-git I would prefer keeping the Store interface seperate for MerchantKeyStore and MerchantAccount. i.e Store impl of MerchantKeystore will only insert into merchant_key_store table. So it would be better to do it in |
Hey @artech-git , Please let me know if you need any help in this |
Opening this issue for contributions because of inactivity. |
May I take this up? |
Sure @Azanul, I'll assign this to you. |
To do this in admin.rs, I think we would need access to the connection to underlying Store. |
Hey @Azanul in that case add it in |
Closing this, as per inputs of @dracarys18 |
Currently MerchantAccount and MerchantKeyStore are getting inserted seperately. Since both of them are interdependent we need to make sure both are consistent with each other. If one of them fails other shouldn't get inserted.
We need to add this in a db_transaction
hyperswitch/crates/router/src/core/admin.rs
Lines 133 to 186 in 4805a94
For reference of how to do it in a db transaction
The text was updated successfully, but these errors were encountered: