mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
feat(FRM): add shipping details for signifyd (#4500)
This commit is contained in:
@ -484,6 +484,21 @@ pub struct FulfilmentData {
|
|||||||
impl TryFrom<&frm_types::FrmFulfillmentRouterData> for RiskifiedFulfillmentRequest {
|
impl TryFrom<&frm_types::FrmFulfillmentRouterData> for RiskifiedFulfillmentRequest {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
fn try_from(item: &frm_types::FrmFulfillmentRouterData) -> Result<Self, Self::Error> {
|
fn try_from(item: &frm_types::FrmFulfillmentRouterData) -> Result<Self, Self::Error> {
|
||||||
|
let tracking_number = item
|
||||||
|
.request
|
||||||
|
.fulfillment_req
|
||||||
|
.tracking_numbers
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|numbers| numbers.first().cloned())
|
||||||
|
.ok_or(errors::ConnectorError::MissingRequiredField {
|
||||||
|
field_name: "tracking_number",
|
||||||
|
})?;
|
||||||
|
let tracking_url = item
|
||||||
|
.request
|
||||||
|
.fulfillment_req
|
||||||
|
.tracking_urls
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|urls| urls.first().cloned().map(|url| url.to_string()));
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
order: OrderFulfillment {
|
order: OrderFulfillment {
|
||||||
id: item.attempt_id.clone(),
|
id: item.attempt_id.clone(),
|
||||||
@ -504,12 +519,8 @@ impl TryFrom<&frm_types::FrmFulfillmentRouterData> for RiskifiedFulfillmentReque
|
|||||||
.ok_or(errors::ConnectorError::MissingRequiredField {
|
.ok_or(errors::ConnectorError::MissingRequiredField {
|
||||||
field_name: "tracking_company",
|
field_name: "tracking_company",
|
||||||
})?,
|
})?,
|
||||||
tracking_number: item.request.fulfillment_req.tracking_number.clone().ok_or(
|
tracking_number,
|
||||||
errors::ConnectorError::MissingRequiredField {
|
tracking_url,
|
||||||
field_name: "tracking_number",
|
|
||||||
},
|
|
||||||
)?,
|
|
||||||
tracking_url: item.request.fulfillment_req.tracking_url.clone(),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -225,6 +225,7 @@ pub struct Transactions {
|
|||||||
payment_method: storage_enums::PaymentMethod,
|
payment_method: storage_enums::PaymentMethod,
|
||||||
amount: i64,
|
amount: i64,
|
||||||
currency: storage_enums::Currency,
|
currency: storage_enums::Currency,
|
||||||
|
gateway: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Eq, PartialEq)]
|
#[derive(Debug, Serialize, Eq, PartialEq)]
|
||||||
@ -256,6 +257,7 @@ impl TryFrom<&frm_types::FrmTransactionRouterData> for SignifydPaymentsTransacti
|
|||||||
gateway_status_code: GatewayStatusCode::from(item.status).to_string(),
|
gateway_status_code: GatewayStatusCode::from(item.status).to_string(),
|
||||||
payment_method: item.payment_method,
|
payment_method: item.payment_method,
|
||||||
currency,
|
currency,
|
||||||
|
gateway: item.request.connector.clone(),
|
||||||
};
|
};
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
order_id: item.attempt_id.clone(),
|
order_id: item.attempt_id.clone(),
|
||||||
@ -377,6 +379,12 @@ pub struct Fulfillments {
|
|||||||
pub shipment_id: String,
|
pub shipment_id: String,
|
||||||
pub products: Option<Vec<Product>>,
|
pub products: Option<Vec<Product>>,
|
||||||
pub destination: Destination,
|
pub destination: Destination,
|
||||||
|
pub fulfillment_method: Option<String>,
|
||||||
|
pub carrier: Option<String>,
|
||||||
|
pub shipment_status: Option<String>,
|
||||||
|
pub tracking_urls: Option<Vec<String>>,
|
||||||
|
pub tracking_numbers: Option<Vec<String>>,
|
||||||
|
pub shipped_at: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
|
#[derive(Default, Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
|
||||||
@ -397,15 +405,9 @@ impl TryFrom<&frm_types::FrmFulfillmentRouterData> for FrmFulfillmentSignifydReq
|
|||||||
.request
|
.request
|
||||||
.fulfillment_req
|
.fulfillment_req
|
||||||
.fulfillment_status
|
.fulfillment_status
|
||||||
.clone()
|
.as_ref()
|
||||||
.map(|fulfillment_status| FulfillmentStatus::from(&fulfillment_status)),
|
.map(|fulfillment_status| FulfillmentStatus::from(&fulfillment_status.clone())),
|
||||||
fulfillments: item
|
fulfillments: Vec::<Fulfillments>::from(&item.request.fulfillment_req),
|
||||||
.request
|
|
||||||
.fulfillment_req
|
|
||||||
.fulfillments
|
|
||||||
.iter()
|
|
||||||
.map(|f| Fulfillments::from(f.clone()))
|
|
||||||
.collect(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,15 +423,26 @@ impl From<&core_types::FulfillmentStatus> for FulfillmentStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<core_types::Fulfillments> for Fulfillments {
|
impl From<&core_types::FrmFulfillmentRequest> for Vec<Fulfillments> {
|
||||||
fn from(fulfillment: core_types::Fulfillments) -> Self {
|
fn from(fulfillment_req: &core_types::FrmFulfillmentRequest) -> Self {
|
||||||
Self {
|
fulfillment_req
|
||||||
shipment_id: fulfillment.shipment_id,
|
.fulfillments
|
||||||
products: fulfillment
|
.iter()
|
||||||
.products
|
.map(|fulfillment| Fulfillments {
|
||||||
.map(|products| products.iter().map(|p| Product::from(p.clone())).collect()),
|
shipment_id: fulfillment.shipment_id.clone(),
|
||||||
destination: Destination::from(fulfillment.destination),
|
products: fulfillment
|
||||||
}
|
.products
|
||||||
|
.as_ref()
|
||||||
|
.map(|products| products.iter().map(|p| Product::from(p.clone())).collect()),
|
||||||
|
destination: Destination::from(fulfillment.destination.clone()),
|
||||||
|
tracking_urls: fulfillment_req.tracking_urls.clone(),
|
||||||
|
tracking_numbers: fulfillment_req.tracking_numbers.clone(),
|
||||||
|
fulfillment_method: fulfillment_req.fulfillment_method.clone(),
|
||||||
|
carrier: fulfillment_req.carrier.clone(),
|
||||||
|
shipment_status: fulfillment_req.shipment_status.clone(),
|
||||||
|
shipped_at: fulfillment_req.shipped_at.clone(),
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,7 @@ impl
|
|||||||
error_code: self.payment_attempt.error_code.clone(),
|
error_code: self.payment_attempt.error_code.clone(),
|
||||||
error_message: self.payment_attempt.error_message.clone(),
|
error_message: self.payment_attempt.error_message.clone(),
|
||||||
connector_transaction_id: self.payment_attempt.connector_transaction_id.clone(),
|
connector_transaction_id: self.payment_attempt.connector_transaction_id.clone(),
|
||||||
|
connector: self.payment_attempt.connector.clone(),
|
||||||
}, // self.order_details
|
}, // self.order_details
|
||||||
response: Ok(FraudCheckResponseData::TransactionResponse {
|
response: Ok(FraudCheckResponseData::TransactionResponse {
|
||||||
resource_id: ResponseId::ConnectorTransactionId("".to_string()),
|
resource_id: ResponseId::ConnectorTransactionId("".to_string()),
|
||||||
|
|||||||
@ -170,6 +170,7 @@ impl<F: Send + Clone> Domain<F> for FraudCheckPre {
|
|||||||
error_code: router_data.request.error_code,
|
error_code: router_data.request.error_code,
|
||||||
error_message: router_data.request.error_message,
|
error_message: router_data.request.error_message,
|
||||||
connector_transaction_id: router_data.request.connector_transaction_id,
|
connector_transaction_id: router_data.request.connector_transaction_id,
|
||||||
|
connector: router_data.request.connector,
|
||||||
}),
|
}),
|
||||||
response: FrmResponse::Transaction(router_data.response),
|
response: FrmResponse::Transaction(router_data.response),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@ -129,10 +129,18 @@ pub struct FrmFulfillmentRequest {
|
|||||||
#[schema(max_length = 255, example = "fedex")]
|
#[schema(max_length = 255, example = "fedex")]
|
||||||
pub tracking_company: Option<String>,
|
pub tracking_company: Option<String>,
|
||||||
//tracking ID of the product
|
//tracking ID of the product
|
||||||
#[schema(max_length = 255, example = "track_8327446667")]
|
#[schema(example = r#"["track_8327446667", "track_8327446668"]"#)]
|
||||||
pub tracking_number: Option<String>,
|
pub tracking_numbers: Option<Vec<String>>,
|
||||||
//tracking_url for tracking the product
|
//tracking_url for tracking the product
|
||||||
pub tracking_url: Option<String>,
|
pub tracking_urls: Option<Vec<String>>,
|
||||||
|
// The name of the Shipper.
|
||||||
|
pub carrier: Option<String>,
|
||||||
|
// Fulfillment method for the shipment.
|
||||||
|
pub fulfillment_method: Option<String>,
|
||||||
|
// Statuses to indicate shipment state.
|
||||||
|
pub shipment_status: Option<String>,
|
||||||
|
// The date and time items are ready to be shipped.
|
||||||
|
pub shipped_at: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
|
#[derive(Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
|
||||||
|
|||||||
@ -103,6 +103,8 @@ pub struct FraudCheckTransactionData {
|
|||||||
pub error_code: Option<String>,
|
pub error_code: Option<String>,
|
||||||
pub error_message: Option<String>,
|
pub error_message: Option<String>,
|
||||||
pub connector_transaction_id: Option<String>,
|
pub connector_transaction_id: Option<String>,
|
||||||
|
//The name of the payment gateway or financial institution that processed the transaction.
|
||||||
|
pub connector: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type FrmFulfillmentRouterData =
|
pub type FrmFulfillmentRouterData =
|
||||||
|
|||||||
Reference in New Issue
Block a user