Skip to content

Commit

Permalink
fix(events): fix default values for request body
Browse files Browse the repository at this point in the history
  • Loading branch information
lsampras committed Dec 12, 2023
1 parent ee3e3f4 commit 17c1126
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ intent_analytics_topic = "hyperswitch-payment-intent-events"
attempt_analytics_topic = "hyperswitch-payment-attempt-events"
refund_analytics_topic = "hyperswitch-refund-events"
api_logs_topic = "hyperswitch-api-log-events"
connector_events_topic = "hyperswitch-connector-api-events"
connector_logs_topic = "hyperswitch-connector-api-events"

[analytics]
source = "sqlx"
Expand Down
2 changes: 1 addition & 1 deletion crates/pm_auth/src/types/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub trait ConnectorIntegration<T, Req, Resp>: ConnectorIntegrationAny<T, Req, Re
&self,
_req: &super::PaymentAuthRouterData<T, Req, Resp>,
) -> CustomResult<RequestContent, ConnectorError> {
Ok(RequestContent::Json(Box::new(serde_json::json!(r#""#))))
Ok(RequestContent::Json(Box::new(serde_json::json!(r#"{}"#))))
}

fn build_request(
Expand Down
10 changes: 0 additions & 10 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,13 +466,6 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
self.common_get_content_type()
}

fn get_request_body(
&self,
_req: &types::PaymentsSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
Ok(RequestContent::Json(Box::new(serde_json::json!({}))))
}
fn build_request(
&self,
req: &types::PaymentsSyncRouterData,
Expand Down Expand Up @@ -818,9 +811,6 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.attach_default_headers()
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
.set_body(types::RefundSyncType::get_request_body(
self, req, connectors,
)?)
.build(),
))
}
Expand Down
7 changes: 4 additions & 3 deletions crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub trait ConnectorIntegration<T, Req, Resp>: ConnectorIntegrationAny<T, Req, Re
_req: &types::RouterData<T, Req, Resp>,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
Ok(RequestContent::Json(Box::new(json!(r#""#))))
Ok(RequestContent::Json(Box::new(json!(r#"{}"#))))
}

fn get_request_form_data(
Expand Down Expand Up @@ -287,7 +287,8 @@ where
Some(RequestContent::Json(payload))
| Some(RequestContent::FormUrlEncoded(payload))
| Some(RequestContent::Xml(payload)) => payload.masked_serialize().unwrap_or_default(),
_ => serde_json::Value::Null,
Some(RequestContent::FormData(_)) => json!({"request_type": "FORM_DATA"}),
None => serde_json::Value::Null,
});
logger::debug!(connector_request_body=?masked_conn_req);
logger::debug!(payment_id=?req.payment_id);
Expand Down Expand Up @@ -374,7 +375,7 @@ where
.unwrap_or(json!({ "error": "failed to mask serialize"})),
RequestContent::FormData(_) => json!({"request_type": "FORM_DATA"}),
},
None => json!({"error": "EMPTY_REQUEST_BODY"}),
None => serde_json::Value::Null,
};
let request_url = request.url.clone();
let request_method = request.method;
Expand Down

0 comments on commit 17c1126

Please sign in to comment.