Skip to content

Commit

Permalink
refactor: remove setter and duplicate db call
Browse files Browse the repository at this point in the history
  • Loading branch information
Narayanbhat166 committed May 10, 2024
1 parent f4c5678 commit 372123c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
4 changes: 1 addition & 3 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2766,9 +2766,7 @@ impl Address {

// used by customers also, could be moved outside
/// Address details
#[derive(
Clone, Default, Debug, Eq, serde::Deserialize, serde::Serialize, PartialEq, ToSchema, Setter,
)]
#[derive(Clone, Default, Debug, Eq, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct AddressDetails {
/// The address city
Expand Down
25 changes: 12 additions & 13 deletions crates/router/src/core/payments/operations/payment_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>

helpers::authenticate_client_secret(request.client_secret.as_ref(), &payment_intent)?;

payment_intent = db
.find_payment_intent_by_payment_id_merchant_id(&payment_id, merchant_id, storage_scheme)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

payment_intent.order_details = request
.get_order_details_as_value()
.change_context(errors::ApiErrorResponse::InternalServerError)
Expand Down Expand Up @@ -351,16 +346,20 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
(Box::new(self), amount)
};

payment_intent.status = match request.payment_method_data.as_ref() {
Some(_) => {
if request.confirm.unwrap_or(false) {
payment_intent.status
} else {
storage_enums::IntentStatus::RequiresConfirmation
}
payment_intent.status = if request
.payment_method_data
.as_ref()
.is_some_and(|payment_method_data| payment_method_data.payment_method_data.is_some())
{
if request.confirm.unwrap_or(false) {
payment_intent.status
} else {
storage_enums::IntentStatus::RequiresConfirmation
}
None => storage_enums::IntentStatus::RequiresPaymentMethod,
} else {
storage_enums::IntentStatus::RequiresPaymentMethod
};

payment_intent.request_external_three_ds_authentication = request
.request_external_three_ds_authentication
.or(payment_intent.request_external_three_ds_authentication);
Expand Down

0 comments on commit 372123c

Please sign in to comment.