Skip to content

feat(core): allow setting up status across payments, refunds and payouts for triggering webhooks in core resource flows#8433

Merged
likhinbopanna merged 6 commits intomainfrom
custom-webhook-delivery
Jun 30, 2025
Merged

feat(core): allow setting up status across payments, refunds and payouts for triggering webhooks in core resource flows#8433
likhinbopanna merged 6 commits intomainfrom
custom-webhook-delivery

Conversation

@kashif-m
Copy link
Contributor

Type of Change

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

Description

This pull request introduces validation for webhook status configurations at the business profile level.

Specifically, the following changes have been made:

  1. WebhookDetails Validation:

    • Added a validate() method to the WebhookDetails struct in crates/api_models/src/admin.rs.
    • This method ensures that any statuses provided in payment_statuses_enabled, refund_statuses_enabled, and payout_statuses_enabled are valid and correspond to triggerable event types.
  2. API Handler Integration:

    • Updated the API route handlers in crates/router/src/routes/profiles.rs for merchant account creation, merchant account updates, profile creation and profile updates.
    • These handlers now invoke the WebhookDetails::validate() method if webhook_details are present in the request payload.
    • If validation fails (i.e., an invalid status is provided), the API will return an ApiErrorResponse::InvalidRequestData with a descriptive message.
  3. Core flows - payments, refunds and payouts

    • Added logic for checking if the resource status is eligible for triggering an outgoing webhook in the payment, refund and payout flows.
    • If statuses configured are empty in profile, it uses a default list for checking the eligibility.
  4. WASM functionalities

    • Added functionality in WASM crate for fetching a list of valid webhook statuses which can be used to render on HyperSwitch dashboard for configurations.

This ensures that only valid webhook configurations are accepted and stored, improving the robustness of the outgoing webhook system.

Additional Changes

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

Motivation and Context

Allows merchants to configure different statuses for triggering outgoing webhooks.

How did you test it?

I. New behavior

1. Create Merchant Account with custom `webhook_details`

cURL

curl --location --request POST 'http://localhost:8080/accounts' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: test_admin' \
    --data-raw '{"merchant_id":"merchant_1750673206","locker_id":"m0010","merchant_name":"NewAge Retailer","merchant_details":{"primary_contact_person":"John Test","primary_email":"JohnTest@test.com","primary_phone":"sunt laborum","secondary_contact_person":"John Test2","secondary_email":"JohnTest2@test.com","secondary_phone":"cillum do dolor id","website":"https://www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US"}},"return_url":"https://google.com/success","webhook_details":{"webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass","payment_statuses_enabled":["requires_customer_action","failed"],"payout_statuses_enabled":["failed"],"refund_statuses_enabled":["success"]},"sub_merchants_enabled":false,"metadata":{"city":"NY","unit":"245"},"primary_business_details":[{"country":"IN","business":"default"}]}'

Response

{"merchant_id":"merchant_1750673203","merchant_name":"NewAge Retailer","return_url":"https://google.com/success","enable_payment_response_hash":true,"payment_response_hash_key":"pv3MWoTzwpOnCUWo8rkeBATn5QiaJ2MKtpKe9anxnqC2dt53I0pK6lH0yy50j1zT","redirect_to_merchant_with_http_post":false,"merchant_details":{"primary_contact_person":"John Test","primary_phone":"sunt laborum","primary_email":"JohnTest@test.com","secondary_contact_person":"John Test2","secondary_phone":"cillum do dolor id","secondary_email":"JohnTest2@test.com","website":"https://www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"city":"San Fransico","country":"US","line1":null,"line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":null,"last_name":null}},"webhook_details":{"webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass","webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","payment_statuses_enabled":["requires_customer_action","failed"],"refund_statuses_enabled":["success"],"payout_statuses_enabled":["failed"]},"payout_routing_algorithm":null,"sub_merchants_enabled":false,"parent_merchant_id":null,"publishable_key":"pk_dev_fdfb25c3c2294cf49aa1bb361afb1100","metadata":{"city":"NY","unit":"245","compatible_connector":null},"locker_id":"m0010","primary_business_details":[{"country":"IN","business":"default"}],"frm_routing_algorithm":null,"organization_id":"org_II9RJV4U9ZcIloWWrNbR","is_recon_enabled":false,"default_profile":"pro_65qra6NQYjw2UP9vperw","recon_status":"not_requested","pm_collect_link_config":null,"product_type":"orchestration","merchant_account_type":"standard"}

Expectation

  • Only valid status can be specified for triggering webhooks across payments, refunds and payouts
2. Create a payment

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_1MDGBqiM9KD4GY0mu6QfjecN40bJrnJWFDyGxxTdaGKKXt6xH3Jbrr59B0Ua4NPK' \
    --data-raw '{"amount":4500,"currency":"EUR","confirm":true,"profile_id":"pro_pNXZoICIkiLUZEYSrKfX","capture_method":"manual","capture_on":"2022-09-10T10:11:12Z","authentication_type":"three_ds","setup_future_usage":"off_session","connector":["adyen"],"customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","email":"abc@example.com","return_url":"https://google.com","payment_method":"card","payment_method_type":"debit","payment_method_data":{"card":{"card_number":"4111112014267661","card_exp_month":"12","card_exp_year":"2030","card_cvc":"737"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"IT","first_name":"joseph","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"metadata":{"Force-PSP":"Adyen","udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"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,"ip_address":"127.0.0.1"},"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_metadata":{"adyen":{"testing":{}}},"session_expiry":60}'

Response

{"payment_id":"pay_iApiXN3tqc2yW1XBP0Ua","merchant_id":"merchant_1750673324","status":"requires_capture","amount":4500,"net_amount":4500,"shipping_cost":null,"amount_capturable":4500,"amount_received":null,"connector":"adyen","client_secret":"pay_iApiXN3tqc2yW1XBP0Ua_secret_AgBcvgc6zoSu2Qr2sq96","created":"2025-06-23T10:08:56.548Z","currency":"EUR","customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","customer":{"id":"cus_zhY6PdgnyRlXLVGzqkvM","name":"John Nether","email":"abc@example.com","phone":"6168205362","phone_country_code":"+1"},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"7661","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"411111","card_extended_bin":null,"card_exp_month":"12","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"IT","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"joseph","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"order_details":null,"email":"abc@example.com","name":"John Nether","phone":"6168205362","return_url":"https://google.com/","authentication_type":"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,"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,"ephemeral_key":{"customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","created_at":1750673336,"expires":1750676936,"secret":"epk_0e045ee6e8b3409da23d14233314639d"},"manual_retry_allowed":false,"connector_transaction_id":"GZD3LFQ2BDDHL975","frm_message":null,"metadata":{"udf1":"value1","Force-PSP":"Adyen","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":{"apple_pay":null,"airwallex":null,"noon":null,"braintree":null,"adyen":{"testing":{"holder_name":null}}},"feature_metadata":null,"reference_id":"pay_iApiXN3tqc2yW1XBP0Ua_1","payment_link":null,"profile_id":"pro_pNXZoICIkiLUZEYSrKfX","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_9dLJtXqFTDdVt4fwwLL4","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-06-23T10:09:56.548Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"127.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_method_id":"pm_4eqrT6kM50j4XdLyX6YK","payment_method_status":"active","updated":"2025-06-23T10:08:57.185Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"JVZJSSRZPLSMC375","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}

Expectation

  • A payment webhook must be triggered since the status reaches requires_capture which was configured for triggering webhooks
3. Update an existing profile

cURL

curl --location --request POST 'http://localhost:8080/account/merchant_1750673423/business_profile/pro_vjiSMmVIZdLWNbPBnGXP' \
    --header 'Content-Type: application/json' \
    --header 'api-key: dev_WWRksDrZIVkWppHEPz4MWFccxq9ZMEoGHTWRw1euMjstZC3XD51mGBc5NjMLVAwx' \
    --data '{"webhook_details":{"webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass","payment_statuses_enabled":["requires_capture","failed"],"payout_statuses_enabled":["failed"],"refund_statuses_enabled":["success"]}}'

Response

{"merchant_id":"merchant_1750673423","profile_id":"pro_vjiSMmVIZdLWNbPBnGXP","profile_name":"IN_default","return_url":"https://google.com/success","enable_payment_response_hash":true,"payment_response_hash_key":"EPy4DzeilG41Sz0g2krFOfbz9jI49AnrsljEPFkIqRhHn96Hh70NcvvrsXMsuiR9","redirect_to_merchant_with_http_post":false,"webhook_details":{"webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass","webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","payment_statuses_enabled":["requires_capture","failed"],"refund_statuses_enabled":["success"],"payout_statuses_enabled":["failed"]},"metadata":null,"routing_algorithm":null,"intent_fulfillment_time":900,"frm_routing_algorithm":null,"payout_routing_algorithm":null,"applepay_verified_domains":["gdpp-dev.zurich.com"],"session_expiry":900,"payment_link_config":{"domain_name":null,"theme":"#E1E1E1","logo":"https://hyperswitch.io/favicon.ico","seller_name":null,"sdk_layout":null,"display_sdk_only":null,"enabled_saved_payment_method":true,"hide_card_nickname_field":null,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":null,"custom_message_for_card_terms":"","payment_button_colour":null,"skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":null,"payment_link_ui_rules":null,"enable_button_only_on_form_ready":null,"payment_form_header_text":null,"payment_form_label_type":null,"show_card_terms":"always","is_setup_mandate_flow":null,"color_icon_card_cvc_error":null,"business_specific_configs":{"mendix":{"theme":null,"logo":"https://hyperswitch.io/favicon.ico","seller_name":null,"sdk_layout":null,"display_sdk_only":true,"enabled_saved_payment_method":null,"hide_card_nickname_field":null,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":"Validate Card","custom_message_for_card_terms":null,"payment_button_colour":null,"skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":{".Input--invalid":{"color":"#545454"},".w-full.relative.flex.flex-row.my-4":{"display":"none"},".Tab":{"display":"none"},".InputLogo":{"color":"#545454"},".Error":{"paddingLeft":"0px","opacity":"1","color":"#CB4B40","display":"block","fontSize":"12px","marginTop":"4px"},".Label":{"left":"0px","fontWeight":"300","color":"#2167AE","fontSize":"12px","bottom":"5px","marginLeft":"0px","opacity":"1","fontFamily":"'zurich-sans-Medium', sans-serif"},".InputLogo--empty":{"color":"#979797"},".flex.flex-col.gap-2.h-auto.w-full":{"display":"none"},".Input":{"paddingBottom":"2px","fontWeight":"400","boxSizing":"border-box","height":"56px","width":"100%","paddingLeft":"0px","backgroundColor":"white","display":"block","border":"none","fontSize":"18px","color":"#23366F","borderRadius":"0px","boxShadow":"none","borderBottom":"1px solid #2167AE","fontFamily":"'zurich-sans-Medium', sans-serif"},".Input:focus":{"outline":"none","borderBottom":"1px solid #2167AE","backgroundColor":"white"},".Label--floating":{"opacity":"1"},".Input:focus + .Label":{"opacity":"0 !important"},".PaymentLabel":{"color":"#545454","fontSize":"24px"},".Input--empty":{"backgroundColor":"white","boxShadow":"none","borderBottom":"1px solid #2167AE"},".TabHeader":{"display":"none"},".InputLogo--invalid":{"color":"#CB4B40"},".Input::placeholder":{"fontFamily":"'zurich-sans-light', sans-serif","fontSize":"18px","paddingLeft":"0px","color":"#C0C0C0"}},"payment_link_ui_rules":{"#submit.processing":{"paddingLeft":"50px !important","paddingRight":"50px !important"},"#submit":{"padding":"13px 20px","marginTop":"24px","width":"max-content !important","borderRadius":"50px !important","backgroundColor":"#2167AE !important","height":"max-content !important","fontSize":"14px !important"}},"enable_button_only_on_form_ready":true,"payment_form_header_text":null,"payment_form_label_type":null,"show_card_terms":null,"is_setup_mandate_flow":null,"color_icon_card_cvc_error":"#CB4B40"},"omnium":{"theme":null,"logo":"https://hyperswitch.io/favicon.ico","seller_name":null,"sdk_layout":null,"display_sdk_only":true,"enabled_saved_payment_method":true,"hide_card_nickname_field":null,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":"Save Card","custom_message_for_card_terms":null,"payment_button_colour":"#c2c2c2","skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":{".Input:not(.Input--empty) + .Label":{"opacity":"0 !important"},".Error":{"marginTop":"4px","display":"block","opacity":"1","fontSize":"12px","paddingLeft":"0px","color":"#CB4B40"},".Label--invalid":{"color":"#CB4B40 !important","opacity":"1 !important"},".InputLogo--empty":{"color":"#979797"},".Tab":{"display":"none"},".TabHeader":{"display":"none"},".InputLogo":{"color":"#545454"},".w-full.relative.flex.flex-row.my-4":{"display":"none"},".Input:focus":{"border":"none !important","outline":"none","borderBottom":"1px solid #C2C2C2 !important","backgroundColor":"white","color":"#C2C2C2"},".Label":{"marginLeft":"0px","bottom":"5px","pointerEvents":"none","left":"0px","color":"#C2C2C2","opacity":"1","fontSize":"14px"},".Input--invalid":{"color":"#CB4B40"},".Input::placeholder":{"color":"#C2C2C2","paddingLeft":"0px"},".Input":{"width":"100%","fontSize":"14px","fontFamily":"'Open Sans', sans-serif","padding":"0","boxSizing":"border-box","borderRadius":"0px","backgroundColor":"white","display":"block","borderBottom":"1px solid #C2C2C2 !important","border":"none !important","boxShadow":"none","color":"#C2C2C2"},".PaymentLabel":{"fontSize":"24px","color":"#545454"},".InputLogo--invalid":{"color":"#CB4B40"},".flex.flex-col.gap-2.h-auto.w-full":{"display":"none"},".Input--empty":{"color":"#C2C2C2","backgroundColor":"white"},".Input:focus + .Label":{"color":"transparent"}},"payment_link_ui_rules":{"#submit":{"height":"25px !important","width":"max-content !important","backgroundColour":"#c2c2c2 !important","padding":"0 8px","color":"#ffffff !important","margin":"0 0 4px auto","fontSize":"13px !important","border":"1px solid #c2c2c2 !important","borderRadius":"0 !important"},"#submit.not-ready":{"border":"1px solid #c2c2c2 !important","backgroundColor":"#ffffff !important","color":"#c2c2c2 !important"},"#submit-spinner":{"borderBottomColor":"#c2c2c2 !important","width":"20px !important","border":"2px solid #fff !important","height":"20px !important"}},"enable_button_only_on_form_ready":true,"payment_form_header_text":null,"payment_form_label_type":"floating","show_card_terms":null,"is_setup_mandate_flow":null,"color_icon_card_cvc_error":"#CB4B40"},"zproject":{"theme":null,"logo":"https://hyperswitch.io/favicon.ico","seller_name":null,"sdk_layout":null,"display_sdk_only":true,"enabled_saved_payment_method":null,"hide_card_nickname_field":null,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":"Validate Card","custom_message_for_card_terms":null,"payment_button_colour":null,"skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":{".Label":{"marginLeft":"0px","left":"0px","color":"#5495CF !important","fontFamily":"'zurich-sans-light', sans-serif","fontWeight":"400","fontSize":"14px","bottom":"5px","opacity":"1 !important"},".InputLogo":{"color":"#545454"},".PaymentLabel":{"fontSize":"24px","color":"#545454 !important"},".w-full.relative.flex.flex-row.my-4":{"display":"none"},".Input, .Input:focus, .Input--invalid, .Input--empty":{"height":"56px","fontSize":"18px","paddingLeft":"0px !important","borderBottom":"1px solid #5495CF","boxShadow":"none","width":"100%","display":"block","borderRadius":"0px","border":"none","boxSizing":"border-box","color":"#000000","paddingBottom":"2px !important","backgroundColor":"white !important","fontFamily":"'zurich-sans-Medium', sans-serif","fontWeight":"400"},".Input::placeholder":{"color":"#C0C0C0","fontSize":"14px","paddingLeft":"0px !important","fontFamily":"'zurich-sans-light', sans-serif"},".Tab":{"display":"none"},".InputLogo--invalid":{"color":"#CB4B40"},".Input--invalid":{"color":"#545454 !important"},".InputLogo--empty":{"color":"#979797"},".Error":{"fontSize":"12px","color":"#CB4B40 !important","marginTop":"4px","opacity":"1 !important","paddingLeft":"0px","display":"block"},".TabHeader":{"display":"none"},".Input:focus + .Label":{"opacity":"0 !important"},".flex.flex-col.gap-2.h-auto.w-full":{"display":"none"},".Label--floating":{"opacity":"1 !important"}},"payment_link_ui_rules":{"#submit":{"padding":"13px 20px","fontSize":"14px !important","borderRadius":"50px !important","height":"max-content !important","backgroundColor":"#5495CF !important","marginTop":"24px","width":"max-content !important"},"#submit.processing":{"paddingRight":"50px !important","paddingLeft":"50px !important"}},"enable_button_only_on_form_ready":true,"payment_form_header_text":null,"payment_form_label_type":null,"show_card_terms":null,"is_setup_mandate_flow":null,"color_icon_card_cvc_error":"#CB4B40"},"illustrator":{"theme":null,"logo":"https://hyperswitch.io/favicon.ico","seller_name":null,"sdk_layout":null,"display_sdk_only":true,"enabled_saved_payment_method":null,"hide_card_nickname_field":null,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":"Save Card","custom_message_for_card_terms":null,"payment_button_colour":null,"skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":{".Label--floating,":{"opacity":"1 !important"},".Label--invalid, .Error":{"opacity":"1 !important","color":"#f00 !important"},".InputLogo--empty":{"color":"#979797"},".TabHeader":{"display":"none"},".Input, .Input:focus, .Input--invalid, .Input--empty":{"width":"100%","fontFamily":"'Open Sans', sans-serif","paddingBottom":"2px !important","paddingLeft":"0px !important","height":"56px","fontWeight":"400","boxSizing":"border-box","color":"#494949","borderBottom":"1px solid #C2C2C2","borderRadius":"0px","backgroundColor":"white !important","display":"block","border":"none","fontSize":"14px","boxShadow":"none"},".InputLogo":{"color":"#545454"},".flex.flex-col.gap-2.h-auto.w-full":{"display":"none"},".Input::placeholder":{"color":"#979797","paddingLeft":"0px !important"},".Input--invalid":{"color":"#545454 !important","borderBottom":"1px solid #f00 !important"},".PaymentLabel":{"color":"#545454 !important","fontSize":"24px"},".w-full.relative.flex.flex-row.my-4":{"display":"none"},".Input:focus + .Label":{"opacity":"0 !important"},".Error":{"marginTop":"4px","fontSize":"12px","paddingLeft":"0px","color":"#f00 !important","display":"block","opacity":"1 !important"},".InputLogo--invalid":{"color":"#CB4B40"},".Tab":{"display":"none"},".Label":{"color":"#FF0022","left":"0px","opacity":"1 !important","marginLeft":"0px","bottom":"5px"}},"payment_link_ui_rules":{"#submit":{"margin":"0 4px 0 auto","fontSize":"13px !important","width":"max-content !important","borderRadius":"0 !important","border":"1px solid #b2b2b2 !important","backgroundColor":"#b2b2b2 !important","height":"25px !important","padding":"0 8px","color":"#ffffff !important"},"#submit.not-ready":{"color":"#b2b2b2 !important","border":"1px solid #b2b2b2 !important","backgroundColor":"#ffffff !important"},"#submit-spinner":{"height":"20px !important","width":"20px !important","borderBottomColor":"#c2c2c2 !important","border":"2px solid #fff !important"}},"enable_button_only_on_form_ready":true,"payment_form_header_text":null,"payment_form_label_type":null,"show_card_terms":null,"is_setup_mandate_flow":null,"color_icon_card_cvc_error":"#CB4B40"},"spain":{"theme":"#2167AE","logo":null,"seller_name":null,"sdk_layout":null,"display_sdk_only":true,"enabled_saved_payment_method":null,"hide_card_nickname_field":true,"show_card_form_by_default":null,"transaction_details":null,"background_image":null,"details_layout":null,"payment_button_text":null,"custom_message_for_card_terms":null,"payment_button_colour":null,"skip_status_screen":null,"payment_button_text_colour":null,"background_colour":null,"sdk_ui_rules":{".InputLogo":{"color":"#23366F"},".InputLogo--invalid":{"color":"#CB4B40"},".Input, .Input:focus, .Input--empty":{"color":"#23366F"},".Label--floating":{"opacity":"1 !important"},".Input, .Input:focus, .Input--invalid, .Input--empty":{"backgroundColor":"rgb(231, 234, 235) !important","paddingLeft":"22px !important","border":"none","boxShadow":"none","borderRadius":"28px","fontSize":"20px","height":"56px","paddingBottom":"2px !important"},".Label":{"color":"#2167AE","opacity":"1 !important","bottom":"5px","marginLeft":"22px"},".Label--invalid, .Input--invalid, .Error":{"color":"#CB4B40 !important","opacity":"1 !important"},".PaymentLabel":{"color":"#23366F !important","fontSize":"24px"},".InputLogo--empty":{"color":"#979797"},".Input--invalid":{"border":"2px solid #CB4B40 !important"}},"payment_link_ui_rules":{"#submit":{"height":"max-content","padding":"14px 20px","fontSize":"20px","marginTop":"48px","borderRadius":"50px"},"#submit.not-ready":{"backgroundColor":"#A6ADAF !important"},"#submit.processing":{"paddingRight":"50px !important","paddingLeft":"50px !important"}},"enable_button_only_on_form_ready":true,"payment_form_header_text":null,"payment_form_label_type":"floating","show_card_terms":"never","is_setup_mandate_flow":null,"color_icon_card_cvc_error":null}},"allowed_domains":["http://localhost:5500","localhost:5500","*","localhost:5501","http://localhost:5501"],"branding_visibility":false},"authentication_connector_details":null,"use_billing_as_payment_method_billing":true,"extended_card_info_config":null,"collect_shipping_details_from_wallet_connector":false,"collect_billing_details_from_wallet_connector":false,"always_collect_shipping_details_from_wallet_connector":false,"always_collect_billing_details_from_wallet_connector":false,"is_connector_agnostic_mit_enabled":true,"payout_link_config":null,"outgoing_webhook_custom_http_headers":null,"tax_connector_id":null,"is_tax_connector_enabled":false,"is_network_tokenization_enabled":true,"is_auto_retries_enabled":false,"max_auto_retries_enabled":null,"always_request_extended_authorization":null,"is_click_to_pay_enabled":false,"authentication_product_ids":null,"card_testing_guard_config":{"card_ip_blocking_status":"disabled","card_ip_blocking_threshold":3,"guest_user_card_blocking_status":"disabled","guest_user_card_blocking_threshold":10,"customer_id_blocking_status":"disabled","customer_id_blocking_threshold":5,"card_testing_guard_expiry":3600},"is_clear_pan_retries_enabled":false,"force_3ds_challenge":false,"is_debit_routing_enabled":false,"merchant_business_country":null,"is_pre_network_tokenization_enabled":false,"acquirer_configs":null,"is_iframe_redirection_enabled":null,"merchant_category_code":null}

Expectation

  • Only valid status can be specified for triggering webhooks across payments, refunds and payouts

II. Existing behavior

1. Create Merchant account without specifying custom status list for triggering webhooks

cURL

curl --location --request POST 'http://localhost:8080/accounts' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: test_admin' \
    --data-raw '{"merchant_id":"merchant_1750673427","locker_id":"m0010","merchant_name":"NewAge Retailer","merchant_details":{"primary_contact_person":"John Test","primary_email":"JohnTest@test.com","primary_phone":"sunt laborum","secondary_contact_person":"John Test2","secondary_email":"JohnTest2@test.com","secondary_phone":"cillum do dolor id","website":"https://www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"US"}},"return_url":"https://google.com/success","webhook_details":{"webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass"},"sub_merchants_enabled":false,"metadata":{"city":"NY","unit":"245"},"primary_business_details":[{"country":"IN","business":"default"}]}'

Response

{"merchant_id":"merchant_1750673423","merchant_name":"NewAge Retailer","return_url":"https://google.com/success","enable_payment_response_hash":true,"payment_response_hash_key":"EPy4DzeilG41Sz0g2krFOfbz9jI49AnrsljEPFkIqRhHn96Hh70NcvvrsXMsuiR9","redirect_to_merchant_with_http_post":false,"merchant_details":{"primary_contact_person":"John Test","primary_phone":"sunt laborum","primary_email":"JohnTest@test.com","secondary_contact_person":"John Test2","secondary_phone":"cillum do dolor id","secondary_email":"JohnTest2@test.com","website":"https://www.example.com","about_business":"Online Retail with a wide selection of organic products for North America","address":{"city":"San Fransico","country":"US","line1":null,"line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":null,"last_name":null}},"webhook_details":{"webhook_version":"1.0.1","webhook_username":"random","webhook_password":"pass","webhook_url":"https://webhook.site/ede0ddc6-5583-4a92-80e3-d513028c4fe2","payment_statuses_enabled":null,"refund_statuses_enabled":null,"payout_statuses_enabled":null},"payout_routing_algorithm":null,"sub_merchants_enabled":false,"parent_merchant_id":null,"publishable_key":"pk_dev_429522d9b95049bb9f077fdbbf270d2c","metadata":{"city":"NY","unit":"245","compatible_connector":null},"locker_id":"m0010","primary_business_details":[{"country":"IN","business":"default"}],"frm_routing_algorithm":null,"organization_id":"org_wpDh2xmA3WgSWCi8Lzik","is_recon_enabled":false,"default_profile":"pro_vjiSMmVIZdLWNbPBnGXP","recon_status":"not_requested","pm_collect_link_config":null,"product_type":"orchestration","merchant_account_type":"standard"}
2. Create a payment

cURL

curl --location --request POST 'http://localhost:8080/payments' \
    --header 'Content-Type: application/json' \
    --header 'Accept: application/json' \
    --header 'api-key: dev_WWRksDrZIVkWppHEPz4MWFccxq9ZMEoGHTWRw1euMjstZC3XD51mGBc5NjMLVAwx' \
    --data-raw '{"amount":4500,"currency":"EUR","confirm":true,"profile_id":"pro_vjiSMmVIZdLWNbPBnGXP","capture_method":"manual","capture_on":"2022-09-10T10:11:12Z","authentication_type":"three_ds","setup_future_usage":"off_session","connector":["adyen"],"customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","email":"abc@example.com","return_url":"https://google.com","payment_method":"card","payment_method_type":"debit","payment_method_data":{"card":{"card_number":"4111112014267661","card_exp_month":"12","card_exp_year":"2030","card_cvc":"737"}},"billing":{"address":{"line1":"1467","line2":"Harrison Street","line3":"Harrison Street","city":"San Fransico","state":"California","zip":"94122","country":"IT","first_name":"joseph","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"metadata":{"Force-PSP":"Adyen","udf1":"value1","new_customer":"true","login_date":"2019-09-10T10:11:12Z"},"browser_info":{"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,"ip_address":"127.0.0.1"},"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_metadata":{"adyen":{"testing":{}}},"session_expiry":60}'

Response

{"payment_id":"pay_g0OJdggJBGyoEzizQvs5","merchant_id":"merchant_1750673423","status":"requires_capture","amount":4500,"net_amount":4500,"shipping_cost":null,"amount_capturable":4500,"amount_received":null,"connector":"adyen","client_secret":"pay_g0OJdggJBGyoEzizQvs5_secret_hfNsAK9g7dE6py1TIyMV","created":"2025-06-23T10:11:45.123Z","currency":"EUR","customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","customer":{"id":"cus_zhY6PdgnyRlXLVGzqkvM","name":null,"email":"abc@example.com","phone":null,"phone_country_code":null},"description":null,"refunds":null,"disputes":null,"mandate_id":null,"mandate_data":null,"setup_future_usage":"off_session","off_session":null,"capture_on":null,"capture_method":"manual","payment_method":"card","payment_method_data":{"card":{"last4":"7661","card_type":null,"card_network":null,"card_issuer":null,"card_issuing_country":null,"card_isin":"411111","card_extended_bin":null,"card_exp_month":"12","card_exp_year":"2030","card_holder_name":null,"payment_checks":null,"authentication_data":null},"billing":null},"payment_token":null,"shipping":null,"billing":{"address":{"city":"San Fransico","country":"IT","line1":"1467","line2":"Harrison Street","line3":"Harrison Street","zip":"94122","state":"California","first_name":"joseph","last_name":"Doe"},"phone":{"number":"8056594427","country_code":"+91"},"email":"guest@example.com"},"order_details":null,"email":"abc@example.com","name":null,"phone":null,"return_url":"https://google.com/","authentication_type":"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,"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,"ephemeral_key":{"customer_id":"cus_zhY6PdgnyRlXLVGzqkvM","created_at":1750673505,"expires":1750677105,"secret":"epk_f3de069957be49b9b927d52fd2c01192"},"manual_retry_allowed":false,"connector_transaction_id":"NJHLXGQ2BDDHL975","frm_message":null,"metadata":{"udf1":"value1","Force-PSP":"Adyen","login_date":"2019-09-10T10:11:12Z","new_customer":"true"},"connector_metadata":{"apple_pay":null,"airwallex":null,"noon":null,"braintree":null,"adyen":{"testing":{"holder_name":null}}},"feature_metadata":null,"reference_id":"pay_g0OJdggJBGyoEzizQvs5_1","payment_link":null,"profile_id":"pro_vjiSMmVIZdLWNbPBnGXP","surcharge_details":null,"attempt_count":1,"merchant_decision":null,"merchant_connector_id":"mca_q5cJJsbcZBqqwUZURC49","incremental_authorization_allowed":null,"authorization_count":null,"incremental_authorizations":null,"external_authentication_details":null,"external_3ds_authentication_attempted":false,"expires_on":"2025-06-23T10:12:45.123Z","fingerprint":null,"browser_info":{"language":"en-US","time_zone":-330,"ip_address":"127.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_method_id":"pm_kWp3mS4JxBegRLBnls36","payment_method_status":"active","updated":"2025-06-23T10:11:46.750Z","split_payments":null,"frm_metadata":null,"extended_authorization_applied":null,"capture_before":null,"merchant_order_reference_id":null,"order_tax_amount":null,"connector_mandate_id":"WCLS4TMLJZ545G75","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}

Expectation

  • Webhook must not be triggered as payment status requires_capture is not configured for triggering webhooks by default

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 Jun 23, 2025
@kashif-m kashif-m requested a review from a team as a code owner June 23, 2025 10:41
@kashif-m kashif-m added the A-core Area: Core flows label Jun 23, 2025
@kashif-m kashif-m requested review from a team as code owners June 23, 2025 10:41
@kashif-m kashif-m added the A-webhooks Area: Webhook flows label Jun 23, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Jun 23, 2025

Copy link
Member

@jarnura jarnura left a comment

Choose a reason for hiding this comment

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

Is this change causes any issues in v2, the checks are failing for v2

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jun 23, 2025
@kashif-m kashif-m requested a review from jarnura June 24, 2025 16:16
@kashif-m
Copy link
Contributor Author

Is this change causes any issues in v2, the checks are failing for v2

This was due to missing feature dependency in euclid_wasm, fixed this one.

@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 30, 2025
Merged via the queue into main with commit d305fad Jun 30, 2025
16 of 20 checks passed
@likhinbopanna likhinbopanna deleted the custom-webhook-delivery branch June 30, 2025 07:41
maverox pushed a commit that referenced this pull request Jul 8, 2025
…uts for triggering webhooks in core resource flows (#8433)

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 A-webhooks Area: Webhook flows M-api-contract-changes Metadata: This PR involves API contract changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] allow configuring outgoing webhooks for different status as a part of payment and refund flows

4 participants