Skip to content

refactor(webhooks): default to triggering webhooks for all the states in payments, refunds and payouts flow#11028

Merged
likhinbopanna merged 6 commits into
mainfrom
11027-refactor-use-all-state-variants-as-default-webhook-status-lists-in-business-profile
Jan 28, 2026
Merged

refactor(webhooks): default to triggering webhooks for all the states in payments, refunds and payouts flow#11028
likhinbopanna merged 6 commits into
mainfrom
11027-refactor-use-all-state-variants-as-default-webhook-status-lists-in-business-profile

Conversation

@kashif-m

@kashif-m kashif-m commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Type of Change

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

Description

Updated business profile webhook status defaults to derive the fallback lists from the enum variants (IntentStatus, RefundStatus, PayoutStatus).

Additional Changes

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

Motivation and Context

Keeps default webhook trigger statuses in sync with their enums as new variants are added.

How did you test it?

Pre-requisites

  • Create a merchant account with empty payment_statuses_enabled, refund_statuses_enabled, payout_statuses_enabled

Pre-requisites

  • Create a merchant account with empty payment_statuses_enabled, refund_statuses_enabled, payout_statuses_enabled
Create a payment

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'x-cug-user: true' \
    --header 'api-key: dev_Ot8dGYccvZMGw390URGs3iZoIz7wkkfeqr2dKN60s8oIuzX0lpA4f5r21AjzzgE8' \
    --data-raw '{"amount":6500,"currency":"EUR","confirm":true,"capture_method":"automatic","capture_on":"2022-09-10T10:11:12Z","customer_id":"cus_E1FFR5t0Td7rCVUsHrOq","email":"guest@example.com","name":"John Doe","phone":"999999999","phone_country_code":"+65","description":"Its my first payment request","authentication_type":"three_ds","return_url":"https://hyperswitch.io","setup_future_usage":"off_session","customer_acceptance":{"acceptance_type":"online","accepted_at":"1963-05-03T04:07:52.723Z","online":{"ip_address":"127.0.0.1","user_agent":"amet irure esse"}},"connector":["adyen"],"payment_method":"card","payment_method_data":{"card":{"card_number":"4917 6100 0000 0000","card_exp_month":"03","card_exp_year":"2030","card_holder_name":"New Cust","card_cvc":"737"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"NL","first_name":"John"},"email":"guest@example.com"},"statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","metadata":{"udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","language":"en-US","color_depth":32,"screen_height":1117,"screen_width":1728,"time_zone":-330,"java_enabled":true,"java_script_enabled":true}}'

Response

{"payment_id":"pay_zBfqaLWHOLSbjMaOsaxm","merchant_id":"merchant_1769086763","status":"requires_customer_action","amount":6500,"net_amount":6500,"shipping_cost":null,"amount_capturable":6500,"amount_received":null,"processor_merchant_id":"merchant_1769086763","initiator":null,"connector":"adyen","client_secret":"pay_zBfqaLWHOLSbjMaOsaxm_secret_nUI21ld0SEVnINUM1Blj","created":"2026-01-22T12:59:35.455Z","modified_at":"2026-01-22T12:59:37.019Z","currency":"EUR","customer_id":"cus_E1FFR5t0Td7rCVUsHrOq","customer":{"id":"cus_E1FFR5t0Td7rCVUsHrOq","name":"John Doe","email":"guest@example.com","phone":"999999999","phone_country_code":"+65"},"description":"Its my first payment request","refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"automatic","payment_method":"card","payment_method_data":{"card":{"last4":"0000","card_type":"CREDIT","card_network":"Visa","card_issuer":"BANKPOLSKAKASAOPIEKIS.A.(BANKPEKAOSA)","card_issuing_country":"POLAND","card_isin":"491761","card_extended_bin":null,"card_exp_month":"03","card_exp_year":"2030","card_holder_name":"New Cust","payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"NL","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"John","last_name":null,"origin_zip":null},"phone":null,"email":"guest@example.com"},"order_details":null,"email":"guest@example.com","name":"John Doe","phone":"999999999","return_url":"https://hyperswitch.io/","authentication_type":"three_ds","statement_descriptor_name":"joseph","statement_descriptor_suffix":"JS","next_action":{"type":"redirect_to_url","redirect_to_url":"http://localhost:8080/payments/redirect/pay_zBfqaLWHOLSbjMaOsaxm/merchant_1769086763/pay_zBfqaLWHOLSbjMaOsaxm_1"},"cancellation_reason":null,"error_code":null,"error_message":null,"unified_code":null,"unified_message":null,"error_details":null,"payment_experience":null,"payment_method_type":"credit","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":"H4XCXRN982TBJWT5","frm_message":null,"metadata":{"udf1":"value1","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":null,"feature_metadata":{"redirect_response":null,"search_tags":null,"apple_pay_recurring_details":null,"gateway_system":"direct"},"reference_id":"H4XCXRN982TBJWT5","payment_link":null,"profile_id":"pro_4bFmAnt3jwGrRZc5AtKc","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_UCAvFcIDzZrKTIo6itUQ","incremental_authorization_allowed":false,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2026-01-22T13:14:35.455Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"129.0.0.1","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","color_depth":32,"java_enabled":true,"screen_width":1728,"accept_header":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8","screen_height":1117,"java_script_enabled":true},"payment_channel":null,"payment_method_id":"pm_8sE2Y4fGcpKSHAwQJxiN","network_transaction_id":null,"payment_method_status":"inactive","updated":"2026-01-22T12:59:37.019Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"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":null,"network_details":null,"is_stored_credential":null,"mit_category":null,"billing_descriptor":null,"tokenization":null,"partner_merchant_identifier_details":null,"payment_method_tokenization_details":{"payment_method_id":"pm_8sE2Y4fGcpKSHAwQJxiN","payment_method_status":"inactive","psp_tokenization":false,"network_tokenization":false,"network_transaction_id":null,"is_eligible_for_mit_payment":false}}

Outcome

  • Should've received a webhook
image
Create a payout

cURL

curl --location --request POST 'http://localhost:8080/payouts/create' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_Ot8dGYccvZMGw390URGs3iZoIz7wkkfeqr2dKN60s8oIuzX0lpA4f5r21AjzzgE8' \
    --data-raw '{"amount":10000000,"currency":"EUR","profile_id":"pro_4bFmAnt3jwGrRZc5AtKc","customer":{"id":"cus_E1FFR5t0Td7rCVUsHrOq","email":"new_cust@example.com","name":"John Doe","phone":"999999999","phone_country_code":"+65"},"connector":["adyen"],"description":"Its my first payout request","payout_type":"card","payout_method_data":{"card":{"card_number":"4111111111111111","expiry_month":"03","expiry_year":"2030","card_holder_name":"John Doe"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"CA","zip":"94122","country":"US","first_name":"John","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"}},"entity_type":"Individual","recurring":true,"metadata":{"ref":"123"},"confirm":true,"auto_fulfill":true}'

Response

{"payout_id":"payout_lNhO1fzAWrR6CQXUxC3D","merchant_id":"merchant_1769086763","merchant_order_reference_id":null,"amount":10000000,"currency":"EUR","connector":"adyen","payout_type":"card","payout_method_data":{"card":{"card_issuer":"JP Morgan","card_network":"Visa","card_type":"CREDIT","card_issuing_country":"INDIA","bank_code":"JP_JPM","last4":"1111","card_isin":"411111","card_extended_bin":null,"card_exp_month":"03","card_exp_year":"2030","card_holder_name":"John Doe"}},"billing":{"address":{"city":"San Fransico","country":"US","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"CA","first_name":"John","last_name":"Doe","origin_zip":null},"phone":{"number":"8056594427","country_code":"+91"},"email":null},"auto_fulfill":true,"customer_id":"cus_E1FFR5t0Td7rCVUsHrOq","customer":{"id":"cus_E1FFR5t0Td7rCVUsHrOq","name":"John Doe","email":"guest@example.com","phone":"999999999","phone_country_code":"+65"},"client_secret":"payout_payout_lNhO1fzAWrR6CQXUxC3D_secret_8UGYb5Xy4ldCuy23ohcK","return_url":null,"business_country":null,"business_label":null,"description":"Its my first payout request","entity_type":"Individual","recurring":true,"metadata":{"ref":"123"},"merchant_connector_id":"mca_vWSjFfMZyPr6iesEQI6K","status":"success","error_message":null,"error_code":null,"profile_id":"pro_4bFmAnt3jwGrRZc5AtKc","created":"2026-01-22T13:08:55.965Z","connector_transaction_id":"VFNQJXPK5P63RX75","priority":null,"payout_link":null,"email":"guest@example.com","name":"John Doe","phone":"999999999","phone_country_code":"+65","unified_code":null,"unified_message":null,"payout_method_id":"pm_D8TRQ1WmhVobGNKYU3py"}

Outcome

  • Should've received a webhook
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

@kashif-m kashif-m self-assigned this Jan 22, 2026
@kashif-m kashif-m requested a review from a team as a code owner January 22, 2026 12:48
@semanticdiff-com

semanticdiff-com Bot commented Jan 22, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/utils.rs  62% smaller
  crates/hyperswitch_domain_models/src/business_profile.rs  52% smaller
  crates/common_types/src/consts.rs  0% smaller

@kashif-m kashif-m added the S-test-ready Status: This PR is ready for cypress-tests label Jan 28, 2026
…ault-webhook-status-lists-in-business-profile
@likhinbopanna likhinbopanna added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit 553ac7a Jan 28, 2026
41 of 48 checks passed
@likhinbopanna likhinbopanna deleted the 11027-refactor-use-all-state-variants-as-default-webhook-status-lists-in-business-profile branch January 28, 2026 14:41
@codecov

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@0a454c3). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11028   +/-   ##
=======================================
  Coverage        ?        0           
=======================================
  Files           ?        0           
  Lines           ?        0           
  Branches        ?        0           
=======================================
  Hits            ?        0           
  Misses          ?        0           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

pixincreate added a commit that referenced this pull request Jan 29, 2026
* 'main' of github.com:juspay/hyperswitch:
  chore(version): 2026.01.29.0
  refactor(webhooks): default to triggering webhooks for all the states in payments, refunds and payouts flow (#11028)
  feat(payment-methods): add modular payment method retrieve transformer (#10994)
  feat(core): add support for Guest Customer in v2 tunnel (#10973)
  feat(interfaces): add query_params functionality in microservice client (#11026)
  refactor(connector): [Worldpayxml] webhook body from xml to url encoded (#10991)
  fix(connector): Fix PreAuth Conditions in NMI, Nuvei and Redsys (#11041)
  chore(version): 2026.01.28.1
  feat(payment_method_data): [adyen] Auth code in payment response (#10985)
  chore(version): 2026.01.28.0
@hyperswitch-bot hyperswitch-bot Bot removed the S-test-ready Status: This PR is ready for cypress-tests label Feb 1, 2026
srujanchikke pushed a commit that referenced this pull request Feb 2, 2026
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.

[REFACTOR] use all state variants as default webhook status lists in business profile

4 participants