Skip to content

feat(router): Payment Intent and MCA changes for split payments#9049

Merged
likhinbopanna merged 5 commits intomainfrom
split-payments-pr-1
Sep 1, 2025
Merged

feat(router): Payment Intent and MCA changes for split payments#9049
likhinbopanna merged 5 commits intomainfrom
split-payments-pr-1

Conversation

@AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Aug 25, 2025

Type of Change

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

Description

  • Add split_txns_enabled field to business_profile DB, create+update API calls
  • Add split_txns_enabled field in PaymentIntent
  • PML changes to filter payment methods based on split_enabled in MCA and split_txns_enabled in Intent

Additional Changes

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

Motivation and Context

Closes #9047

How did you test it?

  1. Business Profile Create Request (split_txns_enabled)
curl --location 'http://localhost:8080/v2/profiles' \
--header 'x-merchant-id: cloth_seller_v2_5WeDFMHDxeA6s3I9WReI' \
--header 'Authorization: admin-api-key=test_admin' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "profile_name": "businesss",
    "return_url": "https://google.com/success",
...
    "split_txns_enabled": "enable"
    
}'

Response:

{
    "merchant_id": "cloth_seller_v2_5WeDFMHDxeA6s3I9WReI",
    "id": "pro_ayVzG5Zr33W31ArJk7CK",
    "profile_name": "businesss",
    "return_url": "https://google.com/success",
    "enable_payment_response_hash": true,
    "payment_response_hash_key": "c94j5uGyFCAIU1N24p3mVl9DKLrSCN0xslChyzawzX1gwvSynCgpX6vS39JuA0J9",
    "redirect_to_merchant_with_http_post": false,
    "webhook_details": {
        "webhook_version": "1.0.1",
        "webhook_username": "ekart_retail",
        "webhook_password": "password_ekart@123",
        "webhook_url": "https://webhook.site",
        "payment_created_enabled": true,
        "payment_succeeded_enabled": true,
        "payment_failed_enabled": true,
        "payment_statuses_enabled": null,
        "refund_statuses_enabled": null,
        "payout_statuses_enabled": null
    },
    "metadata": null,
    "applepay_verified_domains": null,
    "session_expiry": 900,
    "payment_link_config": null,
    "authentication_connector_details": null,
    "use_billing_as_payment_method_billing": true,
    "extended_card_info_config": null,
    "collect_shipping_details_from_wallet_connector_if_required": false,
    "collect_billing_details_from_wallet_connector_if_required": false,
    "always_collect_shipping_details_from_wallet_connector": false,
    "always_collect_billing_details_from_wallet_connector": false,
    "is_connector_agnostic_mit_enabled": false,
    "payout_link_config": null,
    "outgoing_webhook_custom_http_headers": null,
    "order_fulfillment_time": 900,
    "order_fulfillment_time_origin": "create",
    "tax_connector_id": null,
    "is_tax_connector_enabled": false,
    "is_network_tokenization_enabled": false,
    "should_collect_cvv_during_payment": null,
    "is_click_to_pay_enabled": false,
    "authentication_product_ids": null,
    "card_testing_guard_config": {
        "card_ip_blocking_status": "disabled",
        "card_ip_blocking_threshold": 3,
        "guest_user_card_blocking_status": "disabled",
        "guest_user_card_blocking_threshold": 10,
        "customer_id_blocking_status": "disabled",
        "customer_id_blocking_threshold": 5,
        "card_testing_guard_expiry": 3600
    },
    "is_clear_pan_retries_enabled": false,
    "is_debit_routing_enabled": false,
    "merchant_business_country": null,
    "is_iframe_redirection_enabled": null,
    "is_external_vault_enabled": null,
    "external_vault_connector_details": null,
    "merchant_category_code": null,
    "merchant_country_code": null,
    "split_txns_enabled": "enable"
}
  1. Payment Intent Create Request
curl --location 'http://localhost:8080/v2/payments/create-intent' \
--header 'api-key: dev_xjdI9HLJv4OJIab8VojIjDWbXN3i4a50fzUaxgaQjtP3vwL3WmQVwNbgNmA9M5DV' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_dPNtC5bK3lNxBYt7kyk4' \
--header 'Authorization: api-key=dev_xjdI9HLJv4OJIab8VojIjDWbXN3i4a50fzUaxgaQjtP3vwL3WmQVwNbgNmA9M5DV' \
--data-raw '{
	"amount_details": {
		"order_amount": 1000,
		"currency": "USD"
	},
	"capture_method": "automatic",
	"authentication_type": "three_ds",
	"order_details": [
		{
			"product_name": "Apple iphone 15",
			"quantity": 1,
			"amount": 1000
		}
	],
	"billing": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "123456789",
			"country_code": "+1"
		},
		"email": "user@gmail.com"
	},
	"shipping": {
		"address": {
			"first_name": "John",
			"last_name": "Dough",
			"city": "Karwar",
			"zip": "571201",
			"state": "California",
			"country": "US"
		},
		"email": "example@example.com",
		"phone": {
			"number": "123456789",
			"country_code": "+1"
		}
	},
    "customer_id": "12345_cus_0198e54d6c3b7871bcfde4a50ee43b88"
}'
{
    "id": "12345_pay_0198e54f328775408faf14fc2c47651a",
    "status": "requires_payment_method",
    "amount_details": {
        "order_amount": 1000,
        "currency": "USD",
        "shipping_cost": null,
        "order_tax_amount": null,
        "external_tax_calculation": "skip",
        "surcharge_calculation": "skip",
        "surcharge_amount": null,
        "tax_on_surcharge": null
    },
    "client_secret": "cs_0198e54f32b07003a723ffba50f47fea",
    "profile_id": "pro_dPNtC5bK3lNxBYt7kyk4",
    "merchant_reference_id": null,
    "routing_algorithm_id": null,
    "capture_method": "automatic",
    "authentication_type": "three_ds",
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "+1"
        },
        "email": "user@gmail.com"
    },
    "shipping": {
        "address": {
            "city": "Karwar",
            "country": "US",
            "line1": null,
            "line2": null,
            "line3": null,
            "zip": "571201",
            "state": "California",
            "first_name": "John",
            "last_name": "Dough",
            "origin_zip": null
        },
        "phone": {
            "number": "123456789",
            "country_code": "+1"
        },
        "email": "example@example.com"
    },
    "customer_id": "12345_cus_0198e54d6c3b7871bcfde4a50ee43b88",
    "customer_present": "present",
    "description": null,
    "return_url": null,
    "setup_future_usage": "on_session",
    "apply_mit_exemption": "Skip",
    "statement_descriptor": null,
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 1000,
            "tax_rate": null,
            "total_tax_amount": null,
            "requires_shipping": null,
            "product_img_link": null,
            "product_id": null,
            "category": null,
            "sub_category": null,
            "brand": null,
            "product_type": null,
            "product_tax_code": null,
            "description": null,
            "sku": null,
            "upc": null,
            "commodity_code": null,
            "unit_of_measure": null,
            "total_amount": null,
            "unit_discount_amount": null
        }
    ],
    "allowed_payment_method_types": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "payment_link_enabled": "Skip",
    "payment_link_config": null,
    "request_incremental_authorization": "false",
    "split_txns_enabled": "true",
    "expires_on": "2025-08-26T07:52:09.530Z",
    "frm_metadata": null,
    "request_external_three_ds_authentication": "Skip"
}

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

@AnuthaDev AnuthaDev self-assigned this Aug 25, 2025
@AnuthaDev AnuthaDev added C-feature Category: Feature request or enhancement api-v2 labels Aug 25, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Aug 25, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  crates/openapi/src/openapi_v2.rs  30% smaller
  api-reference/v2/openapi_spec_v2.json  6% smaller
  crates/api_models/src/admin.rs  0% smaller
  crates/api_models/src/payments.rs  0% smaller
  crates/common_enums/src/enums.rs  0% smaller
  crates/diesel_models/src/business_profile.rs  0% smaller
  crates/diesel_models/src/payment_intent.rs  0% smaller
  crates/diesel_models/src/schema_v2.rs  0% smaller
  crates/hyperswitch_domain_models/src/business_profile.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/core/admin.rs  0% smaller
  crates/router/src/core/payments/transformers.rs  0% smaller
  crates/router/src/services/kafka/payment_intent.rs  0% smaller
  crates/router/src/services/kafka/payment_intent_event.rs  0% smaller
  crates/router/src/types/api/admin.rs  0% smaller
  v2_compatible_migrations/2025-08-25-090221_add-split-txns-enabled-in-payment-intent/down.sql Unsupported file format
  v2_compatible_migrations/2025-08-25-090221_add-split-txns-enabled-in-payment-intent/up.sql Unsupported file format
  v2_compatible_migrations/2025-08-29-040411_add-split-txns-enabled-in-business-profile/down.sql Unsupported file format
  v2_compatible_migrations/2025-08-29-040411_add-split-txns-enabled-in-business-profile/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Aug 25, 2025
@AnuthaDev AnuthaDev force-pushed the split-payments-pr-1 branch from 2450ccd to 6b02d44 Compare August 26, 2025 08:35
@AnuthaDev AnuthaDev marked this pull request as ready for review August 26, 2025 08:36
@AnuthaDev AnuthaDev requested review from a team as code owners August 26, 2025 08:36
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 26, 2025
@AnuthaDev AnuthaDev force-pushed the split-payments-pr-1 branch from 2aea0a5 to fee9289 Compare August 29, 2025 04:50
hrithikesh026
hrithikesh026 previously approved these changes Aug 29, 2025
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS split_txns_enabled VARCHAR(16); No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this enum variant will not exceed 16 characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be enough. We can anyways rename enum variants when serializing them in DB.

@likhinbopanna likhinbopanna added this pull request to the merge queue Sep 1, 2025
Merged via the queue into main with commit 81b340d Sep 1, 2025
29 of 33 checks passed
@likhinbopanna likhinbopanna deleted the split-payments-pr-1 branch September 1, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 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.

Payment Intent and MCA changes for split payments

4 participants