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

refactor(payment_intent_v2): payment intent fields refactoring #5880

Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
9de3e5e
make v2 changes for payment intent diesel and domain models
hrithikesh026 Sep 2, 2024
a193623
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 3, 2024
b06e82d
refactor: regroup the migrations
Narayanbhat166 Sep 3, 2024
94b2543
add fields to payment intent from payment attempt
hrithikesh026 Sep 3, 2024
1b97e93
chore: run formatter
hyperswitch-bot[bot] Sep 3, 2024
4f24d01
refactor: make domain models compile for v2
Narayanbhat166 Sep 4, 2024
56dcdc0
chore: cargo clippy
Narayanbhat166 Sep 4, 2024
8d100b1
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 4, 2024
9b517ff
add surcharge_amount and tax_on_surcharge to payment_intent
hrithikesh026 Sep 5, 2024
3f1d00a
refactor: remove unused code related to v1 features
Narayanbhat166 Sep 6, 2024
0daf196
refactor: make v1 compile
Narayanbhat166 Sep 7, 2024
2a25402
refactor: Update imports and remove unused code for v1 features
Narayanbhat166 Sep 7, 2024
95917c8
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 7, 2024
e5a7ba8
chore: run formatter
hyperswitch-bot[bot] Sep 7, 2024
5a5355a
chore: fix v2 errors
Narayanbhat166 Sep 8, 2024
da4c00f
chore: cargo clippy
Narayanbhat166 Sep 8, 2024
e453401
chore: fix ci checks
Narayanbhat166 Sep 9, 2024
f3986f3
chore: fix v2 checks
Narayanbhat166 Sep 9, 2024
dc791c3
make v2 changes for payment attempt diesel model
hrithikesh026 Sep 9, 2024
b263797
make v2 changes for payment attempt domail model
hrithikesh026 Sep 9, 2024
f4b2426
fix migration errors
hrithikesh026 Sep 9, 2024
588c298
refactor: remove payment_v2 feature flag
Narayanbhat166 Sep 9, 2024
3d782d8
refactor: remove payment_v2 feature flag
Narayanbhat166 Sep 9, 2024
426ec3f
Revert "refactor: remove payment_v2 feature flag"
Narayanbhat166 Sep 10, 2024
d003b36
Revert "refactor: remove payment_v2 feature flag"
Narayanbhat166 Sep 10, 2024
6befb81
Revert "fix migration errors"
Narayanbhat166 Sep 10, 2024
8bab2fa
Revert "make v2 changes for payment attempt domail model"
Narayanbhat166 Sep 10, 2024
80326fc
Revert "make v2 changes for payment attempt diesel model"
Narayanbhat166 Sep 10, 2024
360ca8d
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 10, 2024
5f66fea
fix: merge fixes
Narayanbhat166 Sep 10, 2024
3a9e8b0
fix: schema file for v2
Narayanbhat166 Sep 10, 2024
ffdcb00
fix: diesel errors
Narayanbhat166 Sep 10, 2024
4ec2ed4
chore: rename merchant_decision in payment_intent
hrithikesh026 Sep 11, 2024
ac48d75
chore: fix migration consistency
hrithikesh026 Sep 11, 2024
ddf0bfe
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 11, 2024
66bc45c
fix: merge fixes
Narayanbhat166 Sep 11, 2024
b0e8d2e
refactor: make currency and profile id mandatory intent
Narayanbhat166 Sep 12, 2024
9591867
chore: Drop v1 columns and add v2 columns to payment_intent table
Narayanbhat166 Sep 12, 2024
a2f7bdc
wip: fix compilation errors for payment attempt
Narayanbhat166 Sep 12, 2024
b7cb269
refactor: make client secret mandatory and add todo!() for kafkaintent
Narayanbhat166 Sep 13, 2024
3a36b10
chore: fix schema file
Narayanbhat166 Sep 13, 2024
33d7bd3
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 13, 2024
05c4333
chore: cargo clippy
Narayanbhat166 Sep 13, 2024
ea18f1a
refactor: remove amount_to_capture and add apply_mit_exemption
Narayanbhat166 Sep 13, 2024
2453e41
refactor: remove few fields that are not necessary / moved to `featur…
Narayanbhat166 Sep 15, 2024
a31dcea
refactor: add global_payment_id type
Narayanbhat166 Sep 16, 2024
5aafeec
chore: run formatter
hyperswitch-bot[bot] Sep 16, 2024
f30fe4e
refactor: remove charges and move all amount related fields to a struct
Narayanbhat166 Sep 16, 2024
bdeb683
chore: add comments to fields in payment intent domain model
Narayanbhat166 Sep 16, 2024
4230f1c
refactor: make few boolean fields as enum
Narayanbhat166 Sep 16, 2024
ddf0118
chore: cargo clippy
Narayanbhat166 Sep 17, 2024
4de62bc
chore: move enums to common enums
Narayanbhat166 Sep 17, 2024
3f8d42c
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 17, 2024
a5c97e2
chore: fix typos
Narayanbhat166 Sep 17, 2024
3f485ae
chore: rename enum variants
Narayanbhat166 Sep 17, 2024
6918814
chore: rename enum variants for mit exemption
Narayanbhat166 Sep 17, 2024
f5b181a
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 17, 2024
54157af
refactor: throw internal server error instead of duplicate error
Narayanbhat166 Sep 17, 2024
06e324f
feat: add customer_present, payment_link_config, routing_algorithm_id…
Narayanbhat166 Sep 18, 2024
fdb179d
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 18, 2024
63b56d7
fix: merge fixes
Narayanbhat166 Sep 18, 2024
cb8863f
feat: create Url and ClientSecret types
Narayanbhat166 Sep 19, 2024
ee70ec9
refactor: add more domain types and rename PaymentGlobalId to GlobalP…
Narayanbhat166 Sep 19, 2024
f1ca9b7
chore: run formatter
hyperswitch-bot[bot] Sep 19, 2024
97540e5
chore: cargo clippy
Narayanbhat166 Sep 19, 2024
5afdadf
refactor: add a new LengthString domain type
Narayanbhat166 Sep 19, 2024
8f73422
chore: cargo fix
Narayanbhat166 Sep 19, 2024
fd3baed
feat: add a domain type for statement descriptor
Narayanbhat166 Sep 19, 2024
bef11e8
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 19, 2024
e4965fd
chore: move mca migration to primary constraints
Narayanbhat166 Sep 19, 2024
9f41fb7
Merge branch 'main' into payment-intent-diesel-and-domail-models-chan…
Narayanbhat166 Sep 20, 2024
65acf25
chore: run formatter
hyperswitch-bot[bot] Sep 20, 2024
839c716
chore: fix tests
Narayanbhat166 Sep 20, 2024
5b1cf99
chore: run formatter
hyperswitch-bot[bot] Sep 20, 2024
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
27 changes: 27 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3212,3 +3212,30 @@ pub enum DeleteStatus {
Active,
Redacted,
}

/// Whether 3ds authentication is requested or not
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum External3dsAuthenticationRequest {
/// Request for 3ds authentication
Enable,
/// Skip 3ds authentication
Skip,
}

/// Whether payment link is requested to be enabled or not for this transaction
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum EnablePaymentLinkRequest {
/// Request for enabling payment link
Enable,
/// Skip enabling payment link
Skip,
}

/// Whether mit exemption is requested or not
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub enum MitExemptionRequest {
/// Request for applying MIT exemption
Apply,
/// Skip applying MIT exemption
Skip,
}
55 changes: 55 additions & 0 deletions crates/common_enums/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,61 @@ mod custom_serde {
}
}

impl From<Option<bool>> for super::External3dsAuthenticationRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Enable,
_ => Self::Skip,
}
}
}

/// Get the boolean value of the `External3dsAuthenticationRequest`.
impl super::External3dsAuthenticationRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Enable => true,
Self::Skip => false,
}
}
}

impl super::EnablePaymentLinkRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Enable => true,
Self::Skip => false,
}
}
}

impl From<Option<bool>> for super::EnablePaymentLinkRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Enable,
_ => Self::Skip,
}
}
}

impl From<Option<bool>> for super::MitExemptionRequest {
fn from(value: Option<bool>) -> Self {
match value {
Some(true) => Self::Apply,
_ => Self::Skip,
}
}
}

impl super::MitExemptionRequest {
pub fn as_bool(&self) -> bool {
match self {
Self::Apply => true,
Self::Skip => false,
}
}
}

#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
Expand Down
4 changes: 4 additions & 0 deletions crates/common_utils/src/id_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod payment;
mod profile;
mod routing;

#[cfg(feature = "v2")]
mod global_id;

pub use customer::CustomerId;
Expand All @@ -21,6 +22,8 @@ use diesel::{
serialize::{Output, ToSql},
sql_types,
};
#[cfg(feature = "v2")]
pub use global_id::{payment::PaymentGlobalId, CellId};
pub use merchant::MerchantId;
pub use merchant_connector_account::MerchantConnectorAccountId;
pub use organization::OrganizationId;
Expand Down Expand Up @@ -151,6 +154,7 @@ impl<const MAX_LENGTH: u8, const MIN_LENGTH: u8> LengthId<MAX_LENGTH, MIN_LENGTH
Self(alphanumeric_id)
}

#[cfg(feature = "v2")]
/// Create a new LengthId from aplhanumeric id
pub(crate) fn from_alphanumeric_id(
alphanumeric_id: AlphaNumericId,
Expand Down
4 changes: 3 additions & 1 deletion crates/common_utils/src/id_type/global_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused)]
pub mod payment;

use diesel::{backend::Backend, deserialize::FromSql, serialize::ToSql, sql_types};
use error_stack::ResultExt;
Expand Down Expand Up @@ -32,8 +33,9 @@ impl GlobalEntity {
}
}

/// Cell identifier for an instance / deployment of application
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub(crate) struct CellId(LengthId<CELL_IDENTIFIER_LENGTH, CELL_IDENTIFIER_LENGTH>);
pub struct CellId(LengthId<CELL_IDENTIFIER_LENGTH, CELL_IDENTIFIER_LENGTH>);

#[derive(Debug, Error, PartialEq, Eq)]
pub enum CellIdError {
Expand Down
38 changes: 38 additions & 0 deletions crates/common_utils/src/id_type/global_id/payment.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// A global id that can be used to identify a payment
#[derive(
Debug,
Clone,
Hash,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
diesel::expression::AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Text)]
pub struct PaymentGlobalId(super::GlobalId);

// Database related implementations so that this field can be used directly in the database tables
crate::impl_queryable_id_type!(PaymentGlobalId);

impl<DB> diesel::serialize::ToSql<diesel::sql_types::Text, DB> for PaymentGlobalId
where
DB: diesel::backend::Backend,
super::GlobalId: diesel::serialize::ToSql<diesel::sql_types::Text, DB>,
{
fn to_sql<'b>(
&'b self,
out: &mut diesel::serialize::Output<'b, '_, DB>,
) -> diesel::serialize::Result {
self.0.to_sql(out)
}
}
impl<DB> diesel::deserialize::FromSql<diesel::sql_types::Text, DB> for PaymentGlobalId
where
DB: diesel::backend::Backend,
super::GlobalId: diesel::deserialize::FromSql<diesel::sql_types::Text, DB>,
{
fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
super::GlobalId::from_sql(value).map(Self)
}
}
17 changes: 2 additions & 15 deletions crates/common_utils/src/id_type/payment.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
errors::{CustomResult, ValidationError},
generate_id_with_default_len,
id_type::{global_id, AlphaNumericId, LengthId},
id_type::{AlphaNumericId, LengthId},
};

crate::id_type!(
Expand All @@ -15,23 +15,10 @@ crate::impl_debug_id_type!(PaymentId);
crate::impl_default_id_type!(PaymentId, "pay");
crate::impl_try_from_cow_str_id_type!(PaymentId, "payment_id");

// Database related implementations so that this field can be used directly in the database tables
crate::impl_queryable_id_type!(PaymentId);
crate::impl_to_sql_from_sql_id_type!(PaymentId);

/// A global id that can be used to identify a payment
#[derive(
Debug,
Clone,
Hash,
PartialEq,
Eq,
serde::Serialize,
serde::Deserialize,
diesel::expression::AsExpression,
)]
#[diesel(sql_type = diesel::sql_types::Text)]
pub struct PaymentGlobalId(global_id::GlobalId);

impl PaymentId {
/// Get the hash key to be stored in redis
pub fn get_hash_key_for_kv_store(&self) -> String {
Expand Down
Loading
Loading