-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(webhooks): add support for custom outgoing webhook http headers #5275
Conversation
6aef41c
to
1f255e1
Compare
api-reference/openapi_spec.json
Outdated
@@ -6991,6 +6991,11 @@ | |||
} | |||
], | |||
"nullable": true | |||
}, | |||
"custom_outgoing_webhook_http_headers": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"custom_outgoing_webhook_http_headers": { | |
"outgoing_webhook_custom_http_headers": { |
crates/api_models/src/admin.rs
Outdated
|
||
/// These key-value pairs are sent as additional custom headers in the outgoing webhook request. It is recommended not to use more than four key-value pairs. | ||
#[schema(value_type = Option<Object>, example = r#"{ "key1": "value-1", "key2": "value-2" }"#)] | ||
pub custom_outgoing_webhook_http_headers: Option<pii::SecretSerdeValue>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should accept it as an Hashmap here right?
let custom_outgoing_webhook_http_headers = business_profile | ||
.custom_outgoing_webhook_http_headers | ||
.clone(); | ||
let hashset = utils::convert_serde_json_to_hashset(custom_outgoing_webhook_http_headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use serde_json::from_value
here instead?
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure) | ||
.attach_printable("Failed to construct outgoing webhook request content")?; | ||
.attach_printable("Failed to construct outgoing webhook custom HTTP headers")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this change?
let custom_headers = decrypt::<serde_json::Value, masking::WithType>( | ||
business_profile | ||
.outgoing_webhook_custom_http_headers | ||
.clone(), | ||
key_store.key.get_inner().peek(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd preferably want to have this implementation as part of domain type implementation rather than encrypting/decrypting it individually in separate locations. We can take up the domain type implementation in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will take this in separate pr .
routing_algorithm: Some(serde_json::json!({ | ||
"algorithm_id": null, | ||
"timestamp": 0 | ||
})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this hardcoded value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SanchithHegde this was hardcoded for backward compatibility.
cc: @Aprabhat19
bb9f3b5
* 'main' of github.com:juspay/hyperswitch: (25 commits) fix(logs): ignore request headers while logging (#5273) feat(webhooks): add support for custom outgoing webhook http headers (#5275) fix(payment_methods): set `requires_cvv` to false when either `connector_mandate_details` or `network_transaction_id` is present during MITs (#5331) chore: create justfile for running commands for v1 and v2 migrations (#5325) fix(routing): do not update `perform_session_flow_routing` output if the `SessionRoutingChoice` is none (#5336) fix(database): modified_at updated for every state change for Payment Attempts (#5312) feat(mca): Added recipient connector call for open banking connectors (#3758) chore(version): 2024.07.16.0 refactor(connector): [Mifinity] add a field language_preference in payment request for mifinity payment method data (#5326) fix(router): store `customer_acceptance` in payment_attempt, use it in confirm flow for delayed authorizations like external 3ds flow (#5308) feat(proxy): add support to pass proxy bypass urls from configs (#5322) Docs: Updating Error codes in API-ref (#5296) feat(core): [Payouts] Add retrieve flow for payouts (#4936) fix(connector): [AUTHORIZEDOTNET] Populate error reason for failure transactions (#5319) chore(version): 2024.07.15.0 feat(logging): Emit a setup error when a restricted keys are used for logging default keys (#5185) feat(payment_methods): add support to migrate existing customer PMs from processor to hyperswitch (#5306) feat(connector): [DATATRANS] Implement card payments (#5028) chore: making of function create_encrypted_data (#5251) fix(payments): populate merchant order ref id in list (#5310) ...
Type of Change
Description
This pr adds support for custom outgoing webhook http headers. If we pass
custom_outgoing_webhook_http_headers
to business profile these headers will be forwaded to all outgoing webhooks request headers.Additional Changes
Motivation and Context
How did you test it?
Test case 1 :
Create or Update the business profile with custom http headers
Create payment you should should be able to see custom headers in the configure test webhook site.
Test case 2 : Pass random string to the field
custom_outgoing_webhook_http_headers
, this should not trigger custom headers to outgoing webhook, but this will show warning in the logsTestcase 3 : Check how data is stored in db,
outgoing_webhook_custom_http_headers
should be encrypted in db.Test case 4: check whether retry for outgoing webhooks have custom headers . You can verify it by passing invalid return url to create 4xx webhook.
Checklist
cargo +nightly fmt --all
cargo clippy