Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [SHIFT4] Pass metadata to connector (#9254)

DEEPANSHU BANSALbcfb13eec06f
diff --git a/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs b/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs
index eeaf340e10..98793e691f 100644
--- a/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/shift4/transformers.rs
@@ -43,6 +43,7 @@ trait Shift4AuthorizePreprocessingCommon {
fn get_email_optional(&self) -> Option<pii::Email>;
fn get_complete_authorize_url(&self) -> Option<String>;
fn get_currency_required(&self) -> Result<enums::Currency, Error>;
+ fn get_metadata(&self) -> Result<Option<serde_json::Value>, Error>;
fn get_payment_method_data_required(&self) -> Result<PaymentMethodData, Error>;
}
@@ -88,6 +89,12 @@ impl Shift4AuthorizePreprocessingCommon for PaymentsAuthorizeData {
fn get_router_return_url(&self) -> Option<String> {
self.router_return_url.clone()
}
+
+ fn get_metadata(
+ &self,
+ ) -> Result<Option<serde_json::Value>, error_stack::Report<errors::ConnectorError>> {
+ Ok(self.metadata.clone())
+ }
}
impl Shift4AuthorizePreprocessingCommon for PaymentsPreProcessingData {
@@ -117,12 +124,18 @@ impl Shift4AuthorizePreprocessingCommon for PaymentsPreProcessingData {
fn get_router_return_url(&self) -> Option<String> {
self.router_return_url.clone()
}
+ fn get_metadata(
+ &self,
+ ) -> Result<Option<serde_json::Value>, error_stack::Report<errors::ConnectorError>> {
+ Ok(None)
+ }
}
#[derive(Debug, Serialize)]
pub struct Shift4PaymentsRequest {
amount: MinorUnit,
currency: enums::Currency,
captured: bool,
+ metadata: Option<serde_json::Value>,
#[serde(flatten)]
payment_method: Shift4PaymentMethod,
}
@@ -275,11 +288,13 @@ where
let submit_for_settlement = item.router_data.request.is_automatic_capture()?;
let amount = item.amount.to_owned();
let currency = item.router_data.request.get_currency_required()?;
+ let metadata = item.router_data.request.get_metadata()?;
let payment_method = Shift4PaymentMethod::try_from(item.router_data)?;
Ok(Self {
amount,
currency,
captured: submit_for_settlement,
+ metadata,
payment_method,
})
}
@@ -641,9 +656,11 @@ impl<T> TryFrom<&Shift4RouterData<&RouterData<T, CompleteAuthorizeData, Payments
Some(PaymentMethodData::Card(_)) => {
let card_token: Shift4CardToken =
to_connector_meta(item.router_data.request.connector_meta.clone())?;
+ let metadata = item.router_data.request.metadata.clone();
Ok(Self {
amount: item.amount.to_owned(),
currency: item.router_data.request.currency,
+ metadata,
payment_method: Shift4PaymentMethod::CardsNon3DSRequest(Box::new(
CardsNon3DSRequest {
card: CardPayment::CardToken(card_token.id),