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,