mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +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()
|
.as_ref()
|
||||||
.map(|pmt| matches!(pmt, diesel_models::enums::PaymentMethodType::GooglePay));
|
.map(|pmt| matches!(pmt, diesel_models::enums::PaymentMethodType::GooglePay));
|
||||||
|
|
||||||
Ok(Self {
|
let request_amount = item
|
||||||
amount: item
|
|
||||||
.request
|
.request
|
||||||
.amount
|
.amount
|
||||||
.get_required_value("amount")
|
.get_required_value("amount")
|
||||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||||
field_name: "amount",
|
field_name: "amount",
|
||||||
})?
|
})?;
|
||||||
.to_string(),
|
|
||||||
currency: item
|
let currency = item
|
||||||
.request
|
.request
|
||||||
.currency
|
.currency
|
||||||
.get_required_value("currency")
|
.get_required_value("currency")
|
||||||
.change_context(errors::ConnectorError::MissingRequiredField {
|
.change_context(errors::ConnectorError::MissingRequiredField {
|
||||||
field_name: "currency",
|
field_name: "currency",
|
||||||
})?
|
})?;
|
||||||
.to_string(),
|
|
||||||
|
let amount = format!(
|
||||||
|
"{:.2}",
|
||||||
|
utils::to_currency_base_unit(request_amount, currency)?
|
||||||
|
.parse::<f64>()
|
||||||
|
.into_report()
|
||||||
|
.change_context(errors::ConnectorError::RequestEncodingFailed)?
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
amount,
|
||||||
|
currency: currency.to_string(),
|
||||||
init_apple_pay: is_apple_pay,
|
init_apple_pay: is_apple_pay,
|
||||||
init_google_pay: is_google_pay,
|
init_google_pay: is_google_pay,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user