diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml index ace6a7f668..5c7f780818 100644 --- a/crates/connector_configs/toml/development.toml +++ b/crates/connector_configs/toml/development.toml @@ -4597,10 +4597,11 @@ merchant_secret="Source verification key" payment_method_type = "google_pay" [[worldpay.wallet]] payment_method_type = "apple_pay" -[worldpay.connector_auth.SignatureKey] +[worldpay.connector_auth.MultiAuthKey] key1="Username" api_key="Password" api_secret="Merchant Identifier" +key2="Worldpay's CA Certificate" [worldpay.connector_webhook_details] merchant_secret="Source verification key" [worldpay.metadata.merchant_name] diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml index 877dd08f6c..85598589ba 100644 --- a/crates/connector_configs/toml/production.toml +++ b/crates/connector_configs/toml/production.toml @@ -3296,10 +3296,11 @@ merchant_secret="Source verification key" payment_method_type = "google_pay" [[worldpay.wallet]] payment_method_type = "apple_pay" -[worldpay.connector_auth.SignatureKey] +[worldpay.connector_auth.MultiAuthKey] key1="Username" api_key="Password" api_secret="Merchant Identifier" +key2="Worldpay's CA Certificate" [worldpay.metadata.merchant_name] name="merchant_name" label="Name of the merchant to de displayed during 3DS challenge" diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml index fcd458b378..af8a19c8be 100644 --- a/crates/connector_configs/toml/sandbox.toml +++ b/crates/connector_configs/toml/sandbox.toml @@ -4557,10 +4557,11 @@ merchant_secret="Source verification key" payment_method_type = "google_pay" [[worldpay.wallet]] payment_method_type = "apple_pay" -[worldpay.connector_auth.SignatureKey] +[worldpay.connector_auth.MultiAuthKey] key1="Username" api_key="Password" api_secret="Merchant Identifier" +key2="Worldpay's CA Certificate" [worldpay.connector_webhook_details] merchant_secret="Source verification key" [worldpay.metadata.merchant_name] diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay.rs b/crates/hyperswitch_connectors/src/connectors/worldpay.rs index 009a02f7ef..0d9a79ed5e 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay.rs @@ -233,12 +233,15 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&types::SetupMandateType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::SetupMandateType::get_headers(self, req, connectors)?) + .add_ca_certificate_pem(auth.ca_certificate) .set_body(types::SetupMandateType::get_request_body( self, req, connectors, )?) @@ -336,12 +339,15 @@ impl ConnectorIntegration for Wo req: &PaymentsCancelRouterData, connectors: &Connectors, ) -> CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Post) .url(&PaymentsVoidType::get_url(self, req, connectors)?) .attach_default_headers() .headers(PaymentsVoidType::get_headers(self, req, connectors)?) + .add_ca_certificate_pem(auth.ca_certificate) .build(), )) } @@ -442,12 +448,15 @@ impl ConnectorIntegration for Wor req: &PaymentsSyncRouterData, connectors: &Connectors, ) -> CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Get) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .add_ca_certificate_pem(auth.ca_certificate) .build(), )) } @@ -579,6 +588,8 @@ impl ConnectorIntegration fo req: &PaymentsCaptureRouterData, connectors: &Connectors, ) -> CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Post) @@ -587,6 +598,7 @@ impl ConnectorIntegration fo .headers(types::PaymentsCaptureType::get_headers( self, req, connectors, )?) + .add_ca_certificate_pem(auth.ca_certificate) .set_body(types::PaymentsCaptureType::get_request_body( self, req, connectors, )?) @@ -704,6 +716,8 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Post) @@ -714,6 +728,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let request = RequestBuilder::new() .method(Method::Post) .url(&types::PaymentsCompleteAuthorizeType::get_url( @@ -828,6 +845,7 @@ impl ConnectorIntegration for Worldpa req: &RefundsRouterData, connectors: &Connectors, ) -> CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let request = RequestBuilder::new() .method(Method::Post) .url(&types::RefundExecuteType::get_url(self, req, connectors)?) @@ -938,6 +958,7 @@ impl ConnectorIntegration for Worldpa .headers(types::RefundExecuteType::get_headers( self, req, connectors, )?) + .add_ca_certificate_pem(auth.ca_certificate) .set_body(types::RefundExecuteType::get_request_body( self, req, connectors, )?) @@ -1028,12 +1049,15 @@ impl ConnectorIntegration for Worldpay req: &RefundSyncRouterData, connectors: &Connectors, ) -> CustomResult, errors::ConnectorError> { + let auth = worldpay::WorldpayAuthType::try_from(&req.connector_auth_type) + .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(Some( RequestBuilder::new() .method(Method::Get) .url(&types::RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::RefundSyncType::get_headers(self, req, connectors)?) + .add_ca_certificate_pem(auth.ca_certificate) .build(), )) } diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs index 20b21be770..84d6e13cde 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay/transformers.rs @@ -562,6 +562,7 @@ impl TryFrom<(&WorldpayRouterData<&T>, &Secret, pub(super) entity_id: Secret, + pub(super) ca_certificate: Option>, } impl TryFrom<&ConnectorAuthType> for WorldpayAuthType { @@ -575,6 +576,7 @@ impl TryFrom<&ConnectorAuthType> for WorldpayAuthType { Ok(Self { api_key: Secret::new(auth_header), entity_id: Secret::new("default".to_string()), + ca_certificate: None, }) } ConnectorAuthType::SignatureKey { @@ -587,6 +589,21 @@ impl TryFrom<&ConnectorAuthType> for WorldpayAuthType { Ok(Self { api_key: Secret::new(auth_header), 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)?,