Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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),
Expand Down
Loading