Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector): remove default cases for Authorizedotnet, Braintree and Fiserv Connector #2796

Merged
merged 17 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 72 additions & 14 deletions crates/router/src/connector/authorizedotnet/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,23 @@ fn get_pm_and_subsequent_auth_detail(
});
Ok((payment_details, processing_options, subseuent_auth_info))
}
_ => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.router_data.request.payment_method_data),
connector: "AuthorizeDotNet",
})?,
api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::Wallet(_)
| api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?
}
}
}
_ => match item.router_data.request.payment_method_data {
Expand All @@ -195,10 +208,20 @@ fn get_pm_and_subsequent_auth_detail(
None,
None,
)),
_ => Err(errors::ConnectorError::NotSupported {
message: format!("{:?}", item.router_data.request.payment_method_data),
connector: "AuthorizeDotNet",
})?,
api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?,
},
}
}
Expand Down Expand Up @@ -295,7 +318,9 @@ impl From<enums::CaptureMethod> for AuthorizationType {
fn from(item: enums::CaptureMethod) -> Self {
match item {
enums::CaptureMethod::Manual => Self::Pre,
_ => Self::Final,
euclid::enums::CaptureMethod::Automatic
| enums::CaptureMethod::ManualMultiple
| enums::CaptureMethod::Scheduled => Self::Final,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ManualMultiple and Scheduled is not supported by the connector. In such cases throw error

}
}
}
Expand Down Expand Up @@ -904,7 +929,14 @@ impl From<SyncStatus> for enums::RefundStatus {
match transaction_status {
SyncStatus::RefundSettledSuccessfully => Self::Success,
SyncStatus::RefundPendingSettlement => Self::Pending,
_ => Self::Failure,
SyncStatus::AuthorizedPendingCapture
| SyncStatus::CapturedPendingSettlement
| SyncStatus::SettledSuccessfully
| SyncStatus::Declined
| SyncStatus::Voided
| SyncStatus::CouldNotVoid
| SyncStatus::GeneralError
| SyncStatus::FDSPendingReview => Self::Failure,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why FDSPendingReview, SettledSuccessfully, AuthorizedPendingCapture, CapturedPendingSettlement, Voided should be mapped to Failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepanshu-iiitu will handle the status mapping modifications in the pull request where he is addressing the connector audit fixes.

}
}
}
Expand All @@ -919,7 +951,9 @@ impl From<SyncStatus> for enums::AttemptStatus {
SyncStatus::Voided => Self::Voided,
SyncStatus::CouldNotVoid => Self::VoidFailed,
SyncStatus::GeneralError => Self::Failure,
_ => Self::Pending,
SyncStatus::RefundSettledSuccessfully
| SyncStatus::RefundPendingSettlement
| SyncStatus::FDSPendingReview => Self::Pending,
}
}
}
Expand Down Expand Up @@ -1164,9 +1198,33 @@ fn get_wallet_data(
cancel_url: return_url.to_owned(),
}))
}
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
))?,
api_models::payments::WalletData::AliPayQr(_)
| api_models::payments::WalletData::AliPayRedirect(_)
| api_models::payments::WalletData::AliPayHkRedirect(_)
| api_models::payments::WalletData::MomoRedirect(_)
| api_models::payments::WalletData::KakaoPayRedirect(_)
| api_models::payments::WalletData::GoPayRedirect(_)
| api_models::payments::WalletData::GcashRedirect(_)
| api_models::payments::WalletData::ApplePayRedirect(_)
| api_models::payments::WalletData::ApplePayThirdPartySdk(_)
| api_models::payments::WalletData::DanaRedirect {}
| api_models::payments::WalletData::GooglePayRedirect(_)
| api_models::payments::WalletData::GooglePayThirdPartySdk(_)
| api_models::payments::WalletData::MbWayRedirect(_)
| api_models::payments::WalletData::MobilePayRedirect(_)
| api_models::payments::WalletData::PaypalSdk(_)
| api_models::payments::WalletData::SamsungPay(_)
| api_models::payments::WalletData::TwintRedirect {}
| api_models::payments::WalletData::VippsRedirect {}
| api_models::payments::WalletData::TouchNGoRedirect(_)
| api_models::payments::WalletData::WeChatPayRedirect(_)
| api_models::payments::WalletData::WeChatPayQr(_)
| api_models::payments::WalletData::CashappQr(_)
| api_models::payments::WalletData::SwishQr(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("authorizedotnet"),
))?
}
}
}

Expand Down
62 changes: 56 additions & 6 deletions crates/router/src/connector/braintree/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,62 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BraintreePaymentsRequest {
api_models::payments::WalletData::PaypalSdk(wallet_data) => {
Ok(wallet_data.token.to_owned())
}
_ => Err(errors::ConnectorError::InvalidWallet),
api_models::payments::WalletData::ApplePay(_)
| api_models::payments::WalletData::GooglePay(_)
| api_models::payments::WalletData::SamsungPay(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
))
}
swangi-kumari marked this conversation as resolved.
Show resolved Hide resolved
api_models::payments::WalletData::AliPayQr(_)
| api_models::payments::WalletData::AliPayRedirect(_)
| api_models::payments::WalletData::AliPayHkRedirect(_)
| api_models::payments::WalletData::MomoRedirect(_)
| api_models::payments::WalletData::KakaoPayRedirect(_)
| api_models::payments::WalletData::GoPayRedirect(_)
| api_models::payments::WalletData::GcashRedirect(_)
| api_models::payments::WalletData::ApplePayRedirect(_)
| api_models::payments::WalletData::ApplePayThirdPartySdk(_)
| api_models::payments::WalletData::DanaRedirect {}
| api_models::payments::WalletData::GooglePayRedirect(_)
| api_models::payments::WalletData::GooglePayThirdPartySdk(_)
| api_models::payments::WalletData::MbWayRedirect(_)
| api_models::payments::WalletData::MobilePayRedirect(_)
| api_models::payments::WalletData::PaypalRedirect(_)
| api_models::payments::WalletData::TwintRedirect {}
| api_models::payments::WalletData::VippsRedirect {}
| api_models::payments::WalletData::TouchNGoRedirect(_)
| api_models::payments::WalletData::WeChatPayRedirect(_)
| api_models::payments::WalletData::WeChatPayQr(_)
| api_models::payments::WalletData::CashappQr(_)
| api_models::payments::WalletData::SwishQr(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
))
}
}?,
}))
}
_ => Err(errors::ConnectorError::NotImplemented(format!(
"Current Payment Method - {:?}",
item.request.payment_method_data
))),
api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_)
| api::PaymentMethodData::BankTransfer(_) => {
Err(errors::ConnectorError::NotImplemented(
swangi-kumari marked this conversation as resolved.
Show resolved Hide resolved
utils::get_unimplemented_payment_method_error_message("braintree"),
))
}
api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
))
}?,
}?;
let braintree_transaction_body = TransactionBody {
amount,
Expand Down Expand Up @@ -210,7 +258,9 @@ impl From<BraintreePaymentStatus> for enums::AttemptStatus {
| BraintreePaymentStatus::SettlementDeclined => Self::Failure,
BraintreePaymentStatus::Authorized => Self::Authorized,
BraintreePaymentStatus::Voided => Self::Voided,
_ => Self::Pending,
BraintreePaymentStatus::SubmittedForSettlement
| BraintreePaymentStatus::SettlementPending
| BraintreePaymentStatus::SettlementConfirmed => Self::Pending,
}
}
}
Expand Down
22 changes: 19 additions & 3 deletions crates/router/src/connector/fiserv/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,25 @@ impl TryFrom<&FiservRouterData<&types::PaymentsAuthorizeRouterData>> for FiservP
};
Source::PaymentCard { card }
}
_ => Err(errors::ConnectorError::NotImplemented(
"Payment Methods".to_string(),
api::PaymentMethodData::Wallet(_)
| api::PaymentMethodData::PayLater(_)
| api::PaymentMethodData::BankRedirect(_)
| api::PaymentMethodData::BankDebit(_) => Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("fiserv"),
swangi-kumari marked this conversation as resolved.
Show resolved Hide resolved
))?,
api::PaymentMethodData::CardRedirect(_)
| api::PaymentMethodData::BankTransfer(_)
| api::PaymentMethodData::Crypto(_)
| api::PaymentMethodData::MandatePayment
| api::PaymentMethodData::Reward
| api::PaymentMethodData::Upi(_)
| api::PaymentMethodData::Voucher(_)
| api::PaymentMethodData::GiftCard(_)
| api::PaymentMethodData::CardToken(_) => {
Err(errors::ConnectorError::NotImplemented(
utils::get_unimplemented_payment_method_error_message("braintree"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be fiserv .

))
}?,
};
Ok(Self {
amount,
Expand Down Expand Up @@ -306,7 +322,7 @@ impl From<FiservPaymentStatus> for enums::RefundStatus {
| FiservPaymentStatus::Authorized
| FiservPaymentStatus::Captured => Self::Success,
FiservPaymentStatus::Declined | FiservPaymentStatus::Failed => Self::Failure,
_ => Self::Pending,
FiservPaymentStatus::Voided | FiservPaymentStatus::Processing => Self::Pending,
}
}
}
Expand Down
Loading