Skip to content

Commit

Permalink
Merge branch 'main' into feat/profile_specific_fallback_routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aprabhat19 authored Nov 9, 2023
2 parents bd329c5 + 966369b commit 475a54e
Show file tree
Hide file tree
Showing 35 changed files with 155 additions and 979 deletions.
2 changes: 2 additions & 0 deletions crates/data_models/src/payments/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ pub enum PaymentAttemptUpdate {
connector_response_reference_id: Option<String>,
amount_capturable: Option<i64>,
updated_by: String,
authentication_data: Option<serde_json::Value>,
encoded_data: Option<String>,
},
UnresolvedResponseUpdate {
status: storage_enums::AttemptStatus,
Expand Down
122 changes: 0 additions & 122 deletions crates/diesel_models/src/connector_response.rs

This file was deleted.

9 changes: 0 additions & 9 deletions crates/diesel_models/src/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize};

use crate::{
address::{Address, AddressNew, AddressUpdateInternal},
connector_response::{ConnectorResponse, ConnectorResponseNew, ConnectorResponseUpdate},
errors,
payment_attempt::{PaymentAttempt, PaymentAttemptNew, PaymentAttemptUpdate},
payment_intent::{PaymentIntentNew, PaymentIntentUpdate},
Expand Down Expand Up @@ -51,7 +50,6 @@ pub enum Insertable {
PaymentIntent(PaymentIntentNew),
PaymentAttempt(PaymentAttemptNew),
Refund(RefundNew),
ConnectorResponse(ConnectorResponseNew),
Address(Box<AddressNew>),
ReverseLookUp(ReverseLookupNew),
}
Expand All @@ -62,16 +60,9 @@ pub enum Updateable {
PaymentIntentUpdate(PaymentIntentUpdateMems),
PaymentAttemptUpdate(PaymentAttemptUpdateMems),
RefundUpdate(RefundUpdateMems),
ConnectorResponseUpdate(ConnectorResponseUpdateMems),
AddressUpdate(Box<AddressUpdateMems>),
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ConnectorResponseUpdateMems {
pub orig: ConnectorResponse,
pub update_data: ConnectorResponseUpdate,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct AddressUpdateMems {
pub orig: Address,
Expand Down
10 changes: 5 additions & 5 deletions crates/diesel_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod business_profile;
pub mod capture;
pub mod cards_info;
pub mod configs;
pub mod connector_response;

pub mod customers;
pub mod dispute;
pub mod encryption;
Expand Down Expand Up @@ -44,10 +44,10 @@ use diesel_impl::{DieselArray, OptionalDieselArray};
pub type StorageResult<T> = error_stack::Result<T, errors::DatabaseError>;
pub type PgPooledConn = async_bb8_diesel::Connection<diesel::PgConnection>;
pub use self::{
address::*, api_keys::*, cards_info::*, configs::*, connector_response::*, customers::*,
dispute::*, ephemeral_key::*, events::*, file::*, locker_mock_up::*, mandate::*,
merchant_account::*, merchant_connector_account::*, payment_attempt::*, payment_intent::*,
payment_method::*, process_tracker::*, refund::*, reverse_lookup::*,
address::*, api_keys::*, cards_info::*, configs::*, customers::*, dispute::*, ephemeral_key::*,
events::*, file::*, locker_mock_up::*, mandate::*, merchant_account::*,
merchant_connector_account::*, payment_attempt::*, payment_intent::*, payment_method::*,
process_tracker::*, refund::*, reverse_lookup::*,
};

/// The types and implementations provided by this module are required for the schema generated by
Expand Down
6 changes: 6 additions & 0 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ pub enum PaymentAttemptUpdate {
connector_response_reference_id: Option<String>,
amount_capturable: Option<i64>,
updated_by: String,
authentication_data: Option<serde_json::Value>,
encoded_data: Option<String>,
},
UnresolvedResponseUpdate {
status: storage_enums::AttemptStatus,
Expand Down Expand Up @@ -478,6 +480,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
connector_response_reference_id,
amount_capturable,
updated_by,
authentication_data,
encoded_data,
} => Self {
status: Some(status),
connector,
Expand All @@ -494,6 +498,8 @@ impl From<PaymentAttemptUpdate> for PaymentAttemptUpdateInternal {
connector_response_reference_id,
amount_capturable,
updated_by,
authentication_data,
encoded_data,
..Default::default()
},
PaymentAttemptUpdate::ErrorUpdate {
Expand Down
2 changes: 1 addition & 1 deletion crates/diesel_models/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod business_profile;
mod capture;
pub mod cards_info;
pub mod configs;
pub mod connector_response;

pub mod customers;
pub mod dispute;
pub mod events;
Expand Down
26 changes: 0 additions & 26 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,6 @@ diesel::table! {
}
}

diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;

connector_response (id) {
id -> Int4,
#[max_length = 64]
payment_id -> Varchar,
#[max_length = 64]
merchant_id -> Varchar,
#[max_length = 64]
attempt_id -> Varchar,
created_at -> Timestamp,
modified_at -> Timestamp,
#[max_length = 64]
connector_name -> Nullable<Varchar>,
#[max_length = 128]
connector_transaction_id -> Nullable<Varchar>,
authentication_data -> Nullable<Json>,
encoded_data -> Nullable<Text>,
#[max_length = 32]
updated_by -> Varchar,
}
}

diesel::table! {
use diesel::sql_types::*;
use crate::enums::diesel_exports::*;
Expand Down Expand Up @@ -932,7 +907,6 @@ diesel::allow_tables_to_appear_in_same_query!(
captures,
cards_info,
configs,
connector_response,
customers,
dispute,
events,
Expand Down
13 changes: 0 additions & 13 deletions crates/drainer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ async fn drainer(
let payment_attempt = "payment_attempt";
let refund = "refund";
let reverse_lookup = "reverse_lookup";
let connector_response = "connector_response";
let address = "address";
match db_op {
// TODO: Handle errors
Expand All @@ -230,13 +229,6 @@ async fn drainer(
kv::Insertable::Refund(a) => {
macro_util::handle_resp!(a.insert(&conn).await, insert_op, refund)
}
kv::Insertable::ConnectorResponse(a) => {
macro_util::handle_resp!(
a.insert(&conn).await,
insert_op,
connector_response
)
}
kv::Insertable::Address(addr) => {
macro_util::handle_resp!(addr.insert(&conn).await, insert_op, address)
}
Expand Down Expand Up @@ -283,11 +275,6 @@ async fn drainer(
refund
)
}
kv::Updateable::ConnectorResponseUpdate(a) => macro_util::handle_resp!(
a.orig.update(&conn, a.update_data).await,
update_op,
connector_response
),
kv::Updateable::AddressUpdate(a) => macro_util::handle_resp!(
a.orig.update(&conn, a.update_data).await,
update_op,
Expand Down
6 changes: 1 addition & 5 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,6 @@ where
pub payment_intent: storage::PaymentIntent,
pub payment_attempt: storage::PaymentAttempt,
pub multiple_capture_data: Option<types::MultipleCaptureData>,
pub connector_response: storage::ConnectorResponse,
pub amount: api::Amount,
pub mandate_id: Option<api_models::payments::MandateIds>,
pub mandate_connector: Option<MandateConnectorDetails>,
Expand Down Expand Up @@ -1671,10 +1670,7 @@ pub fn should_call_connector<Op: Debug, F: Clone>(
!matches!(
payment_data.payment_intent.status,
storage_enums::IntentStatus::Failed | storage_enums::IntentStatus::Succeeded
) && payment_data
.connector_response
.authentication_data
.is_none()
) && payment_data.payment_attempt.authentication_data.is_none()
}
"PaymentStatus" => {
matches!(
Expand Down
54 changes: 0 additions & 54 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2998,60 +2998,6 @@ impl AttemptType {
}
}
}

#[instrument(skip_all)]
pub async fn get_or_insert_connector_response(
&self,
payment_attempt: &PaymentAttempt,
db: &dyn StorageInterface,
storage_scheme: storage::enums::MerchantStorageScheme,
) -> RouterResult<storage::ConnectorResponse> {
match self {
Self::New => db
.insert_connector_response(
payments::PaymentCreate::make_connector_response(payment_attempt),
storage_scheme,
)
.await
.to_duplicate_response(errors::ApiErrorResponse::DuplicatePayment {
payment_id: payment_attempt.payment_id.clone(),
}),
Self::SameOld => db
.find_connector_response_by_payment_id_merchant_id_attempt_id(
&payment_attempt.payment_id,
&payment_attempt.merchant_id,
&payment_attempt.attempt_id,
storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound),
}
}

#[instrument(skip_all)]
pub async fn get_connector_response(
&self,
db: &dyn StorageInterface,
payment_id: &str,
merchant_id: &str,
attempt_id: &str,
storage_scheme: storage_enums::MerchantStorageScheme,
) -> RouterResult<storage::ConnectorResponse> {
match self {
Self::New => Err(errors::ApiErrorResponse::InternalServerError)
.into_report()
.attach_printable("Precondition failed, the attempt type should not be `New`"),
Self::SameOld => db
.find_connector_response_by_payment_id_merchant_id_attempt_id(
payment_id,
merchant_id,
attempt_id,
storage_scheme,
)
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentNotFound),
}
}
}

#[inline(always)]
Expand Down
Loading

0 comments on commit 475a54e

Please sign in to comment.