refactor(core): make attempt id as mandatory in router_data (#604)

This commit is contained in:
Narayan Bhat
2023-02-19 19:31:47 +05:30
committed by GitHub
parent 66563595df
commit 626e467e54
10 changed files with 12 additions and 23 deletions

View File

@ -31,7 +31,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for GlobalpayPaymentsRequest {
account_name,
amount: Some(item.request.amount.to_string()),
currency: item.request.currency.to_string(),
reference: item.get_attempt_id()?,
reference: item.attempt_id.to_string(),
country: item.get_billing_country()?,
capture_mode: item.request.capture_method.map(|f| match f {
enums::CaptureMethod::Manual => requests::CaptureMode::Later,

View File

@ -35,7 +35,6 @@ impl AccessTokenRequestInfo for types::RefreshTokenRouterData {
}
pub trait PaymentsRequestData {
fn get_attempt_id(&self) -> Result<String, Error>;
fn get_billing(&self) -> Result<&api::Address, Error>;
fn get_billing_country(&self) -> Result<String, Error>;
fn get_billing_phone(&self) -> Result<&api::PhoneDetails, Error>;
@ -57,12 +56,6 @@ impl RefundsRequestData for types::RefundsData {
}
impl PaymentsRequestData for types::PaymentsAuthorizeRouterData {
fn get_attempt_id(&self) -> Result<String, Error> {
self.attempt_id
.clone()
.ok_or_else(missing_field_err("attempt_id"))
}
fn get_billing_country(&self) -> Result<String, Error> {
self.address
.billing

View File

@ -91,11 +91,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for WorldpayPaymentsRequest {
entity: item.payment_id.clone(),
..Default::default()
},
transaction_reference: item.attempt_id.clone().ok_or(
errors::ConnectorError::MissingRequiredField {
field_name: "attempt_id",
},
)?,
transaction_reference: item.attempt_id.clone(),
channel: None,
customer: None,
})

View File

@ -80,7 +80,7 @@ where
merchant_id: merchant_account.merchant_id.clone(),
connector: merchant_connector_account.connector_name,
payment_id: payment_data.payment_attempt.payment_id.clone(),
attempt_id: Some(payment_data.payment_attempt.attempt_id.clone()),
attempt_id: payment_data.payment_attempt.attempt_id.clone(),
status: payment_data.payment_attempt.status,
payment_method,
connector_auth_type: auth_type,

View File

@ -53,7 +53,7 @@ pub async fn construct_refund_router_data<'a, F>(
merchant_id: merchant_account.merchant_id.clone(),
connector: merchant_connector_account.connector_name,
payment_id: payment_attempt.payment_id.clone(),
attempt_id: Some(payment_attempt.attempt_id.clone()),
attempt_id: payment_attempt.attempt_id.clone(),
status,
payment_method: payment_method_type,
connector_auth_type: auth_type,

View File

@ -76,7 +76,7 @@ pub struct RouterData<Flow, Request, Response> {
pub merchant_id: String,
pub connector: String,
pub payment_id: String,
pub attempt_id: Option<String>,
pub attempt_id: String,
pub status: storage_enums::AttemptStatus,
pub payment_method: storage_enums::PaymentMethodType,
pub connector_auth_type: ConnectorAuthType,

View File

@ -22,7 +22,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
merchant_id: String::from("aci"),
connector: "aci".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
auth_type: enums::AuthenticationType::NoThreeDs,
payment_method: enums::PaymentMethodType::Card,
@ -72,7 +72,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
merchant_id: String::from("aci"),
connector: "aci".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: None,
payment_method: enums::PaymentMethodType::Card,

View File

@ -22,7 +22,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
merchant_id: String::from("authorizedotnet"),
connector: "authorizedotnet".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: None,
payment_method: enums::PaymentMethodType::Card,
@ -73,7 +73,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
merchant_id: String::from("authorizedotnet"),
connector: "authorizedotnet".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: None,
auth_type: enums::AuthenticationType::NoThreeDs,

View File

@ -19,7 +19,7 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {
merchant_id: "checkout".to_string(),
connector: "checkout".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: None,
auth_type: enums::AuthenticationType::NoThreeDs,
@ -70,7 +70,7 @@ fn construct_refund_router_data<F>() -> types::RefundsRouterData<F> {
merchant_id: "checkout".to_string(),
connector: "checkout".to_string(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: None,
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: None,
payment_method: enums::PaymentMethodType::Card,

View File

@ -348,7 +348,7 @@ pub trait ConnectorActions: Connector {
merchant_id: self.get_name(),
connector: self.get_name(),
payment_id: uuid::Uuid::new_v4().to_string(),
attempt_id: Some(uuid::Uuid::new_v4().to_string()),
attempt_id: uuid::Uuid::new_v4().to_string(),
status: enums::AttemptStatus::default(),
router_return_url: info.clone().and_then(|a| a.router_return_url),
auth_type: info