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): [fiserv] fix metadata deserialization in merchant_connector_account #2746

Merged
merged 3 commits into from
Nov 20, 2023

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Oct 31, 2023

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

While creating merchant connector account for fiserv , we store a field called terminal_id . If it is not present while making payment we throw 500 in this case .This PR add validation to connector metadata while creating merchant connector account for fiserv .

The existing merchant connector will not process payment as terminal_id validation is added . The following data migrations queries need to be run

If terminalId is present then convert it to terminal_id

UPDATE merchant_connector_account
SET metadata = (REPLACE(metadata::TEXT, '"terminalId"', '"terminal_id"'))::JSONB
where connector_name = 'fiserv';

and then if terminal_id is not present set terminal_id to empty string

UPDATE merchant_connector_account
SET metadata = jsonb_set(
    metadata,
    '{terminal_id}',
    '""',
    true
)
WHERE connector_name = 'fiserv'
    AND NOT metadata ? 'terminal_id';

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

While creating merchant connector account for fiserv , we store a field called terminal_id . If it is not present while making payment we throw 500 in this case .This PR add validation to connector metadata while creating merchant connector account for fiserv .

How did you test it?

Screenshot 2023-10-31 at 12 22 29 PM
  1. if we don't pass terminal_id in metadata while creating merchant connector account .it should throw 422 error .

created a issue for postman collection : https://github.com/juspay/hyperswitch-cloud/issues/3276

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

@srujanchikke srujanchikke added A-connector-integration Area: Connector integration C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-database-changes Metadata: This PR involves database schema changes labels Oct 31, 2023
@srujanchikke srujanchikke self-assigned this Oct 31, 2023
@srujanchikke srujanchikke requested review from a team as code owners October 31, 2023 14:08
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let session: FiservSessionObject =
metadata.parse_value("FiservSessionObject").change_context(
errors::ConnectorError::InvalidConnectorConfig { config: "metadata" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have metadata in Payments request also, So here let's give the clarity of Merchant Connector account metadata. The same comment is applicable for all the places where ever you are using "metadata" for the deserialization error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@ArjunKarthik ArjunKarthik added the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Nov 2, 2023
@srujanchikke srujanchikke removed the S-waiting-on-author Status: This PR is incomplete or needs to address review comments label Nov 2, 2023
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 20, 2023
Merged via the queue into main with commit 644709d Nov 20, 2023
12 of 14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the fiserv_fix branch November 20, 2023 08:13
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration C-bug Category: Bug M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants