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

fix(router): make payment_instrument optional (#4389)

AkshayaFoiger450dd0fe0d7c
diff --git a/crates/router/src/connector/bankofamerica/transformers.rs b/crates/router/src/connector/bankofamerica/transformers.rs
index d8a5f8af73..5eca31278a 100644
--- a/crates/router/src/connector/bankofamerica/transformers.rs
+++ b/crates/router/src/connector/bankofamerica/transformers.rs
@@ -363,7 +363,9 @@ impl<F, T>
BankOfAmericaSetupMandatesResponse::ClientReferenceInformation(info_response) => {
let mandate_reference = info_response.token_information.clone().map(|token_info| {
types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
+ connector_mandate_id: token_info
+ .payment_instrument
+ .map(|payment_instrument| payment_instrument.id.expose()),
payment_method_id: None,
}
});
@@ -1274,7 +1276,7 @@ pub struct BankOfAmericaClientReferenceResponse {
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BankOfAmericaTokenInformation {
- payment_instrument: BankOfAmericaPaymentInstrument,
+ payment_instrument: Option<BankOfAmericaPaymentInstrument>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -1374,7 +1376,9 @@ fn get_payment_response(
.token_information
.clone()
.map(|token_info| types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
+ connector_mandate_id: token_info
+ .payment_instrument
+ .map(|payment_instrument| payment_instrument.id.expose()),
payment_method_id: None,
});
diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs
index 14e2ba76c0..338048b878 100644
--- a/crates/router/src/connector/cybersource/transformers.rs
+++ b/crates/router/src/connector/cybersource/transformers.rs
@@ -1653,7 +1653,7 @@ pub struct ClientRiskInformationRules {
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CybersourceTokenInformation {
- payment_instrument: CybersoucrePaymentInstrument,
+ payment_instrument: Option<CybersoucrePaymentInstrument>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
@@ -1748,7 +1748,9 @@ fn get_payment_response(
.token_information
.clone()
.map(|token_info| types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
+ connector_mandate_id: token_info
+ .payment_instrument
+ .map(|payment_instrument| payment_instrument.id.expose()),
payment_method_id: None,
});
Ok(types::PaymentsResponseData::TransactionResponse {
@@ -2397,7 +2399,9 @@ impl<F, T>
CybersourceSetupMandatesResponse::ClientReferenceInformation(info_response) => {
let mandate_reference = info_response.token_information.clone().map(|token_info| {
types::MandateReference {
- connector_mandate_id: Some(token_info.payment_instrument.id.expose()),
+ connector_mandate_id: token_info
+ .payment_instrument
+ .map(|payment_instrument| payment_instrument.id.expose()),
payment_method_id: None,
}
});