Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connector): [BOA/Cyb] Include merchant metadata in capture and void requests #3313

Merged
merged 5 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions crates/router/src/connector/bankofamerica/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ pub struct OrderInformation {
pub struct BankOfAmericaCaptureRequest {
order_information: OrderInformation,
client_reference_information: ClientReferenceInformation,
#[serde(skip_serializing_if = "Option::is_none")]
merchant_defined_information: Option<Vec<MerchantDefinedInformation>>,
}

impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCaptureRouterData>>
Expand All @@ -1039,6 +1041,10 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCaptureRouterData>>
fn try_from(
value: &BankOfAmericaRouterData<&types::PaymentsCaptureRouterData>,
) -> Result<Self, Self::Error> {
let merchant_defined_information =
value.router_data.request.metadata.clone().map(|metadata| {
Vec::<MerchantDefinedInformation>::foreign_from(metadata.peek().to_owned())
});
Ok(Self {
order_information: OrderInformation {
amount_details: Amount {
Expand All @@ -1049,6 +1055,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCaptureRouterData>>
client_reference_information: ClientReferenceInformation {
code: Some(value.router_data.connector_request_reference_id.clone()),
},
merchant_defined_information,
})
}
}
Expand All @@ -1058,6 +1065,9 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCaptureRouterData>>
pub struct BankOfAmericaVoidRequest {
client_reference_information: ClientReferenceInformation,
reversal_information: ReversalInformation,
#[serde(skip_serializing_if = "Option::is_none")]
merchant_defined_information: Option<Vec<MerchantDefinedInformation>>,
// The connector documentation does not mention the merchantDefinedInformation field for Void requests. But this has been still added because it works!
}

#[derive(Debug, Serialize)]
Expand All @@ -1074,6 +1084,10 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCancelRouterData>>
fn try_from(
value: &BankOfAmericaRouterData<&types::PaymentsCancelRouterData>,
) -> Result<Self, Self::Error> {
let merchant_defined_information =
value.router_data.request.metadata.clone().map(|metadata| {
Vec::<MerchantDefinedInformation>::foreign_from(metadata.peek().to_owned())
});
Ok(Self {
client_reference_information: ClientReferenceInformation {
code: Some(value.router_data.connector_request_reference_id.clone()),
Expand All @@ -1096,6 +1110,7 @@ impl TryFrom<&BankOfAmericaRouterData<&types::PaymentsCancelRouterData>>
field_name: "Cancellation Reason",
})?,
},
merchant_defined_information,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsCaptureD
None => None,
},
browser_info,
metadata: payment_data.payment_intent.metadata,
})
}
}
Expand Down Expand Up @@ -1255,6 +1256,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsCancelDa
cancellation_reason: payment_data.payment_attempt.cancellation_reason,
connector_meta: payment_data.payment_attempt.connector_metadata,
browser_info,
metadata: payment_data.payment_intent.metadata,
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/router/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ pub struct PaymentsCaptureData {
pub multiple_capture_data: Option<MultipleCaptureRequestData>,
pub connector_meta: Option<serde_json::Value>,
pub browser_info: Option<BrowserInformation>,
pub metadata: Option<pii::SecretSerdeValue>,
deepanshu-iiitu marked this conversation as resolved.
Show resolved Hide resolved
// This metadata is used to store the metadata shared during the payment intent request.
}

#[derive(Debug, Clone, Default)]
Expand Down Expand Up @@ -533,6 +535,8 @@ pub struct PaymentsCancelData {
pub cancellation_reason: Option<String>,
pub connector_meta: Option<serde_json::Value>,
pub browser_info: Option<BrowserInformation>,
pub metadata: Option<pii::SecretSerdeValue>,
deepanshu-iiitu marked this conversation as resolved.
Show resolved Hide resolved
// This metadata is used to store the metadata shared during the payment intent request.
}

#[derive(Debug, Default, Clone)]
Expand Down
Loading