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(mca): Added recipient connector call for open banking connectors #3758

Merged
merged 39 commits into from
Jul 16, 2024

Conversation

Sarthak1799
Copy link
Contributor

@Sarthak1799 Sarthak1799 commented Feb 21, 2024

Type of Change

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

Description

  • Added connector call in payment connector create to facilitate merchant recipient creation at connector end.
  • Added alternative locker call for creation of recipient at Hyperswitch's end in case the connector does not support it.
  • Added validation for merchant bank account data

Additional Changes

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

Motivation and Context

How did you test it?

  1. Create an MCA account with connector_type as payment_processor and an open banking connector
curl --location --request POST 'http://localhost:8080/account/merchant_1720607250/connectors' \
--header 'api-key: test_admin' \
--header 'Content-Type: application/json' \
--data-raw '{
    "connector_type": "payment_processor",
    "connector_name": "plaid",
    "connector_label": "plaid3",
    "connector_account_details": {
        "auth_type": "BodyKey",
        "api_key": "Some_key",
        "key1": "Some_key"
    },
    "test_mode": false,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    }
                },
                {
                    "payment_method_type": "giropay",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    }
                },
                {
                    "payment_method_type": "ideal",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    }
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "minimum_amount": 0,
                    "maximum_amount": 10000
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "USD",
                            "GBP",
                            "CAD",
                            "AUD",
                            "EUR"
                        ]
                    }
                }
            ]
        }
    ],
    "additional_merchant_data": {
         "open_banking_recipient_data": {
            "account_data": {
                "bacs": {
                    "sort_code": "200000",
                    "account_number": "55779911",
                    "name": "merchant_name"
                }
            }
        }
    },
    "metadata": {
        "city": "NY",
        "unit": "246"
    }
}'

Successful Response should look like this -

{
    "connector_type": "payment_processor",
    "connector_name": "plaid",
    "connector_label": "plaid3",
    "merchant_connector_id": "mca_c0iTEayEJMViYwEhTCOG",
    "profile_id": "pro_UgP3FfqWGhfPLuUqYtJF",
    "connector_account_details": {
        "auth_type": "BodyKey",
      "api_key": "Some_key",
        "key1": "Some_key"
    },
    "payment_methods_enabled": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "ideal",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 10000,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "USD",
                            "GBP",
                            "CAD",
                            "AUD",
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "city": "NY",
        "unit": "246"
    },
    "test_mode": false,
    "disabled": false,
    "frm_configs": null,
    "business_country": null,
    "business_label": null,
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": {
        "open_banking_recipient_data": {
            "account_data": {
                "bacs": {
                    "account_number": "55779911",
                    "sort_code": "200000",
                    "name": "merchant_name",
                    "connector_recipient_id": "recipient-id-sandbox-45beb880-9e3d-4ae3-927b-052f5610fd74"
                }
            }
        }
    }
}

Response when the connector does not support recipient creation (locker call to be made in this)

{
    "connector_type": "payment_processor",
    "connector_name": "plaid",
    "connector_label": "plaid3",
    "merchant_connector_id": "mca_6bIUIrWNSbqssRO89Zxx",
    "profile_id": "pro_UgP3FfqWGhfPLuUqYtJF",
    "connector_account_details": {
        "auth_type": "BodyKey",
       "api_key": "Some_key",
        "key1": "Some_key"
    },
    "payment_methods_enabled": [
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "giropay",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "ideal",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": null,
                    "maximum_amount": null,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_debit",
            "payment_method_types": [
                {
                    "payment_method_type": "ach",
                    "payment_experience": null,
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 0,
                    "maximum_amount": 10000,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "card_networks": null,
                    "accepted_currencies": {
                        "type": "enable_only",
                        "list": [
                            "USD",
                            "GBP",
                            "CAD",
                            "AUD",
                            "EUR"
                        ]
                    },
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "connector_webhook_details": null,
    "metadata": {
        "city": "NY",
        "unit": "246"
    },
    "test_mode": false,
    "disabled": false,
    "frm_configs": null,
    "business_country": null,
    "business_label": null,
    "business_sub_label": null,
    "applepay_verified_domains": null,
    "pm_auth_config": null,
    "status": "active",
    "additional_merchant_data": {
        "open_banking_recipient_data": {
            "account_data": {
                "bacs": {
                    "account_number": "55779911",
                    "sort_code": "200000",
                    "name": "merchant_name"
                }
            }
        }
    }
}

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

@Sarthak1799 Sarthak1799 added A-core Area: Core flows C-feature Category: Feature request or enhancement labels Feb 21, 2024
@Sarthak1799 Sarthak1799 requested a review from vspecky February 21, 2024 14:45
@Sarthak1799 Sarthak1799 self-assigned this Feb 21, 2024
@Sarthak1799 Sarthak1799 requested review from a team as code owners February 21, 2024 14:45
@Sarthak1799 Sarthak1799 linked an issue Feb 27, 2024 that may be closed by this pull request
2 tasks
@Narayanbhat166
Copy link
Member

Few points to be resolved:

  • If we receive an error from the processor, the error should be propogated in the response, status code should be the same as sent by the processor. ( or we can throw 4xx for any failed error, and 5xx for any internal error as usual )
  • Is receipient_id used as a key for authentication with the api? If not it does not make sense to store it in auth type. We can have a separate column for these processors ( or store it in metadata, I would not prefer this option ). Only keys that are used for authentication should go in auth type ( both in api and database ).
  • The previous point also applies for bank_account_number, if not required for authentication, we can move it out and collect it in metadata. The metadata can be type validated.

@Sarthak1799
Copy link
Contributor Author

For the first point, made the changes to throw a 4xx from the connector instead of 5xx @Narayanbhat166

Chethan-rao
Chethan-rao previously approved these changes Jul 11, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes Jul 11, 2024
@Sarthak1799 Sarthak1799 dismissed stale reviews from Narayanbhat166 and Chethan-rao via d177e87 July 11, 2024 11:12
Sakilmostak
Sakilmostak previously approved these changes Jul 12, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes Jul 12, 2024
@Sarthak1799 Sarthak1799 dismissed stale reviews from Narayanbhat166 and Sakilmostak via 6d50f73 July 15, 2024 13:44
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Jul 16, 2024
Merged via the queue into main with commit 3951ac6 Jul 16, 2024
11 of 13 checks passed
@Gnanasundari24 Gnanasundari24 deleted the mca-merchant-recipient branch July 16, 2024 08:33
pixincreate added a commit that referenced this pull request Jul 16, 2024
* 'main' of github.com:juspay/hyperswitch: (25 commits)
  fix(logs): ignore request headers while logging (#5273)
  feat(webhooks): add support for custom outgoing webhook http headers (#5275)
  fix(payment_methods): set `requires_cvv` to false when either `connector_mandate_details` or `network_transaction_id` is present during MITs (#5331)
  chore: create justfile for running commands for v1 and v2 migrations (#5325)
  fix(routing): do not update `perform_session_flow_routing` output if the `SessionRoutingChoice` is none (#5336)
  fix(database): modified_at updated for every state change for Payment Attempts (#5312)
  feat(mca): Added recipient connector call for open banking connectors (#3758)
  chore(version): 2024.07.16.0
  refactor(connector): [Mifinity] add a field language_preference in payment request for mifinity payment method data (#5326)
  fix(router): store `customer_acceptance` in payment_attempt, use it in confirm flow for delayed authorizations like external 3ds flow (#5308)
  feat(proxy): add support to pass proxy bypass urls from configs (#5322)
  Docs: Updating Error codes in API-ref (#5296)
  feat(core): [Payouts] Add retrieve flow for payouts (#4936)
  fix(connector): [AUTHORIZEDOTNET] Populate error reason for failure transactions (#5319)
  chore(version): 2024.07.15.0
  feat(logging): Emit a setup error when a restricted keys are used for logging default keys (#5185)
  feat(payment_methods): add support to migrate existing customer PMs from processor to hyperswitch (#5306)
  feat(connector): [DATATRANS] Implement card payments (#5028)
  chore: making of function create_encrypted_data (#5251)
  fix(payments): populate merchant order ref id in list (#5310)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Update Payment Connector Create to incorporate recipient creation
6 participants