Skip to content

fix(router): resolve notify connector comments#13122

Open
AkshayaFoiger wants to merge 3 commits into
mainfrom
address-comments
Open

fix(router): resolve notify connector comments#13122
AkshayaFoiger wants to merge 3 commits into
mainfrom
address-comments

Conversation

@AkshayaFoiger

@AkshayaFoiger AkshayaFoiger commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Type of Change

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

Description

Resolves unresolved comments on this PR juspay/hyperswitch-prism#1369

How did you test it?

The changes do not impact any flows.

Sanity Test

Create a payment

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_MjUfhmlfBgV9eCWaGUqj1oA54tgQpUnI5rxP6GtGWzBmbix1PvptFKIfQ6SXzX9p' \
--data-raw '{
    "amount": 10900,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "description": "vantiv payment",
    "customer_id": "George_1734",
    "email": "hello@123.com",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    
    
    
    
    
    
    
    
    
    "payment_method": "card",
    "payment_method_type": "debit",
    "payment_method_data": {
        "card": {
            "card_number": "4000000000000259",
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "card_cvc": "737"
        }
    },
    "browser_info": {
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
        "ip_address": "192.168.1.1",
        "java_enabled": false,
        "java_script_enabled": true,
        "language": "en-US",
        "color_depth": 24,
        "screen_height": 1080,
        "screen_width": 1920,
        "time_zone": 330,
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
    },
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "metadata": {
        "processing_account_id": "acct_3eoxafCHioIB3jNMKJev4" 
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "North Carolina South",
            "zip": "94122",
            "country": "US",
            "first_name": "박성준",
            "last_name": "박성준"
        }
    }
    
}'

Response

{
    "payment_id": "pay_BoJmCfmzmvLh5nVurJJJ",
    "merchant_id": "postman_merchant_GHAction_9a34682f-4075-4921-92fc-7bd4abf3db66",
    "status": "succeeded",
    "amount": 10900,
    "net_amount": 10900,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10900,
    "processor_merchant_id": "postman_merchant_GHAction_9a34682f-4075-4921-92fc-7bd4abf3db66",
    "initiator": null,
    "sdk_authorization": "cHJvZmlsZV9pZD1wcm9fbUJhM3l6RXluUXVhbUNWblBFbEwscHVibGlzaGFibGVfa2V5PXBrX2Rldl9mMzVmOTE0ZDQ0ZjM0ZDRjYjVhOThhNzMzMjE3ZTkwYixjbGllbnRfc2VjcmV0PXBheV9Cb0ptQ2Ztem12TGg1blZ1ckpKSl9zZWNyZXRfRk4xOURPR05CYmRBM2dVYm5GTWYsY3VzdG9tZXJfaWQ9R2VvcmdlXzE3MzQsY2xpZW50X3Nlc3Npb25faWQ9Y2xpZW50X3Nlc3NfS1FXeW5RWlJwak5aS1RqTjlrNGUscGF5bWVudF9pZD1wYXlfQm9KbUNmbXptdkxoNW5WdXJKSko=",
    "connector": "stripe",
    "state_metadata": null,
    "client_secret": "pay_BoJmCfmzmvLh5nVurJJJ_secret_FN19DOGNBbdA3gUbnFMf",
    "created": "2026-07-01T09:56:56.609Z",
    "modified_at": "2026-07-01T09:56:59.915Z",
    "connector_customer_id": "cus_Unwm2DCYTX7x04",
    "currency": "USD",
    "customer_id": "George_1734",
    "customer": {
        "id": "George_1734",
        "name": null,
        "email": "hello@123.com",
        "phone": null,
        "phone_country_code": null,
        "customer_document_details": null
    },
    "description": "vantiv payment",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "0259",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "400000",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "30",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null,
            "auth_code": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": null,
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "North Carolina South",
            "first_name": "박성준",
            "last_name": "박성준",
            "origin_zip": null
        },
        "phone": null,
        "email": null
    },
    "order_details": null,
    "email": "hello@123.com",
    "name": null,
    "phone": null,
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "error_details": null,
    "payment_experience": null,
    "payment_method_type": "debit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3ToKt3D5R7gDAGff1CNj1SoX",
    "frm_message": null,
    "metadata": {
        "processing_account_id": "acct_3eoxafCHioIB3jNMKJev4"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        },
        "braintree": null,
        "adyen": null,
        "peachpayments": null,
        "santander": null
    },
    "connector_response_metadata": null,
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "pix_additional_details": null,
        "boleto_additional_details": null,
        "pix_automatico_additional_details": null,
        "finix_additional_details": null
    },
    "reference_id": "pi_3ToKt3D5R7gDAGff1CNj1SoX",
    "payment_link": null,
    "profile_id": "pro_mBa3yzEynQuamCVnPElL",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_vsqS4uZhBsnnjiPItwf7",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2026-07-01T10:11:56.609Z",
    "fingerprint": null,
    "browser_info": {
        "language": "en-US",
        "time_zone": 330,
        "ip_address": "192.168.1.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
        "color_depth": 24,
        "java_enabled": false,
        "screen_width": 1920,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
        "screen_height": 1080,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": "548497118106811",
    "network_transaction_link_id": null,
    "payment_method_status": null,
    "updated": "2026-07-01T09:56:59.915Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": false,
    "extended_authorization_last_applied_at": null,
    "request_extended_authorization": null,
    "capture_before": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null,
    "enable_overcapture": null,
    "is_overcapture_enabled": false,
    "network_details": null,
    "is_stored_credential": null,
    "mit_category": null,
    "billing_descriptor": null,
    "tokenization": null,
    "partner_merchant_identifier_details": null,
    "payment_method_tokenization_details": null,
    "installment_options": null,
    "installment_data": null,
    "sender_payment_instrument_id": null
}
Screenshot 2026-07-01 at 3 27 16 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

@AkshayaFoiger AkshayaFoiger requested review from a team as code owners July 1, 2026 07:05
@semanticdiff-com

semanticdiff-com Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/workflows/outgoing_webhook_retry.rs  28% smaller
  crates/router/src/compatibility/stripe/webhooks.rs  0% smaller
  crates/router/src/core/webhooks/outgoing.rs  0% smaller

@AkshayaFoiger AkshayaFoiger self-assigned this Jul 1, 2026
@AkshayaFoiger AkshayaFoiger requested a review from a team as a code owner July 1, 2026 07:26
@XyneSpaces

Copy link
Copy Markdown

🔍 Feature gate removal verification

The removal of #[cfg(feature = "v1")] from surcharge webhook functions and traits in outgoing.rs appears intentional to enable this functionality in both v1 and v2 builds. Please confirm:

  1. These functions don't have v2-specific alternatives in outgoing_v2.rs that would conflict
  2. The outgoing_v2.rs file doesn't need corresponding surcharge webhook support added
  3. This change has been tested with both v1 and v2 feature flags enabled

This is a non-blocking verification request given the cross-feature nature of the change.

@XyneSpaces

Copy link
Copy Markdown

🚨 Feature gate removal from surcharge webhook handling

This PR removes 8 instances of #[cfg(feature = "v1")] guards from surcharge-related webhook code. This change appears to enable surcharge webhooks for v2 flows.

Blocking concern: Please confirm that:

  1. Surcharge webhook handling has been validated to work correctly in v2 flows
  2. The v2 data model (provider_profile.surcharge_connector_details) is compatible with the functions being ungated
  3. This change is intentional and not an accidental over-removal of feature gates

The PR title says "resolve notify connector comments" but the change has significant flow implications beyond code organization.

Comment on lines +292 to +293
api_models::enums::EventType::SurchargePaymentSucceeded => "surcharge_payment.succeeded",
api_models::enums::EventType::SurchargeRefundSucceeded => "surcharge_refund.succeeded",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Event types that are not supported by Stripe are listed below the comment and are handled without throwing an error.

@AkshayaFoiger

Copy link
Copy Markdown
Contributor Author

🚨 Feature gate removal from surcharge webhook handling

This PR removes 8 instances of #[cfg(feature = "v1")] guards from surcharge-related webhook code. This change appears to enable surcharge webhooks for v2 flows.

Blocking concern: Please confirm that:

  1. Surcharge webhook handling has been validated to work correctly in v2 flows
  2. The v2 data model (provider_profile.surcharge_connector_details) is compatible with the functions being ungated
  3. This change is intentional and not an accidental over-removal of feature gates

The PR title says "resolve notify connector comments" but the change has significant flow implications beyond code organization.

Incase of v2, create_event_and_trigger_outgoing_webhook() of v2 will be called from outgoing_v2.rs

@XyneSpaces

Copy link
Copy Markdown

⚠️ Feature flag removal requires careful review

The PR removes 8 #[cfg(feature = "v1")] attributes from surcharge webhook code. This change makes the code available in all feature configurations.

Question: Has this code been tested in v2 mode to ensure it doesn't break v2 builds or cause runtime issues? The v2 payment path may have different assumptions about webhook handling.

@XyneSpaces

Copy link
Copy Markdown

📝 Review Summary

This PR adds a refund_response table for analytics purposes.

✅ Positive observations:

  1. Proper analytics pattern: Following the existing analytics table structure
  2. Consistent with codebase: Uses AnalyticsDataSource trait pattern
  3. Clean implementation: Proper QueryBuilder generic implementation

💡 Suggestions:

  1. Consider adding a unique index on (merchant_id, refund_id) for efficient lookups
  2. Verify that the retention policy for this table aligns with other analytics tables

No blocking issues found.


This is an automated review.

@XyneSpaces

Copy link
Copy Markdown

Review Findings

🚨 [blocking] V1 Feature Guard Removal

Removing #[cfg(feature = "v1")] from V1-specific types breaks v2-only builds. The following locations need restoration of feature guards:

  • outgoing.rs:66-72 - get_surcharge_webhook_event function call
  • outgoing.rs:100 - get_surcharge_webhook_event function definition
  • outgoing.rs:1477 - OutgoingWebhookResponseHandlerV1 trait definition
  • outgoing.rs:1509 - OutgoingWebhookResponseHandlerV1 impl for WebhookDeliveryAttempt
  • outgoing.rs:1598 - WebhookNotificationHandlerV1 trait definition
  • outgoing.rs:1619 - WebhookNotificationHandlerV1 impl for InitialAttempt
  • outgoing.rs:1664 - WebhookNotificationHandlerV1 impl for AutomaticRetry
  • outgoing.rs:1718 - WebhookNotificationHandlerV1 impl for ManualRetry

These *V1 types are intentionally V1-only. Removing their feature gates causes compilation failures in v2-only builds.

Fix: Restore all 8 #[cfg(feature = "v1")] attributes.

⚠️ Event Type Placement

Moving surcharge events above the Stripe documentation comment may incorrectly categorize them as Stripe-native event types. Please verify these event types are actually in Stripe's official event list; if not, maintain placement below the comment.


This is an automated review. Please address the blocking issue before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants