feat(router): external vault confirm changes for v2 payments
Type of Change
- [ ] Bugfix
- [x] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD
Description
Payments Confirm changes for supporting payments via external vault ( currently via VGS https://www.verygoodsecurity.com )
Additional Changes
- [x] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables
Motivation and Context
There is a need to completing payments with external vault in scope and needed changes in Payments V2 service to support this.
How did you test it?
- Create a business profile
curl --location 'http://localhost:8080/v2/profiles' \
--header 'x-merchant-id: merchant_id' \
--header 'Authorization: admin-api-key=test_admin' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
"profile_name": "profile",
"return_url": "https://google.com/success",
"enable_payment_response_hash": true,
"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
},
"metadata": null,
"order_fulfillment_time": 900,
"order_fulfillment_time_origin": "create",
"applepay_verified_domains": null,
"session_expiry": 900,
"payment_link_config": null,
"authentication_connector_details": null,
"use_billing_as_payment_method_billing": true,
"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
}'
Response
{
"merchant_id": "merchant_id",
"id": "pro_sxTtfDnQ5ERmnCSXDoFd",
"profile_name": "profile",
"return_url": "https://google.com/success",
"enable_payment_response_hash": true,
"payment_response_hash_key": "",
"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
},
"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
}
- Create Merchant Connector Account( MCA ) with required fields in metadata ( field name for proxy URL -> external_vault_url )
curl --location 'http://localhost:8080/v2/connector-accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-merchant-id: merchant_id' \
--header 'x-profile-id: profile_id' \
--header 'Authorization: admin-api-key=test_admin' \
--header 'api-key: test_admin' \
--data '{
"connector_type": "payment_processor",
"connector_name": "stripe",
"connector_account_details": {
"auth_type": "HeaderKey",
"api_key": "{{connector_api_key}}"
},
"payment_methods_enabled": [
{
"payment_method_type": "card",
"payment_method_subtypes": [
{
"payment_method_subtype": "credit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_subtype": "debit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
},
{
"payment_method_type": "external_proxy_card_data",
"payment_method_subtypes": [
{
"payment_method_subtype": "proxy_card",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
}
],
"metadata": {
"status_url": "https://2753-2401-4900-1cb8-2ff9-24dd-1ccf-ed12-b464.in.ngrok.io/webhooks/merchant_1678699058/globalpay",
"account_name": "transaction_processing",
"pricing_type": "fixed_price",
"acquirer_bin": "438309",
"acquirer_merchant_id": "00002000000",
"external_vault_url":"{{proxy_url}}"
},
"frm_configs": null,
"connector_webhook_details": {
"merchant_secret": ""
},
"profile_id": "profile_id"
}'
Response
{
"connector_type": "payment_processor",
"connector_name": "stripe",
"connector_label": "stripe_1749403248",
"id": "mca_GO3zQvkOq2ovGUFyzhJQ",
"profile_id": "pro_4Diz0h0zwSntpZrmISIl",
"connector_account_details": {
"auth_type": "HeaderKey",
"api_key": "key"
},
"payment_methods_enabled": [
{
"payment_method_type": "card",
"payment_method_subtypes": [
{
"payment_method_subtype": "credit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
},
{
"payment_method_subtype": "debit",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
},
{
"payment_method_type": "external_proxy_card_data",
"payment_method_subtypes": [
{
"payment_method_subtype": "proxy_card",
"payment_experience": null,
"card_networks": [
"Visa",
"Mastercard"
],
"accepted_currencies": null,
"accepted_countries": null,
"minimum_amount": -1,
"maximum_amount": 68607706,
"recurring_enabled": true,
"installment_payment_enabled": true
}
]
}
],
"connector_webhook_details": {
"merchant_secret": "",
"additional_secret": null
},
"metadata": {
"status_url": "https://2753-2401-4900-1cb8-2ff9-24dd-1ccf-ed12-b464.in.ngrok.io/webhooks/merchant_1678699058/globalpay",
"account_name": "transaction_processing",
"acquirer_bin": "438309",
"pricing_type": "fixed_price",
"external_vault_url": "https://tntwccevmlr.sandbox.verygoodproxy.com/",
"acquirer_merchant_id": "00002000000"
},
"disabled": false,
"frm_configs": null,
"applepay_verified_domains": null,
"pm_auth_config": null,
"status": "active",
"additional_merchant_data": null,
"connector_wallets_details": null,
"feature_metadata": null
}
- Create a payment-intent
curl --location 'http://localhost:8080/v2/payments/create-intent' \
--header 'api-key: api_key' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: profile_id' \
--header 'Authorization: api-key=api_key' \
--data-raw '{
"amount_details": {
"order_amount": 100,
"currency": "USD"
},
"capture_method":"manual",
"authentication_type": "no_three_ds",
"billing": {
"address": {
"first_name": "John",
"last_name": "Dough"
},
"email": "[email protected]"
},
"shipping": {
"address": {
"first_name": "John",
"last_name": "Dough",
"city": "Karwar",
"zip": "581301",
"state": "Karnataka"
},
"email": "[email protected]"
}
}'
Response
{
"id": "12345_pay_019750b48e927dc19819b24a879ead10",
"status": "requires_payment_method",
"amount_details": {
"order_amount": 100,
"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_019750b48ed272b2ab0d5b2b601507eb",
"profile_id": "profile_Id",
"merchant_reference_id": null,
"routing_algorithm_id": null,
"capture_method": "manual",
"authentication_type": "no_three_ds",
"billing": {
"address": {
"city": null,
"country": null,
"line1": null,
"line2": null,
"line3": null,
"zip": null,
"state": null,
"first_name": "John",
"last_name": "Dough"
},
"phone": null,
"email": "[email protected]"
},
"shipping": {
"address": {
"city": "Karwar",
"country": null,
"line1": null,
"line2": null,
"line3": null,
"zip": "581301",
"state": "Karnataka",
"first_name": "John",
"last_name": "Dough"
},
"phone": null,
"email": "[email protected]"
},
"customer_id": null,
"customer_present": "present",
"description": null,
"return_url": null,
"setup_future_usage": "on_session",
"apply_mit_exemption": "Skip",
"statement_descriptor": null,
"order_details": 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": "default",
"expires_on": "2025-06-08T18:16:39.782Z",
"frm_metadata": null,
"request_external_three_ds_authentication": "Skip"
}
- Confirm intent with new
PaymentMethodDataenum ,external_proxy_card_data
curl --location 'http://localhost:8080/v2/payments/12345_pay_019750b48e927dc19819b24a879ead10/confirm-intent' \
--header 'x-profile-id: profile_id' \
--header 'x-client-secret: cs_019750b48ed272b2ab0d5b2b601507eb' \
--header 'Authorization: api-key=api_key' \
--header 'Content-Type: application/json' \
--header 'api-key: pk_dev_d5bd3a623d714044b879d3a050ae6e68' \
--data '{
"payment_method_data": {
"external_proxy_card_data": {
"card_number": "tok_sandbox_ZgPN54WU8y8tDjc6qfEsH",
"card_exp_month": "tok_sandbox_esTtoSjy4Yach1AYA7f5WT",
"card_exp_year": "tok_sandbox_e3z2krWdKqgYRhV9rCo9oS",
"card_holder_name": "John Doe",
"card_cvc": "100"
}
},
"payment_method_type": "card",
"payment_method_subtype": "debit"
}'
Response
{
"id": "12345_pay_019750b48e927dc19819b24a879ead10",
"status": "requires_capture",
"amount": {
"order_amount": 100,
"currency": "USD",
"shipping_cost": null,
"order_tax_amount": null,
"external_tax_calculation": "skip",
"surcharge_calculation": "skip",
"surcharge_amount": null,
"tax_on_surcharge": null,
"net_amount": 100,
"amount_to_capture": null,
"amount_capturable": 100,
"amount_captured": 0
},
"customer_id": null,
"connector": "stripe",
"created": "2025-06-08T18:01:39.782Z",
"payment_method_data": {
"billing": null
},
"payment_method_type": "card",
"payment_method_subtype": "debit",
"connector_transaction_id": "pi_3RXnXRD5R7gDAGff1OxGVzVu",
"connector_reference_id": null,
"merchant_connector_id": "mca_GO3zQvkOq2ovGUFyzhJQ",
"browser_info": null,
"error": null,
"shipping": null,
"billing": null,
"attempts": null,
"connector_token_details": {
"token": "pm_1RXnXRD5R7gDAGffZloi7Myo",
"connector_token_request_reference_id": "P5c1IhgUdBt0O6pNEO"
},
"payment_method_id": null,
"next_action": null,
"return_url": "https://google.com/success",
"authentication_type": "no_three_ds",
"authentication_type_applied": "no_three_ds",
"is_iframe_redirection_enabled": null
}
VGS proxy dashboard routing ->
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
Summary by CodeRabbit
-
New Features
- Introduced support for an external proxy card payment method, allowing users to provide detailed proxy card information for payments.
- Added a new payment method type and schema for proxy cards in the API documentation and payment flows.
-
Bug Fixes
- Ensured proper handling and error messaging for unsupported proxy card payments across all connectors and payment flows.
-
Documentation
- Updated API reference and OpenAPI documentation to include the new external proxy card payment method and its fields.
Changed Files
Walkthrough
A new payment method type, "external proxy card data," has been introduced across the API, models, domain, and connector layers. This includes new enum variants, schema definitions, serialization/deserialization logic, OpenAPI documentation, and connector handling. Most connectors now recognize this method, typically returning a "not implemented" error, while Stripe implements conditional logic for proxy card routing.
Changes
| Files / Areas | Change Summary |
|---|---|
api-reference-v2/openapi_spec.json, api-reference/openapi_spec.json |
Added "external_proxy_card_data" payment method type, new "ProxyCard" schema, updated enums and oneOfs for payment methods. |
crates/api_models/src/payments.rs, crates/hyperswitch_domain_models/src/payment_method_data.rs |
Added ProxyCard struct, extended PaymentMethodData enum with ExternalProxyCardData, updated trait impls, conversions, and serialization. |
crates/common_enums/src/enums.rs, crates/common_enums/src/transformers.rs |
Added ProxyCard and ExternalProxyCardData variants to enums and transformers. |
crates/connector_configs/src/response_modifier.rs, crates/connector_configs/src/transformer.rs |
Added handling for ExternalProxyCardData in connector config logic. |
crates/euclid/src/frontend/dir/enums.rs, crates/euclid/src/frontend/dir/lowering.rs, crates/euclid/src/frontend/dir/transformers.rs |
Added Proxy card type, mapped to new payment method type, updated trait impls for new variants. |
crates/hyperswitch_connectors/src/connectors/*/transformers.rs, crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs, crates/hyperswitch_connectors/src/connectors/stripe.rs |
Added match arms for ExternalProxyCardData in all connectors, typically returning "NotImplemented" errors; Stripe adds full support for proxy card data and routing. |
crates/hyperswitch_connectors/src/utils.rs |
Updated type conversion to treat ExternalProxyCardData as card. |
crates/kgraph_utils/src/mca.rs, crates/kgraph_utils/src/transformers.rs |
Added support for new payment method and type in graph utilities and transformers. |
crates/openapi/src/openapi.rs, crates/openapi/src/openapi_v2.rs |
Registered ProxyCard in OpenAPI schema components. |
crates/payment_methods/src/helpers.rs |
Added validation logic for new payment method and type pairing. |
crates/router/src/connector/utils.rs, crates/router/src/core/payments.rs, crates/router/src/core/payments/helpers.rs, crates/router/src/core/payments/operations/payment_response.rs, crates/router/src/core/payments/transformers.rs, crates/router/src/core/payout_link.rs, crates/router/src/types/transformers.rs |
Added handling for ExternalProxyCardData in payment routing, filtering, and type conversions; minor logging addition. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant API
participant Router
participant Connector
participant Stripe
participant OtherConnector
Client->>API: Submit payment with external_proxy_card_data
API->>Router: Parse PaymentMethodData::ExternalProxyCardData
Router->>Connector: Route payment method data
alt Stripe Connector
Connector->>Stripe: Handle ProxyCard logic
Stripe->>Stripe: Check connector metadata for vault URL
Stripe-->>Connector: Process payment or return error
else Other Connectors
Connector->>OtherConnector: Match on ExternalProxyCardData
OtherConnector-->>Connector: Return NotImplemented error
end
Connector-->>Router: Respond with result or error
Router-->>API: Return payment status or error
API-->>Client: Respond to client
Poem
In fields of code where payments grow,
A proxy card now joins the show!
With enums stretched and schemas new,
The connectors check what they can do.
Stripe may route, the rest may stall—
But rabbits cheer the change for all!
🐇💳✨
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.