fix(connector): add metadata transformation with encode_to_value
for MerchantAccountUpdate
and merchant_account_update
#3434
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
This pull request aligns the validation of metadata for the create and update merchant account functionality. In the struct
MerchantAccountUpdate
, the request type now containsmetadata: Option<pii::SecretSerdeValue>
, which has been updated tometadata: Option<MerchantAccountMetadata>
. As a result, validation and transformation formetadata
have been added to thefn merchant_account_update
.Additional Changes
Motivation and Context
When creating a merchant account using
fn create_merchant_account
, theMerchantAccountCreate
request type containsmetadata: Option<MerchantAccountMetadata>
. Thesemetadata
are then transformed into JSON here and subsequently stored in the database as JSON.Another struct,
MerchantAccountResponse
, containsmetadata: Option<pii::SecretSerdeValue>
. ThisMerchantAccountResponse
is utilized for read operations as a result. So far, so good.When updating a merchant account with
fn merchant_account_update
, there is aMerchantAccountUpdate
request type that containsmetadata: Option<pii::SecretSerdeValue>
without any validation/transformation. I think this is a bug. When updating a merchant account using thefn merchant_account_update
, someone can store whatever JSON in the metadata, and this JSON is not even checked for compatibility withMerchantAccountMetadata
as is done in thefn create_merchant_account
.I discovered this potential issue while testing another PR.
How did you test it?
TODO: not yet, but if this PR/issue is relevant to fix, I can do postman test.
Checklist
cargo +nightly fmt --all
cargo clippy