Skip to content

Conversation

@AnkitKmrGupta
Copy link
Contributor

@AnkitKmrGupta AnkitKmrGupta commented Jan 12, 2026

Type of Change

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

Description

This pull request introduces support for Platform Organizations, enabling both:

  1. Conversion of an existing Standard Organization to a Platform Organization, and
  2. Direct creation of a Platform Organization during signup via signup_with_merchant_id.

Along with these flows, the PR updates organization and merchant account creation logic, validation rules, and data models to safely enable platform-specific capabilities.

Key Changes

Platform Organization Creation & Conversion

  • Added new API request/response types:

    • ConvertOrganizationToPlatformRequest
    • ConvertOrganizationToPlatformResponse
      to support upgrading an existing organization to a Platform Organization, including event metric implementations.
  • Implemented convert_organization_to_platform_organization, which:

    • Validates conversion eligibility
    • Updates the organization type to Platform
    • Creates the Platform Merchant
    • Returns updated organization and merchant identifiers.
  • Extended signup_with_merchant_id to support direct creation of a Platform Organization during signup when platform creation is enabled and allowed.

  • Updated OrganizationUpdate and OrganizationUpdateInternal to support the ConvertToPlatform variant, ensuring correct organization type transitions and platform merchant handling.

Data Model and Enum Updates

  • Added OrganizationType to relevant API and database models to explicitly track whether an organization is STANDARD or PLATFORM.
  • Replaced deprecated MerchantAccountRequestType with MerchantAccountType across multiple models.

Merchant Account Creation and Validation

  • Tightened merchant creation rules:

    • Platform Organizations can own exactly one Platform Merchant
    • Standard Organizations can only create Standard Merchants
    • Platform Organizations can create Connected and Standard Merchants
  • Added helpers to safely construct platform merchant creation requests.

User Signup and Platform Safeguards

  • Added validation to ensure platform features are enabled before allowing platform organization creation.
  • Restricted Platform Organization creation via signup_with_merchant_id in production environments unless explicitly permitted.
  • Introduced a new InvalidPlatformOperation error variant for clearer error reporting on invalid platform-related actions.

Miscellaneous

  • Refactored imports and removed unnecessary organization updates related to platform merchant IDs.
  • Improved clarity and safety of platform-related flows across organization update and merchant creation logic.

These changes collectively enable safe creation and upgrading of Platform Organizations while enforcing strict business rules around merchant management and platform operations.

How did you test it?

Convert To Platform

Create Organization

curl --location 'http://localhost:8080/organization' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
  "organization_name": "Org_1",
  "organization_details": {
    "address": "123 Main Street",
    "city": "San Francisco",
    "country": "US"
  },
  "metadata": {
    "industry": "technology",
    "size": "medium"
  }
}
{
    "organization_id": "org_XpEBBGgsGEC1s86h9vHL",
    "organization_name": "Org_1",
    "organization_details": {
        "city": "San Francisco",
        "address": "123 Main Street",
        "country": "US"
    },
    "metadata": {
        "size": "medium",
        "industry": "technology"
    },
    "modified_at": "2026-01-13 07:13:00.765357",
    "created_at": "2026-01-13 07:13:00.76531",
    "organization_type": "standard"
}

Convert To Platform

curl --location 'http://localhost:8080/organization/org_XpEBBGgsGEC1s86h9vHL/convert_to_platform' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
  "platform_merchant_name": "platform_merchant"
}'
{
    "organization_id": "org_XpEBBGgsGEC1s86h9vHL",
    "organization_type": "platform",
    "platform_merchant_id": "platform_merchant"
}

Signup with merchant_id

curl --location 'http://localhost:8080/user/signup_with_merchant_id' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
  "name": "John Doe",
  "email": "[email protected]",
  "password": "SecurePassword123!",
  "company_name": "platform_mercahant_1",
  "organization_type": "platform"
}
{
    "is_email_sent": true
}

Screenshots

Convert To Platform

Screenshot 2026-01-13 at 12 53 39 PM Screenshot 2026-01-13 at 12 49 23 PM

Signup with merchant_id

Screenshot 2026-01-13 at 12 53 59 PM Screenshot 2026-01-13 at 1 00 44 PM

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

@AnkitKmrGupta AnkitKmrGupta requested review from a team as code owners January 12, 2026 13:43
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jan 12, 2026

@AnkitKmrGupta AnkitKmrGupta changed the title implement convert organization to platform organization feat(platform): implement convert organization to platform organization Jan 12, 2026
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 12, 2026
@AnkitKmrGupta AnkitKmrGupta force-pushed the convert-org-to-platform-org branch from 110b8b1 to ebc390f Compare January 14, 2026 07:45
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Jan 14, 2026
tsdk02
tsdk02 previously approved these changes Jan 14, 2026
pub company_name: String,
pub product_type: Option<common_enums::MerchantProductType>,
pub merchant_account_type: Option<common_enums::MerchantAccountRequestType>,
pub merchant_account_type: Option<common_enums::MerchantAccountType>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be MerchantAccountRequestType?

}

#[cfg(all(feature = "olap", feature = "v1"))]
fn create_platform_merchant_account_request(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check if we can move this functions to utils/helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants