fix(connector): [Rapyd] Fix payment response structure (#1258)

This commit is contained in:
Shankar Singh C
2023-05-30 11:22:44 +05:30
committed by GitHub
parent bfd7dad2f1
commit 3af3a3cb39

View File

@ -180,10 +180,14 @@ impl ForeignFrom<(RapydPaymentStatus, NextAction)> for enums::AttemptStatus {
let (status, next_action) = item; let (status, next_action) = item;
match (status, next_action) { match (status, next_action) {
(RapydPaymentStatus::Closed, _) => Self::Charged, (RapydPaymentStatus::Closed, _) => Self::Charged,
(RapydPaymentStatus::Active, NextAction::ThreedsVerification) => { (
Self::AuthenticationPending RapydPaymentStatus::Active,
} NextAction::ThreedsVerification | NextAction::PendingConfirmation,
(RapydPaymentStatus::Active, NextAction::PendingCapture) => Self::Authorized, ) => Self::AuthenticationPending,
(
RapydPaymentStatus::Active,
NextAction::PendingCapture | NextAction::NotApplicable,
) => Self::Authorized,
( (
RapydPaymentStatus::CanceledByClientOrBank RapydPaymentStatus::CanceledByClientOrBank
| RapydPaymentStatus::Expired | RapydPaymentStatus::Expired
@ -217,6 +221,10 @@ pub enum NextAction {
ThreedsVerification, ThreedsVerification,
#[serde(rename = "pending_capture")] #[serde(rename = "pending_capture")]
PendingCapture, PendingCapture,
#[serde(rename = "not_applicable")]
NotApplicable,
#[serde(rename = "pending_confirmation")]
PendingConfirmation,
} }
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@ -225,7 +233,7 @@ pub struct ResponseData {
pub amount: i64, pub amount: i64,
pub status: RapydPaymentStatus, pub status: RapydPaymentStatus,
pub next_action: NextAction, pub next_action: NextAction,
pub redirect_url: Option<Url>, pub redirect_url: Option<String>,
pub original_amount: Option<i64>, pub original_amount: Option<i64>,
pub is_partial: Option<bool>, pub is_partial: Option<bool>,
pub currency_code: Option<enums::Currency>, pub currency_code: Option<enums::Currency>,
@ -387,12 +395,20 @@ impl<F, T>
}), }),
), ),
_ => { _ => {
let redirection_data = data.redirect_url.as_ref().map(|redirect_url| { let redirction_url = data
services::RedirectForm::from(( .redirect_url
redirect_url.to_owned(), .as_ref()
services::Method::Get, .filter(|redirect_str| !redirect_str.is_empty())
)) .map(|url| {
}); Url::parse(url).into_report().change_context(
errors::ConnectorError::FailedToObtainIntegrationUrl,
)
})
.transpose()?;
let redirection_data = redirction_url
.map(|url| services::RedirectForm::from((url, services::Method::Get)));
( (
attempt_status, attempt_status,
Ok(types::PaymentsResponseData::TransactionResponse { Ok(types::PaymentsResponseData::TransactionResponse {