Skip to content

Commit

Permalink
refactor(connector): make the original_authorized_amount mandatory on…
Browse files Browse the repository at this point in the history
…ly for discover cards
  • Loading branch information
ShankarSinghC committed Jul 14, 2024
1 parent bcb3450 commit bb04974
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,24 +588,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 Down Expand Up @@ -652,12 +666,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 bb04974

Please sign in to comment.