mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
fix: TODO's and FIXME's in connectors (#183)
This commit is contained in:
@ -72,7 +72,7 @@ impl
|
||||
types::PaymentsResponseData,
|
||||
> for Aci
|
||||
{
|
||||
// TODO: Critical Implement
|
||||
// Issue: #173
|
||||
}
|
||||
|
||||
impl
|
||||
@ -345,7 +345,6 @@ impl
|
||||
Ok(Some(
|
||||
services::RequestBuilder::new()
|
||||
.method(services::Method::Post)
|
||||
// TODO: [ORCA-346] Requestbuilder needs &str migrate get_url to send &str instead of owned string
|
||||
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
|
||||
.headers(types::PaymentsVoidType::get_headers(self, req)?)
|
||||
.body(types::PaymentsVoidType::get_request_body(self, req)?)
|
||||
|
||||
@ -217,7 +217,6 @@ impl<F, T>
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
..item.data
|
||||
|
||||
@ -40,7 +40,6 @@ impl api::ConnectorCommon for Adyen {
|
||||
Ok(vec![(headers::X_API_KEY.to_string(), auth.api_key)])
|
||||
}
|
||||
|
||||
//FIXME with enum
|
||||
fn base_url(&self, connectors: settings::Connectors) -> String {
|
||||
connectors.adyen.base_url
|
||||
}
|
||||
@ -60,7 +59,7 @@ impl
|
||||
types::PaymentsResponseData,
|
||||
> for Adyen
|
||||
{
|
||||
// TODO: Critical implement
|
||||
// Issue: #173
|
||||
}
|
||||
|
||||
impl api::PaymentSession for Adyen {}
|
||||
@ -362,7 +361,6 @@ impl
|
||||
Ok(Some(
|
||||
services::RequestBuilder::new()
|
||||
.method(services::Method::Post)
|
||||
// TODO: [ORCA-346] Requestbuilder needs &str migrate get_url to send &str instead of owned string
|
||||
.url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
|
||||
.headers(types::PaymentsVoidType::get_headers(self, req)?)
|
||||
.header(headers::X_ROUTER, "test")
|
||||
|
||||
@ -7,8 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::{
|
||||
consts,
|
||||
core::errors,
|
||||
pii::{self, PeekInterface},
|
||||
services,
|
||||
pii, services,
|
||||
types::{
|
||||
self,
|
||||
api::{self, enums as api_enums},
|
||||
@ -153,10 +152,10 @@ pub enum AdyenPaymentMethod {
|
||||
pub struct AdyenCard {
|
||||
#[serde(rename = "type")]
|
||||
payment_type: String,
|
||||
number: Option<pii::Secret<String>>,
|
||||
number: Option<pii::Secret<String, pii::CardNumber>>,
|
||||
expiry_month: Option<pii::Secret<String>>,
|
||||
expiry_year: Option<pii::Secret<String>>,
|
||||
cvc: Option<String>,
|
||||
cvc: Option<pii::Secret<String>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Serialize, Deserialize)]
|
||||
@ -301,12 +300,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AdyenPaymentRequest {
|
||||
storage_enums::PaymentMethodType::Card => {
|
||||
let card = AdyenCard {
|
||||
payment_type,
|
||||
number: ccard.map(|x| x.card_number.peek().clone().into()), // FIXME: xxx: should also be secret?
|
||||
expiry_month: ccard.map(|x| x.card_exp_month.peek().clone().into()),
|
||||
expiry_year: ccard.map(|x| x.card_exp_year.peek().clone().into()),
|
||||
// TODO: CVV/CVC shouldn't be saved in our db
|
||||
// Will need to implement tokenization that allows us to make payments without cvv
|
||||
cvc: ccard.map(|x| x.card_cvc.peek().into()),
|
||||
number: ccard.map(|x| x.card_number.clone()),
|
||||
expiry_month: ccard.map(|x| x.card_exp_month.clone()),
|
||||
expiry_year: ccard.map(|x| x.card_exp_year.clone()),
|
||||
cvc: ccard.map(|x| x.card_cvc.clone()),
|
||||
};
|
||||
|
||||
Ok(AdyenPaymentMethod::AdyenCard(card))
|
||||
@ -413,7 +410,6 @@ impl TryFrom<types::PaymentsCancelResponseRouterData<AdyenCancelResponse>>
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.psp_reference),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
..item.data
|
||||
@ -455,7 +451,6 @@ pub fn get_adyen_response(
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(response.psp_reference),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
};
|
||||
Ok((status, error, payments_response_data))
|
||||
@ -521,7 +516,6 @@ pub fn get_redirection_response(
|
||||
resource_id: types::ResponseId::NoResponseId,
|
||||
redirection_data: Some(redirection_data),
|
||||
redirect: true,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
};
|
||||
Ok((status, error, payments_response_data))
|
||||
|
||||
@ -128,7 +128,6 @@ impl
|
||||
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
|
||||
let request = services::RequestBuilder::new()
|
||||
.method(services::Method::Post)
|
||||
// TODO: [ORCA-346] Requestbuilder needs &str migrate get_url to send &str instead of owned string
|
||||
.url(&types::PaymentsSessionType::get_url(self, req, connectors)?)
|
||||
.headers(types::PaymentsSessionType::get_headers(self, req)?)
|
||||
.body(types::PaymentsSessionType::get_request_body(self, req)?)
|
||||
|
||||
@ -77,7 +77,6 @@ impl<F, T>
|
||||
item: types::ResponseRouterData<F, ApplepaySessionResponse, T, types::PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
Ok(types::RouterData {
|
||||
//TODO : change in session response to fit apple pay session object
|
||||
response: Ok(types::PaymentsResponseData::SessionResponse {
|
||||
session_token: {
|
||||
api_models::payments::SessionToken::Applepay {
|
||||
|
||||
@ -63,7 +63,7 @@ impl
|
||||
types::PaymentsResponseData,
|
||||
> for Authorizedotnet
|
||||
{
|
||||
// TODO: Critical Implement
|
||||
// Issue: #173
|
||||
}
|
||||
|
||||
impl
|
||||
|
||||
@ -588,7 +588,6 @@ impl<F, Req>
|
||||
),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
status: payment_status,
|
||||
|
||||
@ -209,7 +209,6 @@ impl<F, T>
|
||||
),
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
..item.data
|
||||
|
||||
@ -77,7 +77,7 @@ impl
|
||||
types::PaymentsResponseData,
|
||||
> for Checkout
|
||||
{
|
||||
// TODO: Critical Implement
|
||||
// Issue: #173
|
||||
}
|
||||
|
||||
impl
|
||||
@ -251,7 +251,6 @@ impl
|
||||
data: &types::PaymentsAuthorizeRouterData,
|
||||
res: types::Response,
|
||||
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
|
||||
//TODO: [ORCA-618] If 3ds fails, the response should be a redirect response, to redirect client to success/failed page
|
||||
let response: checkout::PaymentsResponse = res
|
||||
.response
|
||||
.parse_struct("PaymentIntentResponse")
|
||||
@ -276,14 +275,12 @@ impl
|
||||
code: response
|
||||
.error_codes
|
||||
.unwrap_or_else(|| vec![consts::NO_ERROR_CODE.to_string()])
|
||||
//Considered all the codes here but have to look into the exact no.of codes
|
||||
.join(" & "),
|
||||
message: response
|
||||
.error_type
|
||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||
reason: None,
|
||||
})
|
||||
//TODO : No sufficient information of error codes (no.of error codes to consider)
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +372,6 @@ impl
|
||||
code: response
|
||||
.error_codes
|
||||
.unwrap_or_else(|| vec![consts::NO_ERROR_CODE.to_string()])
|
||||
//Considered all the codes here but have to look into the exact no.of codes
|
||||
.join(" & "),
|
||||
message: response
|
||||
.error_type
|
||||
@ -482,14 +478,12 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
|
||||
code: response
|
||||
.error_codes
|
||||
.unwrap_or_else(|| vec![consts::NO_ERROR_CODE.to_string()])
|
||||
//Considered all the codes here but have to look into the exact no.of codes
|
||||
.join(" & "),
|
||||
message: response
|
||||
.error_type
|
||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||
reason: None,
|
||||
})
|
||||
//TODO : No sufficient information of error codes (no.of error codes to consider)
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,14 +576,12 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
|
||||
code: response
|
||||
.error_codes
|
||||
.unwrap_or_else(|| vec![consts::NO_ERROR_CODE.to_string()])
|
||||
//Considered all the codes here but have to look into the exact no.of codes
|
||||
.join(" & "),
|
||||
message: response
|
||||
.error_type
|
||||
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
|
||||
reason: None,
|
||||
})
|
||||
//TODO : No sufficient information of error codes (no.of error codes to consider)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,7 +25,6 @@ pub struct CardSource {
|
||||
#[serde(untagged)]
|
||||
pub enum Source {
|
||||
Card(CardSource),
|
||||
// TODO: Add other sources here.
|
||||
}
|
||||
|
||||
pub struct CheckoutAuthType {
|
||||
@ -220,7 +219,6 @@ impl TryFrom<types::PaymentsResponseRouterData<PaymentsResponse>>
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
|
||||
redirect: redirection_data.is_some(),
|
||||
redirection_data,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
..item.data
|
||||
@ -235,14 +233,31 @@ impl TryFrom<types::PaymentsSyncResponseRouterData<PaymentsResponse>>
|
||||
fn try_from(
|
||||
item: types::PaymentsSyncResponseRouterData<PaymentsResponse>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
let redirection_url = item
|
||||
.response
|
||||
.links
|
||||
.redirect
|
||||
.map(|data| Url::parse(&data.href))
|
||||
.transpose()
|
||||
.into_report()
|
||||
.change_context(errors::ParsingError)
|
||||
.attach_printable("Could not parse the redirection data")?;
|
||||
|
||||
let redirection_data = redirection_url.map(|url| services::RedirectForm {
|
||||
url: url.to_string(),
|
||||
method: services::Method::Get,
|
||||
form_fields: std::collections::HashMap::from_iter(
|
||||
url.query_pairs()
|
||||
.map(|(k, v)| (k.to_string(), v.to_string())),
|
||||
),
|
||||
});
|
||||
|
||||
Ok(types::RouterData {
|
||||
status: enums::AttemptStatus::foreign_from((item.response.status, None)),
|
||||
response: Ok(types::PaymentsResponseData::TransactionResponse {
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
|
||||
//TODO: Add redirection details here
|
||||
redirection_data: None,
|
||||
redirect: false,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
redirect: redirection_data.is_some(),
|
||||
redirection_data,
|
||||
mandate_reference: None,
|
||||
}),
|
||||
..item.data
|
||||
@ -284,7 +299,6 @@ impl TryFrom<types::PaymentsCancelResponseRouterData<PaymentVoidResponse>>
|
||||
resource_id: types::ResponseId::ConnectorTransactionId(response.action_id.clone()),
|
||||
redirect: false,
|
||||
redirection_data: None,
|
||||
// TODO: Implement mandate fetch for other connectors
|
||||
mandate_reference: None,
|
||||
}),
|
||||
status: response.into(),
|
||||
|
||||
@ -160,7 +160,7 @@ impl
|
||||
types::PaymentsResponseData,
|
||||
> for Klarna
|
||||
{
|
||||
// TODO: Critical Implement
|
||||
// Not Implemented(R)
|
||||
}
|
||||
|
||||
impl
|
||||
|
||||
@ -10,7 +10,10 @@ use self::transformers as stripe;
|
||||
use crate::{
|
||||
configs::settings,
|
||||
consts,
|
||||
core::errors::{self, CustomResult},
|
||||
core::{
|
||||
errors::{self, CustomResult},
|
||||
payments,
|
||||
},
|
||||
db::StorageInterface,
|
||||
headers, logger, services,
|
||||
types::{
|
||||
@ -606,7 +609,6 @@ impl
|
||||
reason: None,
|
||||
})
|
||||
}
|
||||
// TODO CRITICAL: Implement for POC
|
||||
}
|
||||
|
||||
impl api::Refund for Stripe {}
|
||||
@ -755,7 +757,6 @@ impl services::ConnectorIntegration<api::RSync, types::RefundsData, types::Refun
|
||||
Ok(Some(
|
||||
services::RequestBuilder::new()
|
||||
.method(services::Method::Post)
|
||||
// TODO: [ORCA-346] Requestbuilder needs &str migrate get_url to send &str instead of owned string
|
||||
.url(&types::RefundSyncType::get_url(self, req, connectors)?)
|
||||
.headers(types::RefundSyncType::get_headers(self, req)?)
|
||||
.header(headers::X_ROUTER, "test")
|
||||
@ -946,13 +947,10 @@ impl services::ConnectorRedirectResponse for Stripe {
|
||||
.into_report()
|
||||
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
|
||||
|
||||
if query.redirect_status.is_some() {
|
||||
//TODO: Map the redirect status of StripeRedirectResponse to AttemptStatus
|
||||
Ok(crate::core::payments::CallConnectorAction::StatusUpdate(
|
||||
types::storage::enums::AttemptStatus::Pending,
|
||||
))
|
||||
} else {
|
||||
Ok(crate::core::payments::CallConnectorAction::Trigger)
|
||||
}
|
||||
Ok(query
|
||||
.redirect_status
|
||||
.map_or(payments::CallConnectorAction::Trigger, |status| {
|
||||
payments::CallConnectorAction::StatusUpdate(status.into())
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +348,6 @@ impl<F, T>
|
||||
fn try_from(
|
||||
item: types::ResponseRouterData<F, PaymentIntentResponse, T, types::PaymentsResponseData>,
|
||||
) -> Result<Self, Self::Error> {
|
||||
// Redirect form not used https://juspay.atlassian.net/browse/ORCA-301
|
||||
let redirection_data = item.response.next_action.as_ref().map(
|
||||
|StripeNextActionResponse::RedirectToUrl(response)| {
|
||||
let mut base_url = response.url.clone();
|
||||
@ -507,28 +506,23 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for RefundRequest {
|
||||
|
||||
// Type definition for Stripe Refund Response
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[derive(Default, Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum RefundStatus {
|
||||
Succeeded,
|
||||
Failed,
|
||||
Processing,
|
||||
}
|
||||
|
||||
// Default should be Processing
|
||||
impl Default for RefundStatus {
|
||||
fn default() -> Self {
|
||||
RefundStatus::Processing
|
||||
}
|
||||
#[default]
|
||||
Pending,
|
||||
RequiresAction,
|
||||
}
|
||||
|
||||
impl From<self::RefundStatus> for enums::RefundStatus {
|
||||
fn from(item: self::RefundStatus) -> Self {
|
||||
match item {
|
||||
self::RefundStatus::Succeeded => enums::RefundStatus::Success,
|
||||
self::RefundStatus::Failed => enums::RefundStatus::Failure,
|
||||
self::RefundStatus::Processing => enums::RefundStatus::Pending,
|
||||
//TODO: Review mapping
|
||||
self::RefundStatus::Succeeded => Self::Success,
|
||||
self::RefundStatus::Failed => Self::Failure,
|
||||
self::RefundStatus::Pending => Self::Pending,
|
||||
self::RefundStatus::RequiresAction => Self::ManualReview,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -617,7 +611,7 @@ pub struct StripeRedirectResponse {
|
||||
pub payment_intent: String,
|
||||
pub payment_intent_client_secret: String,
|
||||
pub source_redirect_slug: Option<String>,
|
||||
pub redirect_status: Option<String>,
|
||||
pub redirect_status: Option<StripePaymentStatus>,
|
||||
pub source_type: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user