Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payouts): add external vault proxy execution contract (#14580)
Sakil Mostak0ab6c3c90c98
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 0ffe766050..c646a9e548 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -8245,6 +8245,33 @@"application/json": {"schema": {"$ref": "#/components/schemas/PayoutsCreateRequest"+ },+ "examples": {+ "External vault proxy payout (not yet implemented)": {+ "value": {+ "amount": 1000,+ "auto_fulfill": true,+ "confirm": true,+ "connector": [+ "cybersource"+ ],+ "currency": "USD",+ "customer_id": "cus_external_vault_123",+ "entity_type": "Individual",+ "merchant_order_reference_id": "merchant_payout_1001",+ "payout_id": "payout_proxy_merchant_1001",+ "payout_method_id": "pm_external_vault_123",+ "payout_type": "card",+ "profile_id": "pro_external_vault_123",+ "recurring": false+ }+ },+ "Normal payout": {+ "value": {+ "amount": 1000,+ "currency": "USD"+ }+ }}}},@@ -8262,7 +8289,10 @@}},"400": {- "description": "Missing Mandatory fields"+ "description": "Missing mandatory fields or invalid request"+ },+ "501": {+ "description": "External-vault proxy payout execution is not implemented yet"}},"security": [@@ -39921,7 +39951,7 @@},"customer_id": {"type": "string",- "description": "The identifier for the customer object. If not provided the customer ID will be autogenerated. _Deprecated: Use customer_id instead._",+ "description": "Customer identifier for normal and proxy payouts; normal creates may generate it when omitted, while proxy creates require this or customer.id owning payout_method_id. _Deprecated: Use customer.id instead._","deprecated": true,"example": "cus_y3oqhf46pyzuxjbcn2giaqnb44","nullable": true,@@ -40069,7 +40099,7 @@},"payout_method_id": {"type": "string",- "description": "Identifier for payout method",+ "description": "Saved payment-method identifier, resolved internally for normal payouts and to vault tokens for proxy payouts.","nullable": true},"browser_info": {@@ -41019,7 +41049,7 @@},"customer_id": {"type": "string",- "description": "The identifier for the customer object. If not provided the customer ID will be autogenerated. _Deprecated: Use customer_id instead._",+ "description": "Customer identifier for normal and proxy payouts; normal creates may generate it when omitted, while proxy creates require this or customer.id owning payout_method_id. _Deprecated: Use customer.id instead._","deprecated": true,"example": "cus_y3oqhf46pyzuxjbcn2giaqnb44","nullable": true,@@ -41169,7 +41199,7 @@},"payout_method_id": {"type": "string",- "description": "Identifier for payout method",+ "description": "Saved payment-method identifier, resolved internally for normal payouts and to vault tokens for proxy payouts.","nullable": true},"browser_info": {@@ -41289,7 +41319,7 @@},"customer_id": {"type": "string",- "description": "The identifier for the customer object. If not provided the customer ID will be autogenerated. _Deprecated: Use customer_id instead._",+ "description": "Customer identifier for normal and proxy payouts; normal creates may generate it when omitted, while proxy creates require this or customer.id owning payout_method_id. _Deprecated: Use customer.id instead._","deprecated": true,"example": "cus_y3oqhf46pyzuxjbcn2giaqnb44","nullable": true,@@ -41433,7 +41463,7 @@},"payout_method_id": {"type": "string",- "description": "Identifier for payout method",+ "description": "Saved payment-method identifier, resolved internally for normal payouts and to vault tokens for proxy payouts.","nullable": true},"browser_info": {diff --git a/api-reference/v1/payouts/payouts--create.mdx b/api-reference/v1/payouts/payouts--create.mdxindex 923d4f0bc1..14b91af356 100644--- a/api-reference/v1/payouts/payouts--create.mdx+++ b/api-reference/v1/payouts/payouts--create.mdx@@ -1,3 +1,17 @@---openapi: post /payouts/create----\ No newline at end of file+---++Create a payout with `payout_method_data` (including raw card details) or a saved `payout_method_id`.++## External-vault card payouts++Use a card saved during a payment. Provide a unique `payout_id`, the saved `payout_method_id`, and the card owner's `customer_id` or `customer.id`.++Set `confirm=true`, `auto_fulfill=true`, `payout_type=card`, and `recurring=false`. These values apply when omitted for external-vault payouts. Send the request from your server; no separate confirmation call is required. For this flow, use the saved `payout_method_id` instead of inline `payout_method_data`. Do not send vault tokens or credentials.++## Retry handling++After a timeout, retrieve the payout using its `payout_id` before submitting another request. Do not create a new payout ID to retry the same payout.++Creating a payout with an existing `payout_id` returns a duplicate-payout error. Use `merchant_order_reference_id` for reconciliation, not retry protection.diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 29a6a45983..582c192899 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -27429,7 +27429,7 @@"properties": {"payout_id": {"type": "string",- "description": "Unique identifier for the payout. This ensures idempotency for multiple payouts that have been done by a single merchant. This field is auto generated and is returned in the API response, **not required to be included in the Payout Create/Update Request.**",+ "description": "Payout identifier; optional for normal creates and required for external-vault proxy creates.","example": "187282ab-40ef-47a9-9206-5099ba31e432","nullable": true,"maxLength": 30,@@ -27533,7 +27533,7 @@},"customer_id": {"type": "string",- "description": "The identifier for the customer object. If not provided the customer ID will be autogenerated. _Deprecated: Use customer_id instead._",+ "description": "Customer identifier for normal and proxy payouts; normal creates may generate it when omitted, while proxy creates require this or customer.id owning payout_method_id. _Deprecated: Use customer.id instead._","deprecated": true,"example": "cus_y3oqhf46pyzuxjbcn2giaqnb44","nullable": true,@@ -27683,7 +27683,7 @@},"payout_method_id": {"type": "string",- "description": "Identifier for payout method",+ "description": "Saved payment-method identifier, resolved internally for normal payouts and to vault tokens for proxy payouts.","nullable": true},"browser_info": {diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rsindex 11936e7ff8..1cd1c34773 100644--- a/crates/api_models/src/payouts.rs+++ b/crates/api_models/src/payouts.rs@@ -37,7 +37,7 @@ pub enum PayoutRequest {#[generate_schemas(PayoutsCreateRequest, PayoutUpdateRequest, PayoutConfirmRequest)]#[serde(deny_unknown_fields)]pub struct PayoutCreateRequest {- /// Unique identifier for the payout. This ensures idempotency for multiple payouts that have been done by a single merchant. This field is auto generated and is returned in the API response, **not required to be included in the Payout Create/Update Request.**+ /// Payout identifier; optional for normal creates and required for external-vault proxy creates.#[schema(value_type = Option<String>,min_length = 30,@@ -118,7 +118,7 @@ pub struct PayoutCreateRequest {#[schema(value_type = Option<bool>, example = true, default = false)]pub auto_fulfill: Option<bool>,- /// The identifier for the customer object. If not provided the customer ID will be autogenerated. _Deprecated: Use customer_id instead._+ /// Customer identifier for normal and proxy payouts; normal creates may generate it when omitted, while proxy creates require this or customer.id owning payout_method_id. _Deprecated: Use customer.id instead._#[schema(deprecated, value_type = Option<String>, max_length = 255, example = "cus_y3oqhf46pyzuxjbcn2giaqnb44")]pub customer_id: Option<id_type::CustomerId>,@@ -205,7 +205,7 @@ pub struct PayoutCreateRequest {#[schema(deprecated, max_length = 255, example = "+1")]pub phone_country_code: Option<String>,- /// Identifier for payout method+ /// Saved payment-method identifier, resolved internally for normal payouts and to vault tokens for proxy payouts.pub payout_method_id: Option<String>,/// Additional details required by 3DS 2.0diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 872c3973b9..52d7be8d03 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -9097,6 +9097,30 @@ pub enum BrazilStatesAbbreviation {Tocantins,}+/// Internal execution marker; not a merchant-supplied payout request selector.+#[derive(+ Clone,+ Copy,+ Debug,+ Default,+ Eq,+ Hash,+ PartialEq,+ serde::Deserialize,+ serde::Serialize,+ strum::Display,+ strum::EnumIter,+ strum::EnumString,+)]+#[router_derive::diesel_enum(storage_type = "text")]+#[serde(rename_all = "snake_case")]+#[strum(serialize_all = "snake_case")]+pub enum PayoutExecutionKind {+ #[default]+ Normal,+ ExternalVaultProxy,+}+#[derive(Clone,Copy,diff --git a/crates/diesel_models/src/payout_attempt.rs b/crates/diesel_models/src/payout_attempt.rsindex 3d5f3018c5..32ce9dfd0e 100644--- a/crates/diesel_models/src/payout_attempt.rs+++ b/crates/diesel_models/src/payout_attempt.rs@@ -46,6 +46,7 @@ pub struct PayoutAttempt {pub connector_eligibility_reference_id: Option<String>,pub connector_request_reference_id: Option<String>,pub active_frm_id: Option<String>,+ pub execution_kind: Option<storage_enums::PayoutExecutionKind>,}#[derive(@@ -94,6 +95,7 @@ pub struct PayoutAttemptNew {pub connector_eligibility_reference_id: Option<String>,pub connector_request_reference_id: Option<String>,pub active_frm_id: Option<String>,+ pub execution_kind: Option<storage_enums::PayoutExecutionKind>,}#[derive(Debug, Clone, Serialize, Deserialize)]diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex a6ccf7104d..d04da3b748 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -1549,6 +1549,7 @@ diesel::table! {connector_request_reference_id -> Nullable<Varchar>,#[max_length = 64]active_frm_id -> Nullable<Varchar>,+ execution_kind -> Nullable<Text>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 958980f4bf..7ea24c309a 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -1468,6 +1468,7 @@ diesel::table! {connector_request_reference_id -> Nullable<Varchar>,#[max_length = 64]active_frm_id -> Nullable<Varchar>,+ execution_kind -> Nullable<Text>,}}diff --git a/crates/hyperswitch_domain_models/src/payouts.rs b/crates/hyperswitch_domain_models/src/payouts.rsindex adf463f9d8..cd5fa8a040 100644--- a/crates/hyperswitch_domain_models/src/payouts.rs+++ b/crates/hyperswitch_domain_models/src/payouts.rs@@ -1,6 +1,7 @@pub mod payout_attempt;#[allow(clippy::module_inception)]pub mod payouts;+pub mod proxy;use common_enums as storage_enums;use common_utils::{diff --git a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rsindex b0283acf90..a18fd1941b 100644--- a/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payouts/payout_attempt.rs@@ -115,6 +115,7 @@ pub struct PayoutAttempt {pub connector_eligibility_reference_id: Option<String>,pub connector_request_reference_id: Option<String>,pub active_frm_id: Option<String>,+ pub execution_kind: storage_enums::PayoutExecutionKind,}impl PayoutAttempt {@@ -173,6 +174,7 @@ pub struct PayoutAttemptNew {pub connector_eligibility_reference_id: Option<String>,pub connector_request_reference_id: Option<String>,pub active_frm_id: Option<String>,+ pub execution_kind: storage_enums::PayoutExecutionKind,}#[derive(Debug, Clone)]diff --git a/crates/hyperswitch_domain_models/src/payouts/proxy.rs b/crates/hyperswitch_domain_models/src/payouts/proxy.rsnew file mode 100644index 0000000000..0a910df611--- /dev/null+++ b/crates/hyperswitch_domain_models/src/payouts/proxy.rs@@ -0,0 +1,16 @@+//! Request-scoped vault tokens; never persist them in payout records.++#[derive(Clone, Debug)]+pub enum ExternalVaultPayoutMethodData {+ Card(Box<ExternalVaultPayoutCardData>),+}++/// Opaque vault tokens bypass PAN validation and local detokenization.+#[derive(Clone, Debug)]+pub struct ExternalVaultPayoutCardData {+ pub card_number: hyperswitch_masking::Secret<String>,+ pub expiry_month: hyperswitch_masking::Secret<String>,+ pub expiry_year: hyperswitch_masking::Secret<String>,+ pub card_holder_name: Option<hyperswitch_masking::Secret<String>>,+ pub card_network: Option<common_enums::CardNetwork>,+}diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 077aa3b8a1..fc322884b5 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -23,6 +23,8 @@ use serde_with::serde_as;use self::merchant_connector_webhook_management::ConnectorWebhookRegisterRequest;use super::payment_method_data::PaymentMethodData;+#[cfg(feature = "payouts")]+use crate::payouts;use crate::{address,errors::api_error_response::{ApiErrorResponse, NotImplementedMessage},@@ -1705,6 +1707,9 @@ pub struct PayoutsData {pub source_bank_data: Option<api_models::payouts::BankTransfer>,pub billing_descriptor: Option<common_types::payouts::PayoutsBillingDescriptor>,pub connector_eligibility_reference_id: Option<String>,+ /// Exclude replayable vault tokens from serialized router comparisons.+ #[serde(skip)]+ pub external_vault_pmd: Option<payouts::proxy::ExternalVaultPayoutMethodData>,}#[derive(Debug, Default, Clone, Serialize)]diff --git a/crates/openapi/src/routes/payouts.rs b/crates/openapi/src/routes/payouts.rsindex 3f085592ef..e5a5b6ea25 100644--- a/crates/openapi/src/routes/payouts.rs+++ b/crates/openapi/src/routes/payouts.rs@@ -2,10 +2,39 @@#[utoipa::path(post,path = "/payouts/create",- request_body=PayoutsCreateRequest,+ request_body(+ content = PayoutsCreateRequest,+ examples(+ (+ "Normal payout" = (+ value = json!({"amount": 1000, "currency": "USD"})+ )+ ),+ (+ "External vault proxy payout (not yet implemented)" = (+ value = json!({+ "payout_id": "payout_proxy_merchant_1001",+ "merchant_order_reference_id": "merchant_payout_1001",+ "amount": 1000,+ "currency": "USD",+ "customer_id": "cus_external_vault_123",+ "payout_method_id": "pm_external_vault_123",+ "profile_id": "pro_external_vault_123",+ "confirm": true,+ "auto_fulfill": true,+ "payout_type": "card",+ "recurring": false,+ "entity_type": "Individual",+ "connector": ["cybersource"]+ })+ )+ )+ )+ ),responses((status = 200, description = "Payout created", body = PayoutCreateResponse),- (status = 400, description = "Missing Mandatory fields")+ (status = 400, description = "Missing mandatory fields or invalid request"),+ (status = 501, description = "External-vault proxy payout execution is not implemented yet")),tag = "Payouts",operation_id = "Create a Payout",diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rsindex ebde064573..65aae309f2 100644--- a/crates/router/src/core/payouts.rs+++ b/crates/router/src/core/payouts.rs@@ -5,6 +5,8 @@ pub mod gateway;#[cfg(feature = "v1")]pub mod guards;pub mod helpers;+#[cfg(feature = "v1")]+pub mod proxy;#[cfg(feature = "payout_retry")]pub mod retry;pub mod transformers;@@ -3622,6 +3624,7 @@ pub async fn payout_create_db_entries(additional_source_bank_data,connector_request_reference_id: None,active_frm_id: None,+ execution_kind: storage_enums::PayoutExecutionKind::Normal,};let payout_attempt = db.insert_payout_attempt(diff --git a/crates/router/src/core/payouts/proxy.rs b/crates/router/src/core/payouts/proxy.rsnew file mode 100644index 0000000000..d4d6374b3b--- /dev/null+++ b/crates/router/src/core/payouts/proxy.rs@@ -0,0 +1,11 @@+use crate::core::payments::helpers;++/// Provider-profile vault configuration, separate from payout connector credentials and tokens.+#[derive(Clone, Debug, Default)]+pub enum PayoutExecutionContext {+ #[default]+ Normal,+ ExternalVaultProxy {+ external_vault_mca: helpers::MerchantConnectorAccountType,+ },+}diff --git a/crates/router/src/core/payouts/retry.rs b/crates/router/src/core/payouts/retry.rsindex e94359b847..3130fd8e56 100644--- a/crates/router/src/core/payouts/retry.rs+++ b/crates/router/src/core/payouts/retry.rs@@ -302,6 +302,7 @@ pub async fn modify_trackers(.clone(),connector_request_reference_id: None,active_frm_id: payout_data.payout_attempt.active_frm_id.clone(),+ execution_kind: payout_data.payout_attempt.execution_kind,};payout_data.payout_attempt = db.insert_payout_attempt(diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex 4c3b2b7b1b..993ffe034d 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -328,6 +328,7 @@ pub async fn construct_payout_router_data<'a, F>(additional_payout_method_data: payout_attempt.additional_payout_method_data.to_owned(),source_bank_data: payout_data.source_bank_data.clone(),billing_descriptor: payouts.billing_descriptor.clone(),+ external_vault_pmd: None,},response: Ok(types::PayoutsResponseData::default()),access_token: None,diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex 9869a807d3..526c18b605 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -487,6 +487,7 @@ pub trait ConnectorActions: Connector {additional_payout_method_data: None,source_bank_data: None,billing_descriptor: None,+ external_vault_pmd: None,},payment_info,)diff --git a/crates/storage_impl/src/payouts/payout_attempt.rs b/crates/storage_impl/src/payouts/payout_attempt.rsindex 750adca621..b7434997c0 100644--- a/crates/storage_impl/src/payouts/payout_attempt.rs+++ b/crates/storage_impl/src/payouts/payout_attempt.rs@@ -104,6 +104,7 @@ impl<T: DatabaseStore> PayoutAttemptInterface for KVRouterStore<T> {.connector_request_reference_id.clone(),active_frm_id: new_payout_attempt.active_frm_id.clone(),+ execution_kind: new_payout_attempt.execution_kind,};let field = format!("poa_{}", created_attempt.payout_attempt_id);@@ -709,6 +710,7 @@ impl DataModelExt for PayoutAttempt {connector_eligibility_reference_id: self.connector_eligibility_reference_id,connector_request_reference_id: self.connector_request_reference_id,active_frm_id: self.active_frm_id,+ execution_kind: Some(self.execution_kind),}}@@ -747,6 +749,7 @@ impl DataModelExt for PayoutAttempt {connector_eligibility_reference_id: storage_model.connector_eligibility_reference_id,connector_request_reference_id: storage_model.connector_request_reference_id,active_frm_id: storage_model.active_frm_id,+ execution_kind: storage_model.execution_kind.unwrap_or_default(),}}}@@ -786,6 +789,7 @@ impl DataModelExt for PayoutAttemptNew {connector_eligibility_reference_id: self.connector_eligibility_reference_id,connector_request_reference_id: self.connector_request_reference_id,active_frm_id: self.active_frm_id,+ execution_kind: Some(self.execution_kind),}}@@ -824,6 +828,7 @@ impl DataModelExt for PayoutAttemptNew {connector_eligibility_reference_id: storage_model.connector_eligibility_reference_id,connector_request_reference_id: storage_model.connector_request_reference_id,active_frm_id: storage_model.active_frm_id,+ execution_kind: storage_model.execution_kind.unwrap_or_default(),}}}diff --git a/migrations/2026-10-04-100000_add_payout_execution_kind/down.sql b/migrations/2026-10-04-100000_add_payout_execution_kind/down.sqlnew file mode 100644index 0000000000..4b8abc62bf--- /dev/null+++ b/migrations/2026-10-04-100000_add_payout_execution_kind/down.sql@@ -0,0 +1,2 @@+-- Drain column-dependent code and reconcile proxy attempts before rollback.+ALTER TABLE payout_attempt DROP COLUMN execution_kind;diff --git a/migrations/2026-10-04-100000_add_payout_execution_kind/up.sql b/migrations/2026-10-04-100000_add_payout_execution_kind/up.sqlnew file mode 100644index 0000000000..f74f1d2d45--- /dev/null+++ b/migrations/2026-10-04-100000_add_payout_execution_kind/up.sql@@ -0,0 +1,3 @@+-- Apply before deploying code that reads or writes execution_kind.+ALTER TABLE payout_attempt+ ADD COLUMN execution_kind TEXT;