Skip to content

refactor(core): add webhook_url for v2 tunnel#9625

Merged
likhinbopanna merged 4 commits intomainfrom
tunnel-webhook-url
Oct 8, 2025
Merged

refactor(core): add webhook_url for v2 tunnel#9625
likhinbopanna merged 4 commits intomainfrom
tunnel-webhook-url

Conversation

@Aishwariyaa-Anand
Copy link
Contributor

@Aishwariyaa-Anand Aishwariyaa-Anand commented Sep 30, 2025

Type of Change

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

Description

This PR adds support for webhook_url in v2 PaymentsRequest. It allows merchants to pass their own webhook URL instead of creating one in Hyperswitch. This change is applicable only to v2 tunnel flow.

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?

Tested Phonepe through UCS
Payment Create

curl --location 'http://localhost:8080/v2/payments' \
--header 'Content-Type: application/json' \
--header 'x-profile-id: pro_zjXchnTKtjXfUfQ9FJEL' \
--header 'X-Merchant-Id: cloth_seller_Zoo9KadtslxR8ICC7dB6' \
--header 'x-tenant-id: public' \
--data-raw '{
    "amount_details": {
        "order_amount": 100,
        "currency": "INR"
    },
    "merchant_connector_details": {
        "connector_name": "phonepe",
        "merchant_connector_creds": {
            "auth_type": "SignatureKey",
            "api_key": "_",
            "key1": "_",
            "api_secret": "_"
        }
    },
    "return_url": "https://api-ns2.juspay.in/v2/pay/response/irctc",
    "merchant_reference_id": "phonepeirctc1759229122",
    "capture_method":"automatic",
    "payment_method_data": {
        "upi": {
            "upi_collect": {
                "vpa_id": "success@razorpay"
            }
        },
        "billing": {
            "address": {
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "city": "San Fransico",
                "state": "California",
                "zip": "94122",
                "country": "IN",
                "first_name": "Swangi",
                "last_name": "Kumari"
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "swangi.kumari@juspay.in"
        }
    },
    "browser_info": {
        "user_agent": "Dalvik/2.1.0",
        "referer": "abcd.com",
        "ip_address": "157.51.3.204"
    },
    "payment_method_subtype": "upi_collect",
    "payment_method_type": "upi",
    "return_raw_connector_response": true,
    "webhook_url": "https://v2/pay/response/irctc"
}'

Response

{
    "id": "12345_pay_01999962cf7d7e03b33e9ec92da6330c",
    "status": "requires_customer_action",
    "amount": {
        "order_amount": 100,
        "currency": "INR",
        "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": 0,
        "amount_captured": null
    },
    "customer_id": null,
    "connector": "phonepe",
    "created": "2025-09-30T06:50:13.764Z",
    "modified_at": "2025-09-30T06:50:15.068Z",
    "payment_method_data": {
        "billing": {
            "address": {
                "city": "San Fransico",
                "country": "IN",
                "line1": "1467",
                "line2": "Harrison Street",
                "line3": "Harrison Street",
                "zip": "94122",
                "state": "California",
                "first_name": "Swangi",
                "last_name": "Kumari",
                "origin_zip": null
            },
            "phone": {
                "number": "8056594427",
                "country_code": "+91"
            },
            "email": "swangi.kumari@juspay.in"
        }
    },
    "payment_method_type": "upi",
    "payment_method_subtype": "upi_collect",
    "connector_transaction_id": "OMO2509301220148555398840",
    "connector_reference_id": "phonepeirctc1759215013",
    "merchant_connector_id": null,
    "browser_info": null,
    "error": null,
    "shipping": null,
    "billing": null,
    "attempts": null,
    "connector_token_details": null,
    "payment_method_id": null,
    "next_action": null,
    "return_url": "https://api-ns2.juspay.in/v2/pay/response/irctc",
    "authentication_type": null,
    "authentication_type_applied": "no_three_ds",
    "is_iframe_redirection_enabled": null,
    "merchant_reference_id": "phonepeirctc1759215013",
    "raw_connector_response": "{\"success\":true,\"code\":\"PAYMENT_INITIATED\",\"message\":\"Payment initiated\",\"data\":{\"merchantId\":\"JUSPAONLINE\",\"merchantTransactionId\":\"phonepeirctc1759215013\",\"transactionId\":\"OMO2509301220148555398840\",\"instrumentResponse\":{\"type\":\"UPI_COLLECT\"}}}",
    "feature_metadata": null,
    "metadata": null
}

Verify webhook url in UCS logs
image

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

@Aishwariyaa-Anand Aishwariyaa-Anand self-assigned this Sep 30, 2025
@Aishwariyaa-Anand Aishwariyaa-Anand requested a review from a team as a code owner September 30, 2025 10:48
@semanticdiff-com
Copy link

semanticdiff-com bot commented Sep 30, 2025

@Aishwariyaa-Anand Aishwariyaa-Anand linked an issue Sep 30, 2025 that may be closed by this pull request
@Aishwariyaa-Anand Aishwariyaa-Anand added A-core Area: Core flows api-v2 labels Sep 30, 2025
@Aishwariyaa-Anand Aishwariyaa-Anand requested review from a team as code owners October 1, 2025 10:49
@Aishwariyaa-Anand Aishwariyaa-Anand added the M-api-contract-changes Metadata: This PR involves API contract changes label Oct 1, 2025
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
pub external_vault_pmd: Option<payment_method_data::ExternalVaultPaymentMethodData>,
/// The webhook url of the merchant, to which the connector will send the webhook.
pub webhook_url: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make the change of modifying the type here and RouterData as well in a separate PR, please create an issue for it

@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 8, 2025
Merged via the queue into main with commit df51a4f Oct 8, 2025
21 of 25 checks passed
@likhinbopanna likhinbopanna deleted the tunnel-webhook-url branch October 8, 2025 15:25
aadityaguptaa pushed a commit that referenced this pull request Nov 10, 2025
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: Core flows api-v2 M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] add webhook_url for v2 tunnel

5 participants