mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
fix(connector): [Paypal] Parse response for Cards with no 3DS check (#3021)
This commit is contained in:
@ -570,42 +570,95 @@ impl
|
|||||||
.parse_struct("paypal PaypalPreProcessingResponse")
|
.parse_struct("paypal PaypalPreProcessingResponse")
|
||||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||||
|
|
||||||
// permutation for status to continue payment
|
match response {
|
||||||
match (
|
// if card supports 3DS check for liability
|
||||||
response
|
paypal::PaypalPreProcessingResponse::PaypalLiabilityResponse(liability_response) => {
|
||||||
.payment_source
|
// permutation for status to continue payment
|
||||||
.card
|
match (
|
||||||
.authentication_result
|
liability_response
|
||||||
.three_d_secure
|
.payment_source
|
||||||
.enrollment_status
|
.card
|
||||||
.as_ref(),
|
.authentication_result
|
||||||
response
|
.three_d_secure
|
||||||
.payment_source
|
.enrollment_status
|
||||||
.card
|
.as_ref(),
|
||||||
.authentication_result
|
liability_response
|
||||||
.three_d_secure
|
.payment_source
|
||||||
.authentication_status
|
.card
|
||||||
.as_ref(),
|
.authentication_result
|
||||||
response
|
.three_d_secure
|
||||||
.payment_source
|
.authentication_status
|
||||||
.card
|
.as_ref(),
|
||||||
.authentication_result
|
liability_response
|
||||||
.liability_shift
|
.payment_source
|
||||||
.clone(),
|
.card
|
||||||
) {
|
.authentication_result
|
||||||
(
|
.liability_shift
|
||||||
Some(paypal::EnrollementStatus::Ready),
|
.clone(),
|
||||||
Some(paypal::AuthenticationStatus::Success),
|
) {
|
||||||
paypal::LiabilityShift::Possible,
|
(
|
||||||
)
|
Some(paypal::EnrollementStatus::Ready),
|
||||||
| (
|
Some(paypal::AuthenticationStatus::Success),
|
||||||
Some(paypal::EnrollementStatus::Ready),
|
paypal::LiabilityShift::Possible,
|
||||||
Some(paypal::AuthenticationStatus::Attempted),
|
)
|
||||||
paypal::LiabilityShift::Possible,
|
| (
|
||||||
)
|
Some(paypal::EnrollementStatus::Ready),
|
||||||
| (Some(paypal::EnrollementStatus::NotReady), None, paypal::LiabilityShift::No)
|
Some(paypal::AuthenticationStatus::Attempted),
|
||||||
| (Some(paypal::EnrollementStatus::Unavailable), None, paypal::LiabilityShift::No)
|
paypal::LiabilityShift::Possible,
|
||||||
| (Some(paypal::EnrollementStatus::Bypassed), None, paypal::LiabilityShift::No) => {
|
)
|
||||||
|
| (Some(paypal::EnrollementStatus::NotReady), None, paypal::LiabilityShift::No)
|
||||||
|
| (Some(paypal::EnrollementStatus::Unavailable), None, paypal::LiabilityShift::No)
|
||||||
|
| (Some(paypal::EnrollementStatus::Bypassed), None, paypal::LiabilityShift::No) => {
|
||||||
|
Ok(types::PaymentsPreProcessingRouterData {
|
||||||
|
status: storage_enums::AttemptStatus::AuthenticationSuccessful,
|
||||||
|
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||||
|
resource_id: types::ResponseId::NoResponseId,
|
||||||
|
redirection_data: None,
|
||||||
|
mandate_reference: None,
|
||||||
|
connector_metadata: None,
|
||||||
|
network_txn_id: None,
|
||||||
|
connector_response_reference_id: None,
|
||||||
|
incremental_authorization_allowed: None,
|
||||||
|
}),
|
||||||
|
..data.clone()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
_ => Ok(types::PaymentsPreProcessingRouterData {
|
||||||
|
response: Err(ErrorResponse {
|
||||||
|
attempt_status: Some(enums::AttemptStatus::Failure),
|
||||||
|
code: consts::NO_ERROR_CODE.to_string(),
|
||||||
|
message: consts::NO_ERROR_MESSAGE.to_string(),
|
||||||
|
connector_transaction_id: None,
|
||||||
|
reason: Some(format!("{} Connector Responsded with LiabilityShift: {:?}, EnrollmentStatus: {:?}, and AuthenticationStatus: {:?}",
|
||||||
|
consts::CANNOT_CONTINUE_AUTH,
|
||||||
|
liability_response
|
||||||
|
.payment_source
|
||||||
|
.card
|
||||||
|
.authentication_result
|
||||||
|
.liability_shift,
|
||||||
|
liability_response
|
||||||
|
.payment_source
|
||||||
|
.card
|
||||||
|
.authentication_result
|
||||||
|
.three_d_secure
|
||||||
|
.enrollment_status
|
||||||
|
.unwrap_or(paypal::EnrollementStatus::Null),
|
||||||
|
liability_response
|
||||||
|
.payment_source
|
||||||
|
.card
|
||||||
|
.authentication_result
|
||||||
|
.three_d_secure
|
||||||
|
.authentication_status
|
||||||
|
.unwrap_or(paypal::AuthenticationStatus::Null),
|
||||||
|
)),
|
||||||
|
status_code: res.status_code,
|
||||||
|
}),
|
||||||
|
..data.clone()
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if card does not supports 3DS check for liability
|
||||||
|
paypal::PaypalPreProcessingResponse::PaypalNonLiablityResponse(_) => {
|
||||||
Ok(types::PaymentsPreProcessingRouterData {
|
Ok(types::PaymentsPreProcessingRouterData {
|
||||||
status: storage_enums::AttemptStatus::AuthenticationSuccessful,
|
status: storage_enums::AttemptStatus::AuthenticationSuccessful,
|
||||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||||
@ -620,38 +673,6 @@ impl
|
|||||||
..data.clone()
|
..data.clone()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => Ok(types::PaymentsPreProcessingRouterData {
|
|
||||||
response: Err(ErrorResponse {
|
|
||||||
attempt_status: Some(enums::AttemptStatus::Failure),
|
|
||||||
code: consts::NO_ERROR_CODE.to_string(),
|
|
||||||
message: consts::NO_ERROR_MESSAGE.to_string(),
|
|
||||||
connector_transaction_id: None,
|
|
||||||
reason: Some(format!("{} Connector Responsded with LiabilityShift: {:?}, EnrollmentStatus: {:?}, and AuthenticationStatus: {:?}",
|
|
||||||
consts::CANNOT_CONTINUE_AUTH,
|
|
||||||
response
|
|
||||||
.payment_source
|
|
||||||
.card
|
|
||||||
.authentication_result
|
|
||||||
.liability_shift,
|
|
||||||
response
|
|
||||||
.payment_source
|
|
||||||
.card
|
|
||||||
.authentication_result
|
|
||||||
.three_d_secure
|
|
||||||
.enrollment_status
|
|
||||||
.unwrap_or(paypal::EnrollementStatus::Null),
|
|
||||||
response
|
|
||||||
.payment_source
|
|
||||||
.card
|
|
||||||
.authentication_result
|
|
||||||
.three_d_secure
|
|
||||||
.authentication_status
|
|
||||||
.unwrap_or(paypal::AuthenticationStatus::Null),
|
|
||||||
)),
|
|
||||||
status_code: res.status_code,
|
|
||||||
}),
|
|
||||||
..data.clone()
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -926,10 +926,22 @@ pub struct PaypalThreeDsResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct PaypalPreProcessingResponse {
|
#[serde(untagged)]
|
||||||
|
pub enum PaypalPreProcessingResponse {
|
||||||
|
PaypalLiabilityResponse(PaypalLiabilityResponse),
|
||||||
|
PaypalNonLiablityResponse(PaypalNonLiablityResponse),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct PaypalLiabilityResponse {
|
||||||
pub payment_source: CardParams,
|
pub payment_source: CardParams,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct PaypalNonLiablityResponse {
|
||||||
|
payment_source: CardsData,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct CardParams {
|
pub struct CardParams {
|
||||||
pub card: AuthResult,
|
pub card: AuthResult,
|
||||||
|
|||||||
Reference in New Issue
Block a user