mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +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 {
|
||||
type Error = 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 {
|
||||
order: OrderFulfillment {
|
||||
id: item.attempt_id.clone(),
|
||||
@ -504,12 +519,8 @@ impl TryFrom<&frm_types::FrmFulfillmentRouterData> for RiskifiedFulfillmentReque
|
||||
.ok_or(errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "tracking_company",
|
||||
})?,
|
||||
tracking_number: item.request.fulfillment_req.tracking_number.clone().ok_or(
|
||||
errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "tracking_number",
|
||||
},
|
||||
)?,
|
||||
tracking_url: item.request.fulfillment_req.tracking_url.clone(),
|
||||
tracking_number,
|
||||
tracking_url,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -225,6 +225,7 @@ pub struct Transactions {
|
||||
payment_method: storage_enums::PaymentMethod,
|
||||
amount: i64,
|
||||
currency: storage_enums::Currency,
|
||||
gateway: Option<String>,
|
||||
}
|
||||
|
||||
#[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(),
|
||||
payment_method: item.payment_method,
|
||||
currency,
|
||||
gateway: item.request.connector.clone(),
|
||||
};
|
||||
Ok(Self {
|
||||
order_id: item.attempt_id.clone(),
|
||||
@ -377,6 +379,12 @@ pub struct Fulfillments {
|
||||
pub shipment_id: String,
|
||||
pub products: Option<Vec<Product>>,
|
||||
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)]
|
||||
@ -397,15 +405,9 @@ impl TryFrom<&frm_types::FrmFulfillmentRouterData> for FrmFulfillmentSignifydReq
|
||||
.request
|
||||
.fulfillment_req
|
||||
.fulfillment_status
|
||||
.clone()
|
||||
.map(|fulfillment_status| FulfillmentStatus::from(&fulfillment_status)),
|
||||
fulfillments: item
|
||||
.request
|
||||
.fulfillment_req
|
||||
.fulfillments
|
||||
.iter()
|
||||
.map(|f| Fulfillments::from(f.clone()))
|
||||
.collect(),
|
||||
.as_ref()
|
||||
.map(|fulfillment_status| FulfillmentStatus::from(&fulfillment_status.clone())),
|
||||
fulfillments: Vec::<Fulfillments>::from(&item.request.fulfillment_req),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -421,15 +423,26 @@ impl From<&core_types::FulfillmentStatus> for FulfillmentStatus {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<core_types::Fulfillments> for Fulfillments {
|
||||
fn from(fulfillment: core_types::Fulfillments) -> Self {
|
||||
Self {
|
||||
shipment_id: fulfillment.shipment_id,
|
||||
products: fulfillment
|
||||
.products
|
||||
.map(|products| products.iter().map(|p| Product::from(p.clone())).collect()),
|
||||
destination: Destination::from(fulfillment.destination),
|
||||
}
|
||||
impl From<&core_types::FrmFulfillmentRequest> for Vec<Fulfillments> {
|
||||
fn from(fulfillment_req: &core_types::FrmFulfillmentRequest) -> Self {
|
||||
fulfillment_req
|
||||
.fulfillments
|
||||
.iter()
|
||||
.map(|fulfillment| Fulfillments {
|
||||
shipment_id: fulfillment.shipment_id.clone(),
|
||||
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_message: self.payment_attempt.error_message.clone(),
|
||||
connector_transaction_id: self.payment_attempt.connector_transaction_id.clone(),
|
||||
connector: self.payment_attempt.connector.clone(),
|
||||
}, // self.order_details
|
||||
response: Ok(FraudCheckResponseData::TransactionResponse {
|
||||
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_message: router_data.request.error_message,
|
||||
connector_transaction_id: router_data.request.connector_transaction_id,
|
||||
connector: router_data.request.connector,
|
||||
}),
|
||||
response: FrmResponse::Transaction(router_data.response),
|
||||
}))
|
||||
|
||||
@ -129,10 +129,18 @@ pub struct FrmFulfillmentRequest {
|
||||
#[schema(max_length = 255, example = "fedex")]
|
||||
pub tracking_company: Option<String>,
|
||||
//tracking ID of the product
|
||||
#[schema(max_length = 255, example = "track_8327446667")]
|
||||
pub tracking_number: Option<String>,
|
||||
#[schema(example = r#"["track_8327446667", "track_8327446668"]"#)]
|
||||
pub tracking_numbers: Option<Vec<String>>,
|
||||
//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)]
|
||||
|
||||
@ -103,6 +103,8 @@ pub struct FraudCheckTransactionData {
|
||||
pub error_code: Option<String>,
|
||||
pub error_message: 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 =
|
||||
|
||||
Reference in New Issue
Block a user