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

feat(revenue_recovery): rework recovery api docs and remove customer_present from the request (#15026)

CHALLA NISHANTH BABU885d5b2452f1
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 1915e8ec39..a5e7e1bf5c 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -4872,7 +4872,7 @@
"Revenue Recovery"
],
"summary": "Revenue Recovery - Create",
- "description": "Record a transaction made outside of Hyperswitch against a billing connector invoice.\nThe transaction is synced with the payment connector and is then handled based on the\nstatus it reports, for example by scheduling a retry for a failed payment or recording an\nexternally successful payment. The reported `transaction_status` is used when the\nconnector cannot be synced.",
+ "description": "Record a transaction made outside of Hyperswitch against a billing connector invoice.",
"operationId": "Create a Revenue Recovery Payment",
"parameters": [
{
@@ -14147,7 +14147,7 @@
"properties": {
"primary_processor_payment_method_token": {
"type": "string",
- "description": "Primary payment method token at payment processor end.",
+ "description": "Primary payment method token at payment processor end, i.e. the connector token or connector mandate id.",
"example": "token_1234"
},
"payment_method_metadata": {
@@ -31500,7 +31500,7 @@
},
"merchant_reference_id": {
"type": "string",
- "description": "Unique identifier of the invoice in the merchant's billing system against which the\ntransaction is being recorded.",
+ "description": "Unique identifier of the invoice in the merchant's billing system against which the transaction is being recorded.",
"example": "invoice_mbabizu24mvu3mela5njyh",
"maxLength": 30,
"minLength": 30
@@ -31515,12 +31515,12 @@
},
"billing_merchant_connector_id": {
"type": "string",
- "description": "Unique identifier of the billing connector account, such as Chargebee, that manages the\ninvoice. The account must belong to the profile passed in the `X-Profile-Id` header.",
+ "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.",
"example": "mca_1234567890"
},
"payment_merchant_connector_id": {
"type": "string",
- "description": "Unique identifier of the payment connector account, such as Stripe, on which the\ntransaction was processed. The account must belong to the profile passed in the\n`X-Profile-Id` header.",
+ "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.",
"example": "mca_1234567890"
},
"transaction_status": {
@@ -31529,16 +31529,10 @@
"amount_captured": {
"type": "integer",
"format": "int64",
- "description": "Amount captured by the transaction, in the lowest denomination of the currency. It is\nrequired when `transaction_status` is `partial_charged`, where it must be greater than\nzero and less than the order amount. For `charged` it may be omitted, and if sent it\nmust equal the order amount. It must not be sent for a `failure`.",
+ "description": "Amount captured by the transaction, in the lowest denomination of the currency. It is required when `transaction_status` is `partial_charged`, where it must be greater than zero and less than the order amount. For `charged` it may be omitted, and if sent it must equal the order amount. It must not be sent for a `failure`.",
"example": 6540,
"nullable": true
},
- "customer_present": {
- "type": "boolean",
- "description": "Whether the customer was present, and so able to authenticate, when the transaction was\nmade. Defaults to `false`, which marks the transaction as merchant initiated.",
- "default": false,
- "example": false
- },
"mit_category": {
"allOf": [
{
@@ -31577,7 +31571,7 @@
},
"connector_customer_id": {
"type": "string",
- "description": "Unique identifier of the customer at the payment connector, with which the payment\nmethod token used for the transaction is associated.",
+ "description": "Unique identifier of the customer at the payment connector (connector customer id), with which the payment method token used for the transaction is associated.",
"example": "cust_12345"
},
"billing_started_at": {
@@ -31588,7 +31582,7 @@
},
"connector_transaction_id": {
"type": "string",
- "description": "Unique identifier of the transaction at the payment connector. It is used to identify\nthe transaction among the attempts recorded for the invoice.",
+ "description": "Unique identifier of the transaction at the payment connector (connector transaction id). It is used to identify the transaction among the attempts recorded for the invoice, and together with `merchant_reference_id` it has to be unique.",
"example": "993672945374576J"
},
"payment_method_data": {
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 1fa2bc47a7..e559764331 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -6557,7 +6557,7 @@ impl PaymentMethodDataResponseWithBilling {
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, ToSchema, serde::Serialize)]
pub struct CustomRecoveryPaymentMethodData {
- /// Primary payment method token at payment processor end.
+ /// Primary payment method token at payment processor end, i.e. the connector token or connector mandate id.
#[schema(value_type = String, example = "token_1234")]
pub primary_processor_payment_method_token: Secret<String>,
@@ -14806,8 +14806,7 @@ pub struct RecoveryPaymentsCreate {
/// The amount details for the payment
pub amount_details: AmountDetails,
- /// Unique identifier of the invoice in the merchant's billing system against which the
- /// transaction is being recorded.
+ /// Unique identifier of the invoice in the merchant's billing system against which the transaction is being recorded.
#[schema(
value_type = String,
min_length = 30,
@@ -14816,17 +14815,14 @@ pub struct RecoveryPaymentsCreate {
)]
pub merchant_reference_id: id_type::PaymentReferenceId,
- /// Error details for the payment if any
+ /// Error details of a failed transaction.
pub error: Option<ErrorDetails>,
- /// Unique identifier of the billing connector account, such as Chargebee, that manages the
- /// invoice. The account must belong to the profile passed in the `X-Profile-Id` header.
+ /// 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.
#[schema(value_type = String, example = "mca_1234567890")]
pub billing_merchant_connector_id: id_type::MerchantConnectorAccountId,
- /// Unique identifier of 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.
+ /// 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.
#[schema(value_type = String, example = "mca_1234567890")]
pub payment_merchant_connector_id: id_type::MerchantConnectorAccountId,
@@ -14834,21 +14830,11 @@ pub struct RecoveryPaymentsCreate {
#[schema(value_type = RecoveryTransactionStatus, example = "failure")]
pub transaction_status: common_payments_types::RecoveryTransactionStatus,
- /// Amount captured by the transaction, in the lowest denomination of the currency. It is
- /// required when `transaction_status` is `partial_charged`, where it must be greater than
- /// zero and less than the order amount. For `charged` it may be omitted, and if sent it
- /// must equal the order amount. It must not be sent for a `failure`.
+ /// Amount captured by the transaction, in the lowest denomination of the currency. It is required when `transaction_status` is `partial_charged`, where it must be greater than zero and less than the order amount. For `charged` it may be omitted, and if sent it must equal the order amount. It must not be sent for a `failure`.
#[schema(value_type = Option<i64>, example = 6540)]
pub amount_captured: Option<MinorUnit>,
- /// Whether the customer was present, and so able to authenticate, when the transaction was
- /// made. Defaults to `false`, which marks the transaction as merchant initiated.
- #[serde(default)]
- #[schema(default = false, example = false)]
- pub customer_present: bool,
-
- /// Category of the merchant initiated transactions made to recover this invoice. Defaults to
- /// `recurring`.
+ /// Category of the merchant initiated transactions made to recover this invoice. Defaults to `recurring`.
#[schema(value_type = Option<MitCategory>, example = "recurring")]
pub mit_category: Option<api_enums::MitCategory>,
@@ -14871,8 +14857,7 @@ pub struct RecoveryPaymentsCreate {
#[serde(with = "common_utils::custom_serde::iso8601")]
pub transaction_created_at: PrimitiveDateTime,
- /// Unique identifier of the customer at the payment connector, with which the payment
- /// method token used for the transaction is associated.
+ /// Unique identifier of the customer at the payment connector (connector customer id), with which the payment method token used for the transaction is associated.
#[schema(value_type = String, example = "cust_12345")]
pub connector_customer_id: Secret<String>,
@@ -14881,12 +14866,11 @@ pub struct RecoveryPaymentsCreate {
#[serde(with = "common_utils::custom_serde::iso8601")]
pub billing_started_at: PrimitiveDateTime,
- /// Unique identifier of the transaction at the payment connector. It is used to identify
- /// the transaction among the attempts recorded for the invoice.
+ /// Unique identifier of the transaction at the payment connector (connector transaction id). It is used to identify the transaction among the attempts recorded for the invoice, and together with `merchant_reference_id` it has to be unique.
#[schema(value_type = String, example = "993672945374576J")]
pub connector_transaction_id: String,
- /// payment method token units at payment processor end.
+ /// Payment method token and card details at the payment processor's end.
pub payment_method_data: CustomRecoveryPaymentMethodData,
/// Allow partial authorization for this payment
diff --git a/crates/openapi/src/routes/revenue_recovery.rs b/crates/openapi/src/routes/revenue_recovery.rs
index b6da1e22e6..1980956548 100644
--- a/crates/openapi/src/routes/revenue_recovery.rs
+++ b/crates/openapi/src/routes/revenue_recovery.rs
@@ -25,10 +25,6 @@ pub async fn revenue_recovery_pt_retrieve_api() {}
/// Revenue Recovery - Create
///
/// Record a transaction made outside of Hyperswitch against a billing connector invoice.
-/// The transaction is synced with the payment connector and is then handled based on the
-/// status it reports, for example by scheduling a retry for a failed payment or recording an
-/// externally successful payment. The reported `transaction_status` is used when the
-/// connector cannot be synced.
#[utoipa::path(
post,
path = "/v2/recovery",
diff --git a/crates/router/src/core/revenue_recovery/transformers.rs b/crates/router/src/core/revenue_recovery/transformers.rs
index 7eae09a121..7542248340 100644
--- a/crates/router/src/core/revenue_recovery/transformers.rs
+++ b/crates/router/src/core/revenue_recovery/transformers.rs
@@ -59,11 +59,8 @@ impl ForeignFrom<api_models::payments::RecoveryPaymentsCreate>
billing_started_at: Some(data.billing_started_at),
metadata: data.metadata,
enable_partial_authorization: data.enable_partial_authorization,
- customer_present: if data.customer_present {
- common_enums::PresenceOfCustomerDuringPayment::Present
- } else {
- common_enums::PresenceOfCustomerDuringPayment::Absent
- },
+ // Recovery retries are merchant initiated, so the customer is never present
+ customer_present: common_enums::PresenceOfCustomerDuringPayment::Absent,
// Defaults to recurring since recovery retries are merchant initiated transactions on a saved card for a recurring invoice
mit_category: Some(
data.mit_category