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(core): implemented platform merchant account #6882

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

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/src/core/payments/operations/payment_get.rs  67% 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
  config/deployments/integration_test.toml Unsupported file format
  config/deployments/production.toml Unsupported file format
  config/deployments/sandbox.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_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_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 added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 18, 2024
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 18, 2024
@racnan racnan linked an issue Dec 18, 2024 that may be closed by this pull request
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 S-waiting-on-review Status: This PR has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(core): setup platform merchant account
1 participant