Skip to content

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

docs(revenue_recovery): document the recovery outgoing webhook (#15276)

CHALLA NISHANTH BABU3b9eaa65d13b
diff --git a/api-reference/docs.json b/api-reference/docs.json
index b0c8562438..8fd231811f 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -518,7 +518,8 @@
"group": "Revenue Recovery",
"pages": [
"v2/revenue-recovery/revenue-recovery--create",
- "v2/revenue-recovery/revenue-recovery--cancel"
+ "v2/revenue-recovery/revenue-recovery--cancel",
+ "v2/revenue-recovery/revenue-recovery--webhook"
]
}
]
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index a68bd38cd0..e5879af259 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -4945,7 +4945,7 @@
"$ref": "#/components/schemas/RecoveryPaymentsCreate"
},
"examples": {
- "Record a failed transaction and schedule a retry": {
+ "Fully Managed Recovery": {
"value": {
"amount_details": {
"currency": "USD",
@@ -4995,7 +4995,7 @@
"transaction_status": "failure"
}
},
- "Record a failed transaction on a profile with external triggers": {
+ "Schedule Only Recovery": {
"value": {
"amount_details": {
"currency": "USD",
@@ -5055,22 +5055,34 @@
},
"responses": {
"200": {
- "description": "Revenue Recovery Transaction Recorded Successfully",
+ "description": "The transaction is recorded (Fully Managed Recovery), or accepted to be recorded right after the answer (Schedule Only Recovery)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RecoveryPaymentsCreateResponse"
},
- "example": {
- "id": "12_pay_01a3868d94a471219b5c4bc71638e2zc",
- "intent_status": "failed",
- "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh"
+ "examples": {
+ "Fully Managed Recovery": {
+ "summary": "Fully Managed Recovery",
+ "value": {
+ "id": "12_pay_01a3868d94a471219b5c4bc71638e2zc",
+ "intent_status": "failed",
+ "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh"
+ }
+ },
+ "Schedule Only Recovery": {
+ "summary": "Schedule Only Recovery",
+ "value": {
+ "connector_transaction_id": "993672945374576J",
+ "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh"
+ }
+ }
}
}
}
},
"400": {
- "description": "Missing or invalid mandatory fields, or, on `internal_triggers`, the invoice takes no more transactions",
+ "description": "Missing or invalid mandatory fields, or, under Fully Managed Recovery, the invoice takes no more transactions",
"content": {
"application/json": {
"schema": {
@@ -32240,7 +32252,12 @@
"enum": [
"adyen",
"stripe",
- "paypal"
+ "paypal",
+ "shift4",
+ "dlocal",
+ "worldpay",
+ "cybersource",
+ "razorpay"
]
},
"RecoveryNextRetry": {
@@ -32319,13 +32336,13 @@
},
"billing_merchant_connector_id": {
"type": "string",
- "description": "Unique identifier assigned by Hyperswitch for the custom billing connector account. The account must belong to the profile passed in the `X-Profile-Id` header. Required when the `revenue_recovery_trigger_model` of the profile is `internal_triggers`, and ignored when it is `external_triggers`.",
+ "description": "Unique identifier assigned by Hyperswitch for the custom billing connector account. The account must belong to the profile passed in the `X-Profile-Id` header. Required under Fully Managed Recovery (`revenue_recovery_trigger_model` is `internal_triggers`), and ignored under Schedule Only Recovery (`external_triggers`).",
"example": "mca_1234567890",
"nullable": true
},
"payment_merchant_connector_id": {
"type": "string",
- "description": "Unique identifier assigned by Hyperswitch for the payment connector account, such as Stripe, on which the transaction was processed. The account must belong to the profile passed in the `X-Profile-Id` header. Required when the `revenue_recovery_trigger_model` of the profile is `internal_triggers`, and ignored when it is `external_triggers`.",
+ "description": "Unique identifier assigned by Hyperswitch for the payment connector account, such as Stripe, on which the transaction was processed. The account must belong to the profile passed in the `X-Profile-Id` header. Required under Fully Managed Recovery (`revenue_recovery_trigger_model` is `internal_triggers`), and ignored under Schedule Only Recovery (`external_triggers`).",
"example": "mca_1234567890",
"nullable": true
},
@@ -32460,10 +32477,11 @@
"$ref": "#/components/schemas/RecoveryRequestAccepted"
}
],
- "description": "The answer to a reported transaction, which depends on the `revenue_recovery_trigger_model` of\nthe profile."
+ "description": "The answer to a reported transaction, which depends on whether the profile uses Fully Managed\nRecovery or Schedule Only Recovery."
},
"RecoveryPaymentsResponse": {
"type": "object",
+ "title": "Fully Managed Recovery",
"required": [
"id",
"intent_status"
@@ -32496,7 +32514,8 @@
},
"RecoveryRequestAccepted": {
"type": "object",
- "description": "A transaction reported on a profile whose `revenue_recovery_trigger_model` is\n`external_triggers`, accepted to be recorded right after the answer.",
+ "title": "Schedule Only Recovery",
+ "description": "A transaction reported under Schedule Only Recovery (`revenue_recovery_trigger_model` is\n`external_triggers`), accepted to be recorded right after the answer.",
"required": [
"merchant_reference_id",
"connector_transaction_id"
@@ -32545,7 +32564,7 @@
}
}
],
- "description": "The next retry of an invoice whose retries the merchant triggers, sent by webhook after each\ntransaction the merchant reports."
+ "description": "The next retry of an invoice under Schedule Only Recovery, where the merchant triggers the\nretries, sent by webhook after each transaction the merchant reports."
},
"RecoveryTransactionStatus": {
"type": "string",
diff --git a/api-reference/v2/revenue-recovery/revenue-recovery--webhook.mdx b/api-reference/v2/revenue-recovery/revenue-recovery--webhook.mdx
new file mode 100644
index 0000000000..bebbfa4433
--- /dev/null
+++ b/api-reference/v2/revenue-recovery/revenue-recovery--webhook.mdx
@@ -0,0 +1,90 @@
+---
+title: "Outgoing Webhook"
+description: "The next retry of an invoice under Schedule Only Recovery, sent to the profile's webhook URL"
+---
+
+Under Schedule Only Recovery, when a transaction made outside Hyperswitch is reported to [`POST /v2/recovery`](/v2/revenue-recovery/revenue-recovery--create), Hyperswitch tells when to retry the invoice. After recording the transaction, it decides the invoice's next retry and sends it to the profile's webhook URL.
+
+A transaction that doesn't change the next retry sends no webhook: for example, one made with the customer present, or a charge that recovers the invoice.
+
+Each webhook has its own `event_id`, and the request is signed in the `X-Webhook-Signature-512` header, like every Hyperswitch outgoing webhook.
+
+## Webhook body
+
+<ResponseField name="merchant_id" type="string" required>
+ The provider merchant id (platform/business owner).
+</ResponseField>
+
+<ResponseField name="event_id" type="string" required>
+ The unique event id for each webhook.
+</ResponseField>
+
+<ResponseField name="event_type" type="string" required>
+ `recovery_retry_scheduled` or `recovery_limits_exhausted`.
+</ResponseField>
+
+<ResponseField name="content" type="object" required>
+ <Expandable title="properties" defaultOpen>
+ <ResponseField name="type" type="string" required>
+ Always `recovery_retry_details`.
+ </ResponseField>
+
+ <ResponseField name="object" type="object" required>
+ The next retry of the invoice. Every field is always present.
+
+ <Expandable title="properties" defaultOpen>
+ <ResponseField name="id" type="string" required>
+ Unique identifier of the invoice in Hyperswitch.
+ </ResponseField>
+
+ <ResponseField name="merchant_reference_id" type="string" required>
+ Unique identifier of the invoice in the merchant's billing system.
+ </ResponseField>
+
+ <ResponseField name="retry_count" type="integer" required>
+ Number of the next retry, counted the way the `max_retry_count` of the profile counts them: the first retry after the original payment is 1.
+ </ResponseField>
+
+ <ResponseField name="schedule_time" type="string | null" required>
+ The time to trigger the retry at, then report its result through the recovery API. `null` when no retry is scheduled.
+ </ResponseField>
+
+ <ResponseField name="reason" type="string | null" required>
+ Why no retry is scheduled: `retries_exhausted`, `grace_period_expired` or `hard_declined`. `null` when a retry is scheduled.
+ </ResponseField>
+ </Expandable>
+ </ResponseField>
+ </Expandable>
+</ResponseField>
+
+<ResponseField name="timestamp" type="string">
+ The time at which the webhook was sent.
+</ResponseField>
+
+<ResponseField name="processor_merchant_id" type="string | null">
+ The merchant id of the merchant account whose connector credentials are used for payment processing.
+</ResponseField>
+
+<RequestExample>
+
+```json Webhook body
+{
+ "merchant_id": "merchant_1234567890",
+ "event_id": "evt_01a1d62a41b17a208968368ec06459d7",
+ "event_type": "recovery_retry_scheduled",
+ "content": {
+ "type": "recovery_retry_details",
+ "object": {
+ "id": "12_pay_01a3868d94a471219b5c4bc71638e2zc",
+ "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh",
+ "retry_count": 1,
+ "schedule_time": "2026-11-13T21:31:24.979Z",
+ "reason": null
+ }
+ },
+ "timestamp": "2026-11-13T18:27:35.985Z",
+ "processor_merchant_id": "merchant_1234567890"
+}
+```
+
+</RequestExample>
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index c4d6766b8a..dca69239ef 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -2392,6 +2392,7 @@ pub struct PaymentAttemptRecordResponse {
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
+#[schema(title = "Fully Managed Recovery")]
pub struct RecoveryPaymentsResponse {
/// Unique identifier of the invoice in Hyperswitch against which the transaction has been recorded.
#[schema(
@@ -2417,10 +2418,11 @@ pub struct RecoveryPaymentsResponse {
pub merchant_reference_id: Option<id_type::PaymentReferenceId>,
}
-/// A transaction reported on a profile whose `revenue_recovery_trigger_model` is
-/// `external_triggers`, accepted to be recorded right after the answer.
+/// A transaction reported under Schedule Only Recovery (`revenue_recovery_trigger_model` is
+/// `external_triggers`), accepted to be recorded right after the answer.
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
+#[schema(title = "Schedule Only Recovery")]
pub struct RecoveryRequestAccepted {
/// Unique identifier of the invoice in the merchant's billing system against which the
/// transaction is being recorded.
@@ -2437,20 +2439,20 @@ pub struct RecoveryRequestAccepted {
pub connector_transaction_id: String,
}
-/// The answer to a reported transaction, which depends on the `revenue_recovery_trigger_model` of
-/// the profile.
+/// The answer to a reported transaction, which depends on whether the profile uses Fully Managed
+/// Recovery or Schedule Only Recovery.
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
#[serde(untagged)]
pub enum RecoveryPaymentsCreateResponse {
- /// On `internal_triggers`, the transaction is recorded before the answer.
+ /// Under Fully Managed Recovery, the transaction is recorded before the answer.
Recorded(RecoveryPaymentsResponse),
- /// On `external_triggers`, the transaction is recorded after the answer.
+ /// Under Schedule Only Recovery, the transaction is recorded after the answer.
Accepted(RecoveryRequestAccepted),
}
-/// The next retry of an invoice whose retries the merchant triggers, sent by webhook after each
-/// transaction the merchant reports.
+/// The next retry of an invoice under Schedule Only Recovery, where the merchant triggers the
+/// retries, sent by webhook after each transaction the merchant reports.
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, Clone, ToSchema)]
pub struct RecoveryRetryWebhookDetails {
@@ -14718,11 +14720,11 @@ pub struct RecoveryPaymentsCreate {
/// Error details of a failed transaction.
pub error: Option<ErrorDetails>,
- /// Unique identifier assigned by Hyperswitch for the custom billing connector account. The account must belong to the profile passed in the `X-Profile-Id` header. Required when the `revenue_recovery_trigger_model` of the profile is `internal_triggers`, and ignored when it is `external_triggers`.
+ /// Unique identifier assigned by Hyperswitch for the custom billing connector account. The account must belong to the profile passed in the `X-Profile-Id` header. Required under Fully Managed Recovery (`revenue_recovery_trigger_model` is `internal_triggers`), and ignored under Schedule Only Recovery (`external_triggers`).
#[schema(value_type = Option<String>, example = "mca_1234567890")]
pub billing_merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
- /// Unique identifier assigned by Hyperswitch for the payment connector account, such as Stripe, on which the transaction was processed. The account must belong to the profile passed in the `X-Profile-Id` header. Required when the `revenue_recovery_trigger_model` of the profile is `internal_triggers`, and ignored when it is `external_triggers`.
+ /// Unique identifier assigned by Hyperswitch for the payment connector account, such as Stripe, on which the transaction was processed. The account must belong to the profile passed in the `X-Profile-Id` header. Required under Fully Managed Recovery (`revenue_recovery_trigger_model` is `internal_triggers`), and ignored under Schedule Only Recovery (`external_triggers`).
#[schema(value_type = Option<String>, example = "mca_1234567890")]
pub payment_merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
@@ -14734,7 +14736,7 @@ pub struct RecoveryPaymentsCreate {
#[schema(value_type = Option<String>, example = "payment_account_us")]
pub merchant_reference_payment_connector_id: Option<String>,
- /// Payment processor on which the transaction was processed. Required when the `revenue_recovery_trigger_model` of the profile is `external_triggers`, and ignored when it is `internal_triggers`, where the processor comes from `payment_merchant_connector_id`.
+ /// Payment processor on which the transaction was processed. Required under Schedule Only Recovery (`revenue_recovery_trigger_model` is `external_triggers`), and ignored under Fully Managed Recovery (`internal_triggers`), where the processor comes from `payment_merchant_connector_id`.
#[schema(value_type = Option<RecoveryConnector>, example = "stripe")]
pub connector: Option<common_payments_types::RecoveryConnector>,
diff --git a/crates/common_types/src/payments.rs b/crates/common_types/src/payments.rs
index 640e882bb3..c1748a37bc 100644
--- a/crates/common_types/src/payments.rs
+++ b/crates/common_types/src/payments.rs
@@ -1054,6 +1054,16 @@ pub enum RecoveryConnector {
Stripe,
/// PayPal.
Paypal,
+ /// Shift4.
+ Shift4,
+ /// dLocal.
+ Dlocal,
+ /// Worldpay.
+ Worldpay,
+ /// Cybersource.
+ Cybersource,
+ /// Razorpay.
+ Razorpay,
}
impl From<RecoveryConnector> for common_enums::connector_enums::Connector {
@@ -1062,6 +1072,11 @@ impl From<RecoveryConnector> for common_enums::connector_enums::Connector {
RecoveryConnector::Adyen => Self::Adyen,
RecoveryConnector::Stripe => Self::Stripe,
RecoveryConnector::Paypal => Self::Paypal,
+ RecoveryConnector::Shift4 => Self::Shift4,
+ RecoveryConnector::Dlocal => Self::Dlocal,
+ RecoveryConnector::Worldpay => Self::Worldpay,
+ RecoveryConnector::Cybersource => Self::Cybersource,
+ RecoveryConnector::Razorpay => Self::Razorpay,
}
}
}
diff --git a/crates/openapi/src/routes/revenue_recovery.rs b/crates/openapi/src/routes/revenue_recovery.rs
index fb4339a665..7a6e886b1f 100644
--- a/crates/openapi/src/routes/revenue_recovery.rs
+++ b/crates/openapi/src/routes/revenue_recovery.rs
@@ -39,7 +39,7 @@ pub async fn revenue_recovery_pt_retrieve_api() {}
content = RecoveryPaymentsCreate,
examples(
(
- "Record a failed transaction and schedule a retry" = (
+ "Fully Managed Recovery" = (
value = json!({
"amount_details": {
"order_amount": 6540,
@@ -91,7 +91,7 @@ pub async fn revenue_recovery_pt_retrieve_api() {}
)
),
(
- "Record a failed transaction on a profile with external triggers" = (
+ "Schedule Only Recovery" = (
value = json!({
"amount_details": {
"order_amount": 6540,
@@ -150,15 +150,31 @@ pub async fn revenue_recovery_pt_retrieve_api() {}
responses(
(
status = 200,
- description = "Revenue Recovery Transaction Recorded Successfully",
+ description = "The transaction is recorded (Fully Managed Recovery), or accepted to be recorded right after the answer (Schedule Only Recovery)",
body = RecoveryPaymentsCreateResponse,
- example = json!({
- "id": "12_pay_01a3868d94a471219b5c4bc71638e2zc",
- "intent_status": "failed",
- "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh"
- })
+ examples(
+ (
+ "Fully Managed Recovery" = (
+ summary = "Fully Managed Recovery",
+ value = json!({
+ "id": "12_pay_01a3868d94a471219b5c4bc71638e2zc",
+ "intent_status": "failed",
+ "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh"
+ })
+ )
+ ),
+ (
+ "Schedule Only Recovery" = (
+ summary = "Schedule Only Recovery",
+ value = json!({
+ "merchant_reference_id": "invoice_mbabizu24mvu3mela5njyh",
+ "connector_transaction_id": "993672945374576J"
+ })
+ )
+ ),
+ )
),
- (status = 400, description = "Missing or invalid mandatory fields, or, on `internal_triggers`, the invoice takes no more transactions", body = GenericErrorResponseOpenApi),
+ (status = 400, description = "Missing or invalid mandatory fields, or, under Fully Managed Recovery, the invoice takes no more transactions", body = GenericErrorResponseOpenApi),
(status = 404, description = "Resource missing"),
(status = 500, description = "Internal server error"),
),