mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
fix(connector): [SHIFT4] Fix 3DS payments and api key (#9480)
This commit is contained in:
@ -2,6 +2,7 @@ pub mod transformers;
|
|||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use api_models::webhooks::IncomingWebhookEvent;
|
use api_models::webhooks::IncomingWebhookEvent;
|
||||||
|
use base64::Engine;
|
||||||
use common_enums::enums;
|
use common_enums::enums;
|
||||||
use common_utils::{
|
use common_utils::{
|
||||||
errors::CustomResult,
|
errors::CustomResult,
|
||||||
@ -46,7 +47,7 @@ use hyperswitch_interfaces::{
|
|||||||
types::{self, Response},
|
types::{self, Response},
|
||||||
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
|
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
|
||||||
};
|
};
|
||||||
use masking::Mask;
|
use masking::{Mask, PeekInterface};
|
||||||
use transformers::{self as shift4, Shift4PaymentsRequest, Shift4RefundRequest};
|
use transformers::{self as shift4, Shift4PaymentsRequest, Shift4RefundRequest};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -111,9 +112,13 @@ impl ConnectorCommon for Shift4 {
|
|||||||
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
|
||||||
let auth = shift4::Shift4AuthType::try_from(auth_type)
|
let auth = shift4::Shift4AuthType::try_from(auth_type)
|
||||||
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
|
||||||
|
let api_key = format!(
|
||||||
|
"Basic {}",
|
||||||
|
common_utils::consts::BASE64_ENGINE.encode(format!("{}:", auth.api_key.peek()))
|
||||||
|
);
|
||||||
Ok(vec![(
|
Ok(vec![(
|
||||||
headers::AUTHORIZATION.to_string(),
|
headers::AUTHORIZATION.to_string(),
|
||||||
auth.api_key.into_masked(),
|
api_key.into_masked(),
|
||||||
)])
|
)])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +282,19 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Shift4 {}
|
impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Shift4 {
|
||||||
|
fn build_request(
|
||||||
|
&self,
|
||||||
|
_req: &hyperswitch_domain_models::types::PaymentsCancelRouterData,
|
||||||
|
_connectors: &Connectors,
|
||||||
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
Err(errors::ConnectorError::NotSupported {
|
||||||
|
message: "Void".to_string(),
|
||||||
|
connector: "Shift4",
|
||||||
|
}
|
||||||
|
.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Shift4 {
|
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Shift4 {
|
||||||
fn get_headers(
|
fn get_headers(
|
||||||
@ -373,6 +390,12 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
|
|||||||
req: &PaymentsCaptureRouterData,
|
req: &PaymentsCaptureRouterData,
|
||||||
connectors: &Connectors,
|
connectors: &Connectors,
|
||||||
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
) -> CustomResult<Option<Request>, errors::ConnectorError> {
|
||||||
|
if req.request.amount_to_capture != req.request.payment_amount {
|
||||||
|
Err(errors::ConnectorError::NotSupported {
|
||||||
|
message: "Partial Capture".to_string(),
|
||||||
|
connector: "Shift4",
|
||||||
|
})?
|
||||||
|
}
|
||||||
Ok(Some(
|
Ok(Some(
|
||||||
RequestBuilder::new()
|
RequestBuilder::new()
|
||||||
.method(Method::Post)
|
.method(Method::Post)
|
||||||
@ -488,7 +511,7 @@ impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResp
|
|||||||
)?;
|
)?;
|
||||||
let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
|
let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
|
||||||
let connector_req = Shift4PaymentsRequest::try_from(&connector_router_data)?;
|
let connector_req = Shift4PaymentsRequest::try_from(&connector_router_data)?;
|
||||||
Ok(RequestContent::Json(Box::new(connector_req)))
|
Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_request(
|
fn build_request(
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const successfulNo3DSCardDetails = {
|
|||||||
|
|
||||||
const successfulThreeDSTestCardDetails = {
|
const successfulThreeDSTestCardDetails = {
|
||||||
...successfulNo3DSCardDetails,
|
...successfulNo3DSCardDetails,
|
||||||
card_number: "4000000000003063", // Using standard test card with authentication_type: "three_ds"
|
card_number: "4012001800000016", // Using standard test card with authentication_type: "three_ds"
|
||||||
};
|
};
|
||||||
|
|
||||||
const failedNo3DSCardDetails = {
|
const failedNo3DSCardDetails = {
|
||||||
@ -43,11 +43,11 @@ const failedNo3DSCardDetails = {
|
|||||||
|
|
||||||
const payment_method_data_3ds = {
|
const payment_method_data_3ds = {
|
||||||
card: {
|
card: {
|
||||||
last4: "3063",
|
last4: "0016",
|
||||||
card_type: "DEBIT",
|
card_type: "DEBIT",
|
||||||
card_network: "Visa",
|
card_network: "Visa",
|
||||||
card_issuer: "STRIPE PAYMENTS UK LIMITED",
|
card_issuer: "VISA PRODUCTION SUPPORT CLIENT BID 1",
|
||||||
card_issuing_country: "UNITEDKINGDOM",
|
card_issuing_country: "UNITEDSTATES",
|
||||||
card_isin: "401200",
|
card_isin: "401200",
|
||||||
card_extended_bin: null,
|
card_extended_bin: null,
|
||||||
card_exp_month: "10",
|
card_exp_month: "10",
|
||||||
@ -267,6 +267,9 @@ export const connectorDetails = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
PartialCapture: {
|
PartialCapture: {
|
||||||
|
Configs: {
|
||||||
|
TRIGGER_SKIP: true, // Partial Capture is not supported in Shift4
|
||||||
|
},
|
||||||
Request: {
|
Request: {
|
||||||
amount_to_capture: 2000,
|
amount_to_capture: 2000,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user