mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
fix: request amount fix for trustpay apple pay (#1837)
Co-authored-by: Abhishek Marrivagu <68317979+Abhicodes-crypto@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a1cb255765
commit
3da69f3ee1
@ -849,23 +849,33 @@ impl TryFrom<&types::PaymentsPreProcessingRouterData> for TrustpayCreateIntentRe
|
||||
.as_ref()
|
||||
.map(|pmt| matches!(pmt, diesel_models::enums::PaymentMethodType::GooglePay));
|
||||
|
||||
let request_amount = item
|
||||
.request
|
||||
.amount
|
||||
.get_required_value("amount")
|
||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "amount",
|
||||
})?;
|
||||
|
||||
let currency = item
|
||||
.request
|
||||
.currency
|
||||
.get_required_value("currency")
|
||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "currency",
|
||||
})?;
|
||||
|
||||
let amount = format!(
|
||||
"{:.2}",
|
||||
utils::to_currency_base_unit(request_amount, currency)?
|
||||
.parse::<f64>()
|
||||
.into_report()
|
||||
.change_context(errors::ConnectorError::RequestEncodingFailed)?
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
amount: item
|
||||
.request
|
||||
.amount
|
||||
.get_required_value("amount")
|
||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "amount",
|
||||
})?
|
||||
.to_string(),
|
||||
currency: item
|
||||
.request
|
||||
.currency
|
||||
.get_required_value("currency")
|
||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||
field_name: "currency",
|
||||
})?
|
||||
.to_string(),
|
||||
amount,
|
||||
currency: currency.to_string(),
|
||||
init_apple_pay: is_apple_pay,
|
||||
init_google_pay: is_google_pay,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user