mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
fix(connector): [Worldpay] add root CA certificate (#8205)
This commit is contained in:
@ -4597,10 +4597,11 @@ merchant_secret="Source verification key"
|
|||||||
payment_method_type = "google_pay"
|
payment_method_type = "google_pay"
|
||||||
[[worldpay.wallet]]
|
[[worldpay.wallet]]
|
||||||
payment_method_type = "apple_pay"
|
payment_method_type = "apple_pay"
|
||||||
[worldpay.connector_auth.SignatureKey]
|
[worldpay.connector_auth.MultiAuthKey]
|
||||||
key1="Username"
|
key1="Username"
|
||||||
api_key="Password"
|
api_key="Password"
|
||||||
api_secret="Merchant Identifier"
|
api_secret="Merchant Identifier"
|
||||||
|
key2="Worldpay's CA Certificate"
|
||||||
[worldpay.connector_webhook_details]
|
[worldpay.connector_webhook_details]
|
||||||
merchant_secret="Source verification key"
|
merchant_secret="Source verification key"
|
||||||
[worldpay.metadata.merchant_name]
|
[worldpay.metadata.merchant_name]
|
||||||
|
|||||||
@ -3296,10 +3296,11 @@ merchant_secret="Source verification key"
|
|||||||
payment_method_type = "google_pay"
|
payment_method_type = "google_pay"
|
||||||
[[worldpay.wallet]]
|
[[worldpay.wallet]]
|
||||||
payment_method_type = "apple_pay"
|
payment_method_type = "apple_pay"
|
||||||
[worldpay.connector_auth.SignatureKey]
|
[worldpay.connector_auth.MultiAuthKey]
|
||||||
key1="Username"
|
key1="Username"
|
||||||
api_key="Password"
|
api_key="Password"
|
||||||
api_secret="Merchant Identifier"
|
api_secret="Merchant Identifier"
|
||||||
|
key2="Worldpay's CA Certificate"
|
||||||
[worldpay.metadata.merchant_name]
|
[worldpay.metadata.merchant_name]
|
||||||
name="merchant_name"
|
name="merchant_name"
|
||||||
label="Name of the merchant to de displayed during 3DS challenge"
|
label="Name of the merchant to de displayed during 3DS challenge"
|
||||||
|
|||||||
@ -4557,10 +4557,11 @@ merchant_secret="Source verification key"
|
|||||||
payment_method_type = "google_pay"
|
payment_method_type = "google_pay"
|
||||||
[[worldpay.wallet]]
|
[[worldpay.wallet]]
|
||||||
payment_method_type = "apple_pay"
|
payment_method_type = "apple_pay"
|
||||||
[worldpay.connector_auth.SignatureKey]
|
[worldpay.connector_auth.MultiAuthKey]
|
||||||
key1="Username"
|
key1="Username"
|
||||||
api_key="Password"
|
api_key="Password"
|
||||||
api_secret="Merchant Identifier"
|
api_secret="Merchant Identifier"
|
||||||
|
key2="Worldpay's CA Certificate"
|
||||||
[worldpay.connector_webhook_details]
|
[worldpay.connector_webhook_details]
|
||||||
merchant_secret="Source verification key"
|
merchant_secret="Source verification key"
|
||||||
[worldpay.metadata.merchant_name]
|
[worldpay.metadata.merchant_name]
|
||||||
|
|||||||
@ -233,12 +233,15 @@ impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsRespons
|
|||||||
req: &SetupMandateRouterData,
|
req: &SetupMandateRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
.url(&types::SetupMandateType::get_url(self, req, connectors)?)
|
.url(&types::SetupMandateType::get_url(self, req, connectors)?)
|
||||||
.attach_default_headers()
|
.attach_default_headers()
|
||||||
.headers(types::SetupMandateType::get_headers(self, req, connectors)?)
|
.headers(types::SetupMandateType::get_headers(self, req, connectors)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.set_body(types::SetupMandateType::get_request_body(
|
.set_body(types::SetupMandateType::get_request_body(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
@ -336,12 +339,15 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Wo
|
|||||||
req: &PaymentsCancelRouterData,
|
req: &PaymentsCancelRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
.url(&PaymentsVoidType::get_url(self, req, connectors)?)
|
.url(&PaymentsVoidType::get_url(self, req, connectors)?)
|
||||||
.attach_default_headers()
|
.attach_default_headers()
|
||||||
.headers(PaymentsVoidType::get_headers(self, req, connectors)?)
|
.headers(PaymentsVoidType::get_headers(self, req, connectors)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.build(),
|
.build(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -442,12 +448,15 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Wor
|
|||||||
req: &PaymentsSyncRouterData,
|
req: &PaymentsSyncRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Get)
|
.method(Method::Get)
|
||||||
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
|
.url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
|
||||||
.attach_default_headers()
|
.attach_default_headers()
|
||||||
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
|
.headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.build(),
|
.build(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -579,6 +588,8 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
|
|||||||
req: &PaymentsCaptureRouterData,
|
req: &PaymentsCaptureRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
@ -587,6 +598,7 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
|
|||||||
.headers(types::PaymentsCaptureType::get_headers(
|
.headers(types::PaymentsCaptureType::get_headers(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.set_body(types::PaymentsCaptureType::get_request_body(
|
.set_body(types::PaymentsCaptureType::get_request_body(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
@ -704,6 +716,8 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
|
|||||||
req: &PaymentsAuthorizeRouterData,
|
req: &PaymentsAuthorizeRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
@ -714,6 +728,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
|
|||||||
.headers(types::PaymentsAuthorizeType::get_headers(
|
.headers(types::PaymentsAuthorizeType::get_headers(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.set_body(types::PaymentsAuthorizeType::get_request_body(
|
.set_body(types::PaymentsAuthorizeType::get_request_body(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
@ -820,6 +835,8 @@ impl ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResp
|
|||||||
req: &PaymentsCompleteAuthorizeRouterData,
|
req: &PaymentsCompleteAuthorizeRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
let request = RequestBuilder::new()
|
let request = RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
.url(&types::PaymentsCompleteAuthorizeType::get_url(
|
.url(&types::PaymentsCompleteAuthorizeType::get_url(
|
||||||
@ -828,6 +845,7 @@ impl ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResp
|
|||||||
.headers(types::PaymentsCompleteAuthorizeType::get_headers(
|
.headers(types::PaymentsCompleteAuthorizeType::get_headers(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.set_body(types::PaymentsCompleteAuthorizeType::get_request_body(
|
.set_body(types::PaymentsCompleteAuthorizeType::get_request_body(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
@ -931,6 +949,8 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Worldpa
|
|||||||
req: &RefundsRouterData<Execute>,
|
req: &RefundsRouterData<Execute>,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
let request = RequestBuilder::new()
|
let request = RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
|
.url(&types::RefundExecuteType::get_url(self, req, connectors)?)
|
||||||
@ -938,6 +958,7 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Worldpa
|
|||||||
.headers(types::RefundExecuteType::get_headers(
|
.headers(types::RefundExecuteType::get_headers(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.set_body(types::RefundExecuteType::get_request_body(
|
.set_body(types::RefundExecuteType::get_request_body(
|
||||||
self, req, connectors,
|
self, req, connectors,
|
||||||
)?)
|
)?)
|
||||||
@ -1028,12 +1049,15 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Worldpay
|
|||||||
req: &RefundSyncRouterData,
|
req: &RefundSyncRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type)
|
||||||
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Get)
|
.method(Method::Get)
|
||||||
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
|
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
|
||||||
.attach_default_headers()
|
.attach_default_headers()
|
||||||
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
|
.headers(types::RefundSyncType::get_headers(self, req, connectors)?)
|
||||||
|
.add_ca_certificate_pem(auth.ca_certificate)
|
||||||
.build(),
|
.build(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -562,6 +562,7 @@ impl<T: WorldpayPaymentsRequestData> TryFrom<(&WorldpayRouterData<&T>, &Secret<S
|
|||||||
pub struct WorldpayAuthType {
|
pub struct WorldpayAuthType {
|
||||||
pub(super) api_key: Secret<String>,
|
pub(super) api_key: Secret<String>,
|
||||||
pub(super) entity_id: Secret<String>,
|
pub(super) entity_id: Secret<String>,
|
||||||
|
pub(super) ca_certificate: Option<Secret<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<&ConnectorAuthType> for WorldpayAuthType {
|
impl TryFrom<&ConnectorAuthType> for WorldpayAuthType {
|
||||||
@ -575,6 +576,7 @@ impl TryFrom<&ConnectorAuthType> for WorldpayAuthType {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
api_key: Secret::new(auth_header),
|
api_key: Secret::new(auth_header),
|
||||||
entity_id: Secret::new("default".to_string()),
|
entity_id: Secret::new("default".to_string()),
|
||||||
|
ca_certificate: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ConnectorAuthType::SignatureKey {
|
ConnectorAuthType::SignatureKey {
|
||||||
@ -587,6 +589,21 @@ impl TryFrom<&ConnectorAuthType> for WorldpayAuthType {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
api_key: Secret::new(auth_header),
|
api_key: Secret::new(auth_header),
|
||||||
entity_id: api_secret.clone(),
|
entity_id: api_secret.clone(),
|
||||||
|
ca_certificate: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ConnectorAuthType::MultiAuthKey {
|
||||||
|
api_key,
|
||||||
|
key1,
|
||||||
|
api_secret,
|
||||||
|
key2,
|
||||||
|
} => {
|
||||||
|
let auth_key = format!("{}:{}", key1.peek(), api_key.peek());
|
||||||
|
let auth_header = format!("Basic {}", BASE64_ENGINE.encode(auth_key));
|
||||||
|
Ok(Self {
|
||||||
|
api_key: Secret::new(auth_header),
|
||||||
|
entity_id: api_secret.clone(),
|
||||||
|
ca_certificate: Some(key2.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,
|
_ => Err(errors::ConnectorError::FailedToObtainAuthType)?,
|
||||||
|
|||||||
Reference in New Issue
Block a user