Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: request amount fix for trustpay apple pay #1837

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions crates/router/src/connector/trustpay/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Preprocessing amount and currency need not to be optional fields. Please check this if any changes required take it in separate PR

.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,
})
Expand Down
Loading