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

feat: list payment_methods with the required fields in each method #1310

Merged
merged 53 commits into from
Jul 4, 2023

Conversation

Chethan-rao
Copy link
Contributor

@Chethan-rao Chethan-rao commented May 29, 2023

Type of Change

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

Description

Currently when /payments API call is made with confirm = false from merchant server, payment is created. Assuming the customer hasn't sent the required field in this call, when a confirm API call is made, since customer has missed to send the required filed during create call, confirm call triggers an error.
So, after Payment create call is made, when payment_methods_list call will be made, along with the payment_methods we need to send the required fields for each method, so that it could be sent during confirm call.

Api changes - Added a new field required_fields in payment_method_data which lists all the required fields with its appropriate display_name, field_type and field_options.

payment_method_data: {"payment_method": {"payment_method_type": "", "required_fields": {} } }

Config changes - Added required_fields in config which is a tuple struct containing a HashMap<PaymentMethod, PaymentMethodType>. PaymentMethodType is also tuple struct containing HashMap<PaymentMethodType, ConnectorFields>. ConnectorFields is a named field struct containing HashMap<Connector, HashSet<RequiredFieldInfo>>>> and RequiredFieldInfo is a struct defined in api_models crate, containing info about each required field. The default implementation for the same is provided in defaults.rs which contains data of required fields for each payment_method and payment_method_type.

required_fields are added in defaults.rs in connector level. But while listing, it would be in payment_method_type level as we are not sure about which connector the payment is going through during confirm call. So we get a union of all required_fields of connectors for a particular payment_method_type

Additional Changes

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

Motivation and Context

To avoid failure of payments due to missing required fields

How did you test it?

Postman

image

Checklist

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

@Chethan-rao Chethan-rao added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-api-contract-changes Metadata: This PR involves API contract changes labels May 29, 2023
@Chethan-rao Chethan-rao added this to the May 2023 Release milestone May 29, 2023
@Chethan-rao Chethan-rao self-assigned this May 29, 2023
@Chethan-rao Chethan-rao requested review from a team as code owners May 29, 2023 17:22
@Chethan-rao Chethan-rao linked an issue May 29, 2023 that may be closed by this pull request
2 tasks
@Chethan-rao Chethan-rao changed the title feat: list payment_methods with the missing required fields in each method feat: list payment_methods with the required fields in each method May 29, 2023
@Chethan-rao Chethan-rao added the M-configuration-changes Metadata: This PR involves configuration changes label May 29, 2023
@Chethan-rao Chethan-rao added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Jun 6, 2023
@SanchithHegde SanchithHegde added the S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author label Jul 4, 2023
@Chethan-rao Chethan-rao added S-waiting-on-review Status: This PR has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments S-needs-conflict-resolution Status: This PR needs conflicts to be resolved by the author labels Jul 4, 2023
SanchithHegde
SanchithHegde previously approved these changes Jul 4, 2023
Narayanbhat166
Narayanbhat166 previously approved these changes Jul 4, 2023
jarnura
jarnura previously approved these changes Jul 4, 2023
@SanchithHegde SanchithHegde added this pull request to the merge queue Jul 4, 2023
@SanchithHegde SanchithHegde added S-ready-for-merge and removed S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Jul 4, 2023
Merged via the queue into main with commit 6447b04 Jul 4, 2023
@SanchithHegde SanchithHegde deleted the required_fields_in_pmd branch July 4, 2023 14:11
@SanchithHegde SanchithHegde removed S-ready-for-merge low-risk label to track PRs which might have less impact on hyperswitch after merge labels Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes M-configuration-changes Metadata: This PR involves configuration changes
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[FEATURE] List payment_methods with the required fields in each method
9 participants