Skip to content

Conversation

racnan
Copy link
Contributor

@racnan racnan commented Dec 18, 2024

Type of Change

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

Description

About the feature

  • This the first PR for the Platform Account feature.
  • Feature is under development and behind the feature flag.
  • Feature is supposed to be disabled for sandbox and production environments.

Enabling the platform account.

  • New API has been created to enable platform account.
  • API requires Admin API auth.
  • Once enabled, there is no way of disabling platform account as of now.

How it works

  • A new special header is to be sent by the platform called x-connected-merchant-id.
  • Platform will use its own API key irrespective of the merchant id present in the above header.
  • Value of this header is supposed to be the merchant id of the merchant account on behalf of which the platform is performing the operation.
  • If the platform has is_platform true and the merchant account on behalf of which operation is performed belongs to the same organisation as platform then the operation is allowed.

Payment Intent

  • Operation will be performed for merchant id present in the x-connected-merchant-id header.
  • platform_merchant_id column for the payment intent will be populated with platforms merchant id.

Other operations

  • Will add context of platform_merchant_id in other operations as well.

Additional Changes

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

Motivation and Context

#6883

How did you test it?

  1. Create a merchant account(m1).
  2. Use below api to convert it into platform account.
curl --location --request POST '<BASE URL>/accounts/{merchant_id}/platform' \
--header 'api-key:<ADMIN API KEY>'
  1. Create another merchant account in the same organisation(m2).
  2. Do a payment using platform's(m1) API key for connected merchant account(m2) by passing header x-connected-merchant-id with value as connected merchant account's merchant id.
  3. Check if payment is created for connected merchant account.
  4. Check if platform_merchant_id is populated with platform's merchant id.

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

@racnan racnan requested review from a team as code owners December 18, 2024 18:20
Copy link

semanticdiff-com bot commented Dec 18, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/routes/lock_utils.rs  86% smaller
  crates/router/build.rs  66% smaller
  crates/router/src/routes/app.rs  16% smaller
  crates/router/src/compatibility/stripe/errors.rs  6% smaller
  crates/router/src/services/authentication.rs  3% smaller
  .github/workflows/postman-collection-runner.yml Unsupported file format
  config/deployments/integration_test.toml Unsupported file format
  config/deployments/production.toml Unsupported file format
  config/deployments/sandbox.toml Unsupported file format
  config/development.toml Unsupported file format
  config/docker_compose.toml Unsupported file format
  crates/diesel_models/src/merchant_account.rs  0% smaller
  crates/diesel_models/src/payment_intent.rs  0% smaller
  crates/diesel_models/src/schema.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/hyperswitch_domain_models/src/errors/api_error_response.rs  0% smaller
  crates/hyperswitch_domain_models/src/merchant_account.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments.rs  0% smaller
  crates/hyperswitch_domain_models/src/payments/payment_intent.rs  0% smaller
  crates/router/src/compatibility/stripe/payment_intents.rs  0% smaller
  crates/router/src/compatibility/stripe/setup_intents.rs  0% smaller
  crates/router/src/configs/secrets_transformers.rs  0% smaller
  crates/router/src/configs/settings.rs  0% smaller
  crates/router/src/core/admin.rs  0% smaller
  crates/router/src/core/fraud_check.rs  0% smaller
  crates/router/src/core/fraud_check/operation.rs  0% smaller
  crates/router/src/core/fraud_check/operation/fraud_check_post.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller
  crates/router/src/core/payments/helpers.rs  0% smaller
  crates/router/src/core/payments/operations.rs  0% smaller
  crates/router/src/core/payments/operations/payment_approve.rs  0% smaller
  crates/router/src/core/payments/operations/payment_cancel.rs  0% smaller
  crates/router/src/core/payments/operations/payment_capture.rs  0% smaller
  crates/router/src/core/payments/operations/payment_capture_v2.rs  0% smaller
  crates/router/src/core/payments/operations/payment_complete_authorize.rs  0% smaller
  crates/router/src/core/payments/operations/payment_confirm.rs  0% smaller
  crates/router/src/core/payments/operations/payment_confirm_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payment_create.rs  0% smaller
  crates/router/src/core/payments/operations/payment_create_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payment_get.rs  0% smaller
  crates/router/src/core/payments/operations/payment_get_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payment_post_session_tokens.rs  0% smaller
  crates/router/src/core/payments/operations/payment_reject.rs  0% smaller
  crates/router/src/core/payments/operations/payment_session.rs  0% smaller
  crates/router/src/core/payments/operations/payment_session_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payment_start.rs  0% smaller
  crates/router/src/core/payments/operations/payment_status.rs  0% smaller
  crates/router/src/core/payments/operations/payment_update.rs  0% smaller
  crates/router/src/core/payments/operations/payment_update_intent.rs  0% smaller
  crates/router/src/core/payments/operations/payments_incremental_authorization.rs  0% smaller
  crates/router/src/core/payments/operations/tax_calculation.rs  0% smaller
  crates/router/src/core/payments/session_operation.rs  0% smaller
  crates/router/src/core/webhooks/incoming.rs  0% smaller
  crates/router/src/lib.rs  0% smaller
  crates/router/src/routes/admin.rs  0% smaller
  crates/router/src/routes/payments.rs  0% smaller
  crates/router/src/utils/user/sample_data.rs  0% smaller
  crates/router/src/workflows/outgoing_webhook_retry.rs  0% smaller
  crates/router/src/workflows/payment_sync.rs  0% smaller
  crates/router/tests/payments.rs  0% smaller
  crates/router/tests/payments2.rs  0% smaller
  crates/router_env/src/logger/types.rs  0% smaller
  migrations/2024-12-03-072318_platform_merchant_account/down.sql Unsupported file format
  migrations/2024-12-03-072318_platform_merchant_account/up.sql Unsupported file format

@racnan racnan self-assigned this Dec 18, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Dec 18, 2024
@racnan racnan added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payments Area: payments M-database-changes Metadata: This PR involves database schema changes and removed M-database-changes Metadata: This PR involves database schema changes labels Dec 18, 2024
@racnan racnan requested a review from a team as a code owner December 23, 2024 08:55
pixincreate
pixincreate previously approved these changes Dec 23, 2024
Copy link
Member

@pixincreate pixincreate left a comment

Choose a reason for hiding this comment

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

ci looks good to me

NishantJoshi00
NishantJoshi00 previously approved these changes Dec 23, 2024
Copy link
Contributor

@NishantJoshi00 NishantJoshi00 left a comment

Choose a reason for hiding this comment

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

The HeaderAuth side of things look good

Narayanbhat166
Narayanbhat166 previously approved these changes Dec 23, 2024
Copy link
Member

@SanchithHegde SanchithHegde Dec 23, 2024

Choose a reason for hiding this comment

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

Can you make the same changes in the other config files as well: config/development.toml and config/docker_compose.toml?

@@ -724,12 +775,14 @@ where
}

#[cfg(all(feature = "partial-auth", feature = "v1"))]
#[allow(unused)]
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this annotation?

@@ -1412,15 +1537,20 @@ pub struct MerchantIdAuth(pub id_type::MerchantId);

#[cfg(feature = "v1")]
#[async_trait]
#[allow(unused)]
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Narayanbhat166
Narayanbhat166 previously approved these changes Dec 23, 2024
SanchithHegde
SanchithHegde previously approved these changes Dec 23, 2024
@racnan racnan dismissed stale reviews from SanchithHegde and Narayanbhat166 via 4049c6e December 23, 2024 10:32
@racnan racnan force-pushed the platform-merchant-account branch from 724cf37 to 4049c6e Compare December 23, 2024 10:32
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 23, 2024
Merged via the queue into main with commit 95fcf2a Dec 23, 2024
17 of 19 checks passed
@Gnanasundari24 Gnanasundari24 deleted the platform-merchant-account branch December 23, 2024 13:21
pixincreate added a commit to Ankesh2004/hyperswitch that referenced this pull request Dec 26, 2024
…r-verifyurl-in-redirection-handler

* 'main' of github.com:juspay/hyperswitch: (444 commits)
  ci: add tests that make use of locker (juspay#6735)
  chore(version): 2024.12.26.1
  fix(router): populate `profile_id` in for the HeaderAuth of v1 (juspay#6936)
  docs(openapi): update /relay request example (juspay#6942)
  chore(version): 2024.12.26.0
  fix(payments_list): handle same payment/attempt ids for different merchants (juspay#6917)
  refactor(core): remove merchant return url from `router_data` (juspay#6895)
  feat(router): add endpoint for listing connector features  (juspay#6612)
  fix(wasm): remove chasenet from jpmorgan wasm as ChaseNet doesn’t exist in PMT (juspay#6927)
  fix(cors): expose all headers set by application in `access-control-expose-headers` header value (juspay#6877)
  chore(version): 2024.12.24.0
  feat(cypress): valdiate `error_code` and `error_message` and make it visible in `reports` (juspay#6913)
  fix(wasm): remove extra space from wasm for payment_method_type of JPMorgan (juspay#6923)
  fix(wasm): fix feature dependencies in `connector_configs` crate for WASM builds  (juspay#6832)
  feat(router): add /retrieve api for relay (juspay#6918)
  feat(core): implemented platform merchant account (juspay#6882)
  feat(payments_v2): add payment method list endpoint (juspay#6805)
  fix(connector): [Cybersource] fix the required fields for wallet mandate payments (juspay#6911)
  chore(version): 2024.12.23.0
  feat(connector): [JPMORGAN] add Payment flows for cards (juspay#6668)
  ...
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows A-payments Area: payments M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(core): setup platform merchant account
8 participants