Skip to content
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

refactor(connector): modify build_headers method to accept connectors… #265

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions crates/router/src/connector/aci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -137,7 +138,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.headers(types::PaymentsSyncType::get_headers(self, req)?)
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.body(types::PaymentsSyncType::get_request_body(self, req)?)
.build(),
))
Expand Down Expand Up @@ -196,6 +197,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -247,7 +249,9 @@ impl
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.headers(types::PaymentsAuthorizeType::get_headers(self, req)?)
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsAuthorizeType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -303,6 +307,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsCancelRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -346,7 +351,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.headers(types::PaymentsVoidType::get_headers(self, req)?)
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
.body(types::PaymentsVoidType::get_request_body(self, req)?)
.build(),
))
Expand Down Expand Up @@ -401,6 +406,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
fn get_headers(
&self,
req: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -449,7 +455,9 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.headers(types::RefundExecuteType::get_headers(self, req)?)
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.body(types::RefundExecuteType::get_request_body(self, req)?)
.build(),
))
Expand Down
16 changes: 12 additions & 4 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl
fn get_headers(
&self,
req: &types::RouterData<api::PSync, types::PaymentsSyncData, types::PaymentsResponseData>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -171,7 +172,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.headers(types::PaymentsSyncType::get_headers(self, req)?)
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsSyncType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -222,6 +223,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError>
where
Self: services::ConnectorIntegration<
Expand Down Expand Up @@ -274,7 +276,9 @@ impl
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.headers(types::PaymentsAuthorizeType::get_headers(self, req)?)
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsAuthorizeType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -324,6 +328,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsCancelRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -362,7 +367,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.headers(types::PaymentsVoidType::get_headers(self, req)?)
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsVoidType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -412,6 +417,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
fn get_headers(
&self,
req: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut header = vec![
(
Expand Down Expand Up @@ -456,7 +462,9 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.headers(types::RefundExecuteType::get_headers(self, req)?)
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.body(types::RefundExecuteType::get_request_body(self, req)?)
.build(),
))
Expand Down
5 changes: 4 additions & 1 deletion crates/router/src/connector/applepay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl
fn get_headers(
&self,
_req: &types::PaymentsSessionRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let header = vec![(
headers::CONTENT_TYPE.to_string(),
Expand Down Expand Up @@ -129,7 +130,9 @@ impl
let request = services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsSessionType::get_url(self, req, connectors)?)
.headers(types::PaymentsSessionType::get_headers(self, req)?)
.headers(types::PaymentsSessionType::get_headers(
self, req, connectors,
)?)
.body(types::PaymentsSessionType::get_request_body(self, req)?)
.add_certificate(types::PaymentsSessionType::get_certificate(self, req)?)
.add_certificate_key(types::PaymentsSessionType::get_certificate_key(self, req)?)
Expand Down
19 changes: 14 additions & 5 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl
fn get_headers(
&self,
_req: &types::PaymentsSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
// This connector does not require an auth header, the authentication details are sent in the request body
Ok(vec![
Expand Down Expand Up @@ -126,7 +127,7 @@ impl
let request = services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.headers(types::PaymentsSyncType::get_headers(self, req)?)
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.body(types::PaymentsSyncType::get_request_body(self, req)?)
.build();
Ok(Some(request))
Expand Down Expand Up @@ -175,6 +176,7 @@ impl
fn get_headers(
&self,
_req: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
// This connector does not require an auth header, the authentication details are sent in the request body
Ok(vec![
Expand Down Expand Up @@ -224,7 +226,9 @@ impl
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.headers(types::PaymentsAuthorizeType::get_headers(self, req)?)
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsAuthorizeType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -275,6 +279,7 @@ impl
fn get_headers(
&self,
_req: &types::PaymentsCancelRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
Ok(vec![
(
Expand Down Expand Up @@ -315,7 +320,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.headers(types::PaymentsVoidType::get_headers(self, req)?)
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
.header(headers::X_ROUTER, "test")
.body(types::PaymentsVoidType::get_request_body(self, req)?)
.build(),
Expand Down Expand Up @@ -366,6 +371,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
fn get_headers(
&self,
_req: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
// This connector does not require an auth header, the authentication details are sent in the request body
Ok(vec![
Expand Down Expand Up @@ -408,7 +414,9 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
let request = services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.headers(types::RefundExecuteType::get_headers(self, req)?)
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.body(types::RefundExecuteType::get_request_body(self, req)?)
.build();
Ok(Some(request))
Expand Down Expand Up @@ -455,6 +463,7 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
fn get_headers(
&self,
_req: &types::RefundsRouterData<api::RSync>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
// This connector does not require an auth header, the authentication details are sent in the request body
Ok(vec![
Expand Down Expand Up @@ -498,7 +507,7 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
let request = services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
.headers(types::RefundSyncType::get_headers(self, req)?)
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
.body(types::RefundSyncType::get_request_body(self, req)?)
.build();
Ok(Some(request))
Expand Down
22 changes: 17 additions & 5 deletions crates/router/src/connector/braintree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsSessionRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut headers = vec![
(
Expand Down Expand Up @@ -105,7 +106,9 @@ impl
services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::PaymentsSessionType::get_url(self, req, connectors)?)
.headers(types::PaymentsSessionType::get_headers(self, req)?)
.headers(types::PaymentsSessionType::get_headers(
self, req, connectors,
)?)
.body(types::PaymentsSessionType::get_request_body(self, req)?)
.build(),
);
Expand Down Expand Up @@ -191,6 +194,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsSyncRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut headers = vec![
(
Expand Down Expand Up @@ -239,7 +243,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Get)
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
.headers(types::PaymentsSyncType::get_headers(self, req)?)
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
.body(types::PaymentsSyncType::get_request_body(self, req)?)
.build(),
))
Expand Down Expand Up @@ -296,6 +300,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsAuthorizeRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut headers = vec![
(
Expand Down Expand Up @@ -337,7 +342,9 @@ impl
.url(&types::PaymentsAuthorizeType::get_url(
self, req, connectors,
)?)
.headers(types::PaymentsAuthorizeType::get_headers(self, req)?)
.headers(types::PaymentsAuthorizeType::get_headers(
self, req, connectors,
)?)
.body(types::PaymentsAuthorizeType::get_request_body(self, req)?)
.build(),
))
Expand Down Expand Up @@ -399,6 +406,7 @@ impl
fn get_headers(
&self,
req: &types::PaymentsCancelRouterData,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut headers = vec![
(
Expand Down Expand Up @@ -442,7 +450,7 @@ impl
services::RequestBuilder::new()
.method(services::Method::Put)
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
.headers(types::PaymentsVoidType::get_headers(self, req)?)
.headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
.body(types::PaymentsVoidType::get_request_body(self, req)?)
.build(),
))
Expand Down Expand Up @@ -499,6 +507,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
fn get_headers(
&self,
req: &types::RefundsRouterData<api::Execute>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
let mut headers = vec![
(
Expand Down Expand Up @@ -552,7 +561,9 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
let request = services::RequestBuilder::new()
.method(services::Method::Post)
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
.headers(types::RefundExecuteType::get_headers(self, req)?)
.headers(types::RefundExecuteType::get_headers(
self, req, connectors,
)?)
.body(types::RefundExecuteType::get_request_body(self, req)?)
.build();
Ok(Some(request))
Expand Down Expand Up @@ -592,6 +603,7 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
fn get_headers(
&self,
_req: &types::RouterData<api::RSync, types::RefundsData, types::RefundsResponseData>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, String)>, errors::ConnectorError> {
Err(errors::ConnectorError::NotImplemented("braintree".to_string()).into())
}
Expand Down
Loading