Skip to content

Conversation

aniketburman014
Copy link
Contributor

@aniketburman014 aniketburman014 commented Apr 9, 2025

Type of Change

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

Description

This PR adds support for configuring revenue recovery retry algorithms at the business level. When a new billing connector is created, the columns are updated with Monitoring as the default algorithm type and the current timestamp. It introduces two new columns in the business_profile table:


revenue_recovery_retry_algorithm_type (enum)

Specifies the retry algorithm type to be used for revenue recovery. This value will be used to determine the retry strategy for a transaction and will be included in the tracking data for the process tracker.

Supported values:

  • Cascading – Exponential retry strategy that increases the interval between retries after each attempt.
  • Smart – Data-driven retry approach that adapts dynamically based on historical performance and success rates.
  • Monitoring (default) – Passive mode with no active retries; used to observe behavior without influencing outcomes.

revenue_recovery_retry_algorithm_data (JSON)

A serde_json column to store additional data for the configured algorithm.

In Monitoring mode, it includes:

{
  "timestamp": "2025-04-15T10:30:00Z"
}

Additional Changes

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

Motivation and Context

How did you test it?

Curl

curl --location 'http://localhost:8080/v2/profiles' \
--header 'x-merchant-id: cloth_seller_163hj0DHc6ZpApzDPxhk' \
--header 'Authorization: admin-api-key=test_admin' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "profile_name": "business4",
    "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
}'

revenue_recovery_retry_algorithm_type and revenue_recovery_retry_algorithm_data columns added in business_profile table.
Screenshot 2025-04-22 at 11 20 45 AM

Curl 2

When a new billing processor is created, the revenue_recovery_retry_algorithm_type and revenue_recovery_retry_algorithm_data columns in the business_profile table are updated to Monitoring and the current timestamp by default.

curl --location 'http://localhost:8080/v2/connector-accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-merchant-id: cloth_seller_upLI6BmuDD2B9Vm3rqXO' \
--header 'x-profile-id: pro_0whZPSu2KxnSJRLvCg6F' \
--header 'Authorization: admin-api-key=test_admin' \
--header 'api-key: test_admin' \
--data '{
    "connector_type": "billing_processor",
    "connector_name": "recurly",
    "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
                }
            ]
        }
    ],
    "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"
    },
    "feature_metadata": {
        "revenue_recovery":{
            "max_retry_count": 16,
            "billing_connector_retry_threshold":10,
            "billing_account_reference":{
                "mca_0nVCxY1ZpTSPmvcCNt1j": "recurly"
            }


        }
    },
    "frm_configs": null,
    "connector_webhook_details": {
        "merchant_secret": "3d8feef681477c19d1d58d0df134ea40490f39763e678e4d8e561e9a5ba3d264"
    },
    "profile_id": "pro_0whZPSu2KxnSJRLvCg6F"
}'
Screenshot 2025-04-22 at 4 06 47 PM

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

@aniketburman014 aniketburman014 requested review from a team as code owners April 9, 2025 09:31
Copy link

semanticdiff-com bot commented Apr 9, 2025

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Apr 9, 2025
@aniketburman014 aniketburman014 changed the title Add Recovery_retry_algorithm_type in business_profile feat(router): add revenue_retry_algorithm_type in business_profile Apr 9, 2025
@aniketburman014 aniketburman014 changed the title feat(router): add revenue_retry_algorithm_type in business_profile feat(router): add revenue_recovery_retry_algorithm_type and revenue_recovery_retry_algorithm_table in business_profile table Apr 15, 2025
@aniketburman014 aniketburman014 changed the title feat(router): add revenue_recovery_retry_algorithm_type and revenue_recovery_retry_algorithm_table in business_profile table feat(router): Add revenue recovery retry algorithm type and data columns to business_profile Apr 15, 2025
@aniketburman014 aniketburman014 self-assigned this Apr 15, 2025
Aprabhat19
Aprabhat19 previously approved these changes Apr 15, 2025
ShankarSinghC
ShankarSinghC previously approved these changes Apr 17, 2025
@aniketburman014 aniketburman014 changed the title feat(router): Add revenue recovery retry algorithm type and data columns to business_profile feat(router): Add revenue recovery retry algorithm type and data columns to business_profile table Apr 17, 2025
@likhinbopanna likhinbopanna added this pull request to the merge queue Apr 24, 2025
Merged via the queue into main with commit c633b33 Apr 24, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the add_retry_enum_in_business_profile branch April 24, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants