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
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f9848a0
feat(mca): Added recipient connector call for open banking connectors
Sarthak1799 Feb 20, 2024
708774f
chore: run formatter
hyperswitch-bot[bot] Feb 21, 2024
5315345
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Feb 21, 2024
1886c11
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Mar 4, 2024
41666a0
fix(mca): Some fixes
Sarthak1799 Mar 4, 2024
e6a8754
fix(mca): Use merchant_id for customer in lcoker call
Sarthak1799 Mar 5, 2024
8b78b91
fix(mca) :Fixed clippy errors
Sarthak1799 Mar 11, 2024
6ae507e
fix(mca): Fixed mca response
Sarthak1799 Mar 12, 2024
d7839fe
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Mar 13, 2024
1bbd8c3
chore: run formatter
hyperswitch-bot[bot] Mar 13, 2024
7ba1295
fix(mca): Resolved comments
Sarthak1799 Mar 15, 2024
516e1f8
fix(mca): Resolved comments
Sarthak1799 Mar 15, 2024
6df183d
chore: run formatter
hyperswitch-bot[bot] Mar 15, 2024
aba43fb
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Apr 12, 2024
0265a1f
refactor(mca): Additional merchant data in mca
Sarthak1799 Apr 22, 2024
601dc3b
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Apr 22, 2024
a9608ef
fix(mca): Fixed errors
Sarthak1799 Apr 22, 2024
83c98ec
fix(mca): Fixed errors
Sarthak1799 Apr 23, 2024
5c1fd4d
fix(mca): fixed more errors
Sarthak1799 Apr 23, 2024
bc5e523
fix(mca): Fixed more errors
Sarthak1799 Apr 23, 2024
b3d291c
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 May 14, 2024
cf62cbf
fix(mca): Resolved comments
Sarthak1799 May 14, 2024
a7ec74a
fix(mca): Added config
Sarthak1799 May 16, 2024
237148e
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 May 23, 2024
1296af5
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Jul 8, 2024
15bf83a
fix(mca): Fixed errors
Sarthak1799 Jul 8, 2024
91cb50f
fix(mca): Fixed errors
Sarthak1799 Jul 8, 2024
0a2e266
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Jul 10, 2024
4cff58f
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jul 10, 2024
bc6ec0b
fix(mca): Resolved comments
Sarthak1799 Jul 10, 2024
2cf744a
fix(mca): Fixed errors
Sarthak1799 Jul 10, 2024
f1affe5
fix(mca): Fixed errors
Sarthak1799 Jul 10, 2024
d177e87
fix(mca): Resolved comments
Sarthak1799 Jul 11, 2024
791ba58
fix(mca): Resolved errors
Sarthak1799 Jul 11, 2024
f41a4c4
Merge branch 'main' of github.com:juspay/hyperswitch into mca-merchan…
Sarthak1799 Jul 11, 2024
1adb8d2
fix(mca): Resolved errors
Sarthak1799 Jul 11, 2024
72dc3f9
Merge branch 'main' into mca-merchant-recipient
Sarthak1799 Jul 11, 2024
cc1fba3
fix(mca): Fixed errors
Sarthak1799 Jul 11, 2024
6d50f73
fix(mca): Fixed some errors
Sarthak1799 Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4887,6 +4887,21 @@
}
}
},
"AdditionalMerchantData": {
"oneOf": [
{
"type": "object",
"required": [
"open_banking_recipient_data"
],
"properties": {
"open_banking_recipient_data": {
"$ref": "#/components/schemas/MerchantRecipientData"
}
}
}
]
},
"Address": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -11224,6 +11239,76 @@
},
"additionalProperties": false
},
"MerchantAccountData": {
"oneOf": [
{
"type": "object",
"required": [
"Iban"
],
"properties": {
"Iban": {
"type": "object",
"required": [
"iban",
"name"
],
"properties": {
"iban": {
"type": "string"
},
"name": {
"type": "string"
},
"connector_recipient_id": {
"allOf": [
{
"$ref": "#/components/schemas/RecipientIdType"
}
],
"nullable": true
}
}
}
}
},
{
"type": "object",
"required": [
"Bacs"
],
"properties": {
"Bacs": {
"type": "object",
"required": [
"account_number",
"sort_code",
"name"
],
"properties": {
"account_number": {
"type": "string"
},
"sort_code": {
"type": "string"
},
"name": {
"type": "string"
},
"connector_recipient_id": {
"allOf": [
{
"$ref": "#/components/schemas/RecipientIdType"
}
],
"nullable": true
}
}
}
}
}
]
},
"MerchantAccountDeleteResponse": {
"type": "object",
"required": [
Expand Down Expand Up @@ -11668,6 +11753,14 @@
}
],
"nullable": true
},
"additional_merchant_data": {
"allOf": [
{
"$ref": "#/components/schemas/AdditionalMerchantData"
}
],
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -11903,6 +11996,14 @@
},
"status": {
"$ref": "#/components/schemas/ConnectorStatus"
},
"additional_merchant_data": {
"allOf": [
{
"$ref": "#/components/schemas/AdditionalMerchantData"
}
],
"nullable": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -12109,6 +12210,45 @@
},
"additionalProperties": false
},
"MerchantRecipientData": {
"oneOf": [
{
"type": "object",
"required": [
"ConnectorRecipientId"
],
"properties": {
"ConnectorRecipientId": {
"type": "string",
"nullable": true
}
}
},
{
"type": "object",
"required": [
"WalletId"
],
"properties": {
"WalletId": {
"type": "string",
"nullable": true
}
}
},
{
"type": "object",
"required": [
"AccountData"
],
"properties": {
"AccountData": {
"$ref": "#/components/schemas/MerchantAccountData"
}
}
}
]
},
"MerchantRoutingAlgorithm": {
"type": "object",
"description": "Routing Algorithm specific to merchants",
Expand Down Expand Up @@ -18731,6 +18871,32 @@
}
}
},
"RecipientIdType": {
"oneOf": [
{
"type": "object",
"required": [
"ConnectorId"
],
"properties": {
"ConnectorId": {
"type": "string"
}
}
},
{
"type": "object",
"required": [
"LockerId"
],
"properties": {
"LockerId": {
"type": "string"
}
}
}
]
},
"ReconStatus": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -19490,6 +19656,7 @@
"worldline",
"worldpay",
"zen",
"plaid",
"zsl"
]
},
Expand Down
3 changes: 3 additions & 0 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,6 @@ public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "p

[user_auth_methods]
encryption_key = "" # Encryption key used for encrypting data in user_authentication_methods table

[locker_based_open_banking_connectors]
connector_list = ""
3 changes: 3 additions & 0 deletions config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,6 @@ keys = "user-agent"

[saved_payment_methods]
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
3 changes: 3 additions & 0 deletions config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,6 @@ keys = "user-agent"

[saved_payment_methods]
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
3 changes: 3 additions & 0 deletions config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,6 @@ keys = "user-agent"

[saved_payment_methods]
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
3 changes: 3 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -688,3 +688,6 @@ public = { name = "hyperswitch", base_url = "http://localhost:8080", schema = "p

[user_auth_methods]
encryption_key = "A8EF32E029BC3342E54BF2E172A4D7AA43E8EF9D2C3A624A9F04E2EF79DC698F"

[locker_based_open_banking_connectors]
connector_list = ""
3 changes: 3 additions & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,6 @@ merchant_name = "HyperSwitch"
card = "credit,debit"
bank_transfer = "ach,bacs,sepa"
wallet = "paypal,pix,venmo"

[locker_based_open_banking_connectors]
connector_list = ""
48 changes: 48 additions & 0 deletions crates/api_models/src/admin.rs
Copy link
Member

Choose a reason for hiding this comment

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

We should also send back the additional data (along with masked bank details if applicable) during retrieval of the merchant connector account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API picks up and sends whatever it finds in the DB, we're already sending back the data.

Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,51 @@ pub struct MerchantConnectorCreate {

#[schema(value_type = Option<ConnectorStatus>, example = "inactive")]
pub status: Option<api_enums::ConnectorStatus>,

/// In case the merchant needs to store any additional sensitive data
#[schema(value_type = Option<AdditionalMerchantData>)]
pub additional_merchant_data: Option<pii::SecretSerdeValue>,
Copy link
Member

Choose a reason for hiding this comment

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

Since we're parsing this in the flow anyways, why can't this just be a concrete type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

expecting it to have multiple variants with with complex nested structs underneath, hence thought of keeping it as a json.

Copy link
Member

Choose a reason for hiding this comment

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

If it's in the API, it's better for it to be a concrete type since any structural validations will be handled by the API layer itself and you won't have to manually parse it and throw errors.

}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub enum RecipientIdType {
#[schema(value_type= String)]
ConnectorId(Secret<String>),
#[schema(value_type= String)]
LockerId(Secret<String>),
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum AdditionalMerchantData {
OpenBankingRecipientData(MerchantRecipientData),
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub enum MerchantAccountData {
Iban {
#[schema(value_type= String)]
iban: Secret<String>,
name: String,
connector_recipient_id: Option<RecipientIdType>,
},
Bacs {
#[schema(value_type= String)]
account_number: Secret<String>,
#[schema(value_type= String)]
sort_code: Secret<String>,
name: String,
connector_recipient_id: Option<RecipientIdType>,
},
}

#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, ToSchema)]
pub enum MerchantRecipientData {
#[schema(value_type= Option<String>)]
ConnectorRecipientId(Secret<String>),
#[schema(value_type= Option<String>)]
WalletId(Secret<String>),
AccountData(MerchantAccountData),
}

// Different patterns of authentication.
Expand Down Expand Up @@ -805,6 +850,9 @@ pub struct MerchantConnectorResponse {

#[schema(value_type = ConnectorStatus, example = "inactive")]
pub status: api_enums::ConnectorStatus,

#[schema(value_type = Option<AdditionalMerchantData>)]
pub additional_merchant_data: Option<pii::SecretSerdeValue>,
}

/// Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc."
Expand Down
1 change: 1 addition & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ pub enum RoutableConnectors {
Worldline,
Worldpay,
Zen,
Plaid,
Zsl,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/diesel_models/src/merchant_connector_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct MerchantConnectorAccount {
pub pm_auth_config: Option<serde_json::Value>,
pub status: storage_enums::ConnectorStatus,
pub connector_wallets_details: Option<Encryption>,
pub additional_merchant_data: Option<Encryption>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand Down Expand Up @@ -74,6 +75,7 @@ pub struct MerchantConnectorAccountNew {
pub pm_auth_config: Option<serde_json::Value>,
pub status: storage_enums::ConnectorStatus,
pub connector_wallets_details: Option<Encryption>,
pub additional_merchant_data: Option<Encryption>,
}

#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ diesel::table! {
applepay_verified_domains -> Nullable<Array<Nullable<Text>>>,
pm_auth_config -> Nullable<Jsonb>,
status -> ConnectorStatus,
additional_merchant_data -> Nullable<Bytea>,
connector_wallets_details -> Nullable<Bytea>,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/kgraph_utils/benches/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fn build_test_data(
applepay_verified_domains: None,
pm_auth_config: None,
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
};
let config = CountryCurrencyFilter {
connector_configs: HashMap::new(),
Expand Down
1 change: 1 addition & 0 deletions crates/kgraph_utils/src/mca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ mod tests {
applepay_verified_domains: None,
pm_auth_config: None,
status: api_enums::ConnectorStatus::Inactive,
additional_merchant_data: None,
};

let config_map = kgraph_types::CountryCurrencyFilter {
Expand Down
4 changes: 4 additions & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::AuthorizationStatus,
api_models::enums::PaymentMethodStatus,
api_models::admin::MerchantConnectorCreate,
api_models::admin::AdditionalMerchantData,
api_models::admin::MerchantRecipientData,
api_models::admin::MerchantAccountData,
api_models::admin::RecipientIdType,
api_models::admin::MerchantConnectorUpdate,
api_models::admin::PrimaryBusinessDetails,
api_models::admin::FrmConfigs,
Expand Down
Loading
Loading