Skip to content

Commit

Permalink
refactor(connector): make the original_authorized_amount optional f…
Browse files Browse the repository at this point in the history
…or MITs with `connector_mandate_details` (#5311)
  • Loading branch information
ShankarSinghC authored Jul 19, 2024
1 parent eb01680 commit a8e2f3e
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,24 +589,38 @@ impl
Some(payments::MandateReferenceId::ConnectorMandateId(_)) => {
let original_amount = item
.router_data
.get_recurring_mandate_payment_data()?
.get_original_payment_amount()?;
.recurring_mandate_payment_data
.as_ref()
.and_then(|recurring_mandate_payment_data| {
recurring_mandate_payment_data.original_payment_authorized_amount
});

let original_currency = item
.router_data
.get_recurring_mandate_payment_data()?
.get_original_payment_currency()?;
.recurring_mandate_payment_data
.as_ref()
.and_then(|recurring_mandate_payment_data| {
recurring_mandate_payment_data.original_payment_authorized_currency
});

let original_authorized_amount = match original_amount.zip(original_currency) {
Some((original_amount, original_currency)) => {
Some(utils::get_amount_as_string(
&api::CurrencyUnit::Base,
original_amount,
original_currency,
)?)
}
None => None,
};
(
None,
None,
Some(CybersourceAuthorizationOptions {
initiator: None,
merchant_intitiated_transaction: Some(MerchantInitiatedTransaction {
reason: None,
original_authorized_amount: Some(utils::get_amount_as_string(
&api::CurrencyUnit::Base,
original_amount,
original_currency,
)?),
original_authorized_amount,
previous_transaction_id: None,
}),
}),
Expand All @@ -618,7 +632,8 @@ impl
.map(|network| network.to_lowercase())
.as_deref()
{
Some("discover") => {
//This is to make original_authorized_amount mandatory for discover card networks in NetworkMandateId flow
Some("004") => {
let original_amount = Some(
item.router_data
.get_recurring_mandate_payment_data()?
Expand Down Expand Up @@ -653,12 +668,11 @@ impl
(original_amount, original_currency)
}
};

let original_authorized_amount = match (original_amount, original_currency) {
(Some(original_amount), Some(original_currency)) => Some(
let original_authorized_amount = match original_amount.zip(original_currency) {
Some((original_amount, original_currency)) => Some(
utils::to_currency_base_unit(original_amount, original_currency)?,
),
_ => None,
None => None,
};
commerce_indicator = "recurring".to_string();
(
Expand Down

0 comments on commit a8e2f3e

Please sign in to comment.