Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/juspay/hyperswitch into tra…
Browse files Browse the repository at this point in the history
…nsfer-ownership
  • Loading branch information
ThisIsMani committed Feb 9, 2024
2 parents 8fe3342 + cfa10aa commit 9390a93
Show file tree
Hide file tree
Showing 45 changed files with 816 additions and 308 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ All notable changes to HyperSwitch will be documented here.

- - -

## 2024.02.09.1

### Bug Fixes

- **core:** Add column mandate_data for storing the details of a mandate in PaymentAttempt ([#3606](https://github.com/juspay/hyperswitch/pull/3606)) ([`74f3721`](https://github.com/juspay/hyperswitch/commit/74f3721ccd0cceac6ae8e751cb83784d2f00a283))
- **postman:** Fix failing postman tests and send a proper error message ([#3601](https://github.com/juspay/hyperswitch/pull/3601)) ([`3cef73b`](https://github.com/juspay/hyperswitch/commit/3cef73b9d8b35cb337757e29e78d22bcbe72faac))

### Miscellaneous Tasks

- **postman:** Update Postman collection files ([`155aa9d`](https://github.com/juspay/hyperswitch/commit/155aa9d1192c3632c5678a958c4bb89f7861c636))

**Full Changelog:** [`2024.02.09.0...2024.02.09.1`](https://github.com/juspay/hyperswitch/compare/2024.02.09.0...2024.02.09.1)

- - -

## 2024.02.09.0

### Features

- **permissions:** Permsision Info Ordering Change ([#3594](https://github.com/juspay/hyperswitch/pull/3594)) ([`96f82cb`](https://github.com/juspay/hyperswitch/commit/96f82cb21233677968aade844db91f91e3918843))
- Adding refunds type to api_event_logs api to fetch refunds audit trail ([#3503](https://github.com/juspay/hyperswitch/pull/3503)) ([`c2b2b65`](https://github.com/juspay/hyperswitch/commit/c2b2b65b9cfc43b5999888635c7b03b1d2de78b3))

### Refactors

- **payment_methods:** Handle card duplication ([#3146](https://github.com/juspay/hyperswitch/pull/3146)) ([`dd5630f`](https://github.com/juspay/hyperswitch/commit/dd5630f070db28051a3dd59a66f0a4ee6777e38f))
- **user_role:** Change update user role request to take `email` instead of `user_id` ([#3530](https://github.com/juspay/hyperswitch/pull/3530)) ([`edd6806`](https://github.com/juspay/hyperswitch/commit/edd6806f97b8d400f1215d845023bb0d7c06aaca))

### Documentation

- Add list mandates for customer ([#3592](https://github.com/juspay/hyperswitch/pull/3592)) ([`3a869a2`](https://github.com/juspay/hyperswitch/commit/3a869a2d5731a2393a687ed7773eda5344bd8e3f))

**Full Changelog:** [`2024.02.08.0...2024.02.09.0`](https://github.com/juspay/hyperswitch/compare/2024.02.08.0...2024.02.09.0)

- - -

## 2024.02.08.0

### Features
Expand Down
4 changes: 4 additions & 0 deletions crates/api_models/src/user/dashboard_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub enum SetMetaDataRequest {
ConfigureWoocom,
SetupWoocomWebhook,
IsMultipleConfiguration,
#[serde(skip)]
IsChangePasswordRequired,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
Expand Down Expand Up @@ -110,6 +112,7 @@ pub enum GetMetaDataRequest {
ConfigureWoocom,
SetupWoocomWebhook,
IsMultipleConfiguration,
IsChangePasswordRequired,
}

#[derive(Debug, serde::Deserialize, serde::Serialize)]
Expand Down Expand Up @@ -146,4 +149,5 @@ pub enum GetMetaDataResponse {
ConfigureWoocom(bool),
SetupWoocomWebhook(bool),
IsMultipleConfiguration(bool),
IsChangePasswordRequired(bool),
}
8 changes: 0 additions & 8 deletions crates/data_models/src/mandates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use time::PrimitiveDateTime;
#[serde(rename_all = "snake_case")]
pub struct MandateDetails {
pub update_mandate_id: Option<String>,
pub mandate_type: Option<MandateDataType>,
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
Expand All @@ -23,13 +22,6 @@ pub enum MandateDataType {
MultiUse(Option<MandateAmountData>),
}

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[serde(untagged)]
pub enum MandateTypeDetails {
MandateType(MandateDataType),
MandateDetails(MandateDetails),
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct MandateAmountData {
pub amount: i64,
Expand Down
12 changes: 9 additions & 3 deletions crates/data_models/src/payments/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use super::PaymentIntent;
use crate::{errors, mandates::MandateTypeDetails, ForeignIDRef};
use crate::{
errors,
mandates::{MandateDataType, MandateDetails},
ForeignIDRef,
};

#[async_trait::async_trait]
pub trait PaymentAttemptInterface {
Expand Down Expand Up @@ -143,7 +147,7 @@ pub struct PaymentAttempt {
pub straight_through_algorithm: Option<serde_json::Value>,
pub preprocessing_step_id: Option<String>,
// providing a location to store mandate details intermediately for transaction
pub mandate_details: Option<MandateTypeDetails>,
pub mandate_details: Option<MandateDataType>,
pub error_reason: Option<String>,
pub multiple_capture_count: Option<i16>,
// reference to the payment at connector side
Expand All @@ -155,6 +159,7 @@ pub struct PaymentAttempt {
pub merchant_connector_id: Option<String>,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub mandate_data: Option<MandateDetails>,
}

impl PaymentAttempt {
Expand Down Expand Up @@ -221,7 +226,7 @@ pub struct PaymentAttemptNew {
pub business_sub_label: Option<String>,
pub straight_through_algorithm: Option<serde_json::Value>,
pub preprocessing_step_id: Option<String>,
pub mandate_details: Option<MandateTypeDetails>,
pub mandate_details: Option<MandateDataType>,
pub error_reason: Option<String>,
pub connector_response_reference_id: Option<String>,
pub multiple_capture_count: Option<i16>,
Expand All @@ -232,6 +237,7 @@ pub struct PaymentAttemptNew {
pub merchant_connector_id: Option<String>,
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub mandate_data: Option<MandateDetails>,
}

impl PaymentAttemptNew {
Expand Down
30 changes: 9 additions & 21 deletions crates/diesel_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,8 @@ use diesel::{
#[serde(rename_all = "snake_case")]
pub struct MandateDetails {
pub update_mandate_id: Option<String>,
pub mandate_type: Option<MandateDataType>,
}

#[derive(
serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression,
)]
#[diesel(sql_type = Jsonb)]
#[serde(rename_all = "snake_case")]
pub enum MandateDataType {
SingleUse(MandateAmountData),
MultiUse(Option<MandateAmountData>),
}

impl<DB: Backend> FromSql<Jsonb, DB> for MandateDataType
impl<DB: Backend> FromSql<Jsonb, DB> for MandateDetails
where
serde_json::Value: FromSql<Jsonb, DB>,
{
Expand All @@ -197,7 +185,7 @@ where
}
}

impl ToSql<Jsonb, diesel::pg::Pg> for MandateDataType
impl ToSql<Jsonb, diesel::pg::Pg> for MandateDetails
where
serde_json::Value: ToSql<Jsonb, diesel::pg::Pg>,
{
Expand All @@ -210,19 +198,17 @@ where
<serde_json::Value as ToSql<Jsonb, diesel::pg::Pg>>::to_sql(&value, &mut out.reborrow())
}
}

#[derive(
serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, FromSqlRow, AsExpression,
)]
#[diesel(sql_type = Jsonb)]
#[serde(untagged)]
#[serde(rename_all = "snake_case")]
pub enum MandateTypeDetails {
MandateType(MandateDataType),
MandateDetails(MandateDetails),
pub enum MandateDataType {
SingleUse(MandateAmountData),
MultiUse(Option<MandateAmountData>),
}

impl<DB: Backend> FromSql<Jsonb, DB> for MandateTypeDetails
impl<DB: Backend> FromSql<Jsonb, DB> for MandateDataType
where
serde_json::Value: FromSql<Jsonb, DB>,
{
Expand All @@ -231,7 +217,8 @@ where
Ok(serde_json::from_value(value)?)
}
}
impl ToSql<Jsonb, diesel::pg::Pg> for MandateTypeDetails

impl ToSql<Jsonb, diesel::pg::Pg> for MandateDataType
where
serde_json::Value: ToSql<Jsonb, diesel::pg::Pg>,
{
Expand Down Expand Up @@ -511,4 +498,5 @@ pub enum DashboardMetadata {
ConfigureWoocom,
SetupWoocomWebhook,
IsMultipleConfiguration,
IsChangePasswordRequired,
}
3 changes: 1 addition & 2 deletions crates/diesel_models/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use time::PrimitiveDateTime;

use crate::{enums as storage_enums, schema::events};

#[derive(Clone, Debug, Deserialize, Insertable, Serialize, router_derive::DebugAsDisplay)]
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
#[diesel(table_name = events)]
#[serde(deny_unknown_fields)]
pub struct EventNew {
pub event_id: String,
pub event_type: storage_enums::EventType,
Expand Down
6 changes: 4 additions & 2 deletions crates/diesel_models/src/payment_attempt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct PaymentAttempt {
pub straight_through_algorithm: Option<serde_json::Value>,
pub preprocessing_step_id: Option<String>,
// providing a location to store mandate details intermediately for transaction
pub mandate_details: Option<storage_enums::MandateTypeDetails>,
pub mandate_details: Option<storage_enums::MandateDataType>,
pub error_reason: Option<String>,
pub multiple_capture_count: Option<i16>,
// reference to the payment at connector side
Expand All @@ -64,6 +64,7 @@ pub struct PaymentAttempt {
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<storage_enums::MandateDetails>,
}

impl PaymentAttempt {
Expand Down Expand Up @@ -126,7 +127,7 @@ pub struct PaymentAttemptNew {
pub business_sub_label: Option<String>,
pub straight_through_algorithm: Option<serde_json::Value>,
pub preprocessing_step_id: Option<String>,
pub mandate_details: Option<storage_enums::MandateTypeDetails>,
pub mandate_details: Option<storage_enums::MandateDataType>,
pub error_reason: Option<String>,
pub connector_response_reference_id: Option<String>,
pub multiple_capture_count: Option<i16>,
Expand All @@ -138,6 +139,7 @@ pub struct PaymentAttemptNew {
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<storage_enums::MandateDetails>,
}

impl PaymentAttemptNew {
Expand Down
18 changes: 17 additions & 1 deletion crates/diesel_models/src/query/dashboard_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl DashboardMetadata {
.await
}

pub async fn delete_user_scoped_dashboard_metadata_by_merchant_id(
pub async fn delete_all_user_scoped_dashboard_metadata_by_merchant_id(
conn: &PgPooledConn,
user_id: String,
merchant_id: String,
Expand All @@ -118,4 +118,20 @@ impl DashboardMetadata {
)
.await
}

pub async fn delete_user_scoped_dashboard_metadata_by_merchant_id_data_key(
conn: &PgPooledConn,
user_id: String,
merchant_id: String,
data_key: enums::DashboardMetadata,
) -> StorageResult<Self> {
generics::generic_delete_one_with_result::<<Self as HasTable>::Table, _, _>(
conn,
dsl::user_id
.eq(user_id)
.and(dsl::merchant_id.eq(merchant_id))
.and(dsl::data_key.eq(data_key)),
)
.await
}
}
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ diesel::table! {
#[max_length = 1024]
unified_message -> Nullable<Varchar>,
net_amount -> Nullable<Int8>,
mandate_data -> Nullable<Jsonb>,
}
}

Expand Down
10 changes: 8 additions & 2 deletions crates/diesel_models/src/user/sample_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ use common_enums::{
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;

use crate::{enums::MandateTypeDetails, schema::payment_attempt, PaymentAttemptNew};
use crate::{
enums::{MandateDataType, MandateDetails},
schema::payment_attempt,
PaymentAttemptNew,
};

#[derive(
Clone, Debug, Default, diesel::Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize,
Expand Down Expand Up @@ -50,7 +54,7 @@ pub struct PaymentAttemptBatchNew {
pub business_sub_label: Option<String>,
pub straight_through_algorithm: Option<serde_json::Value>,
pub preprocessing_step_id: Option<String>,
pub mandate_details: Option<MandateTypeDetails>,
pub mandate_details: Option<MandateDataType>,
pub error_reason: Option<String>,
pub connector_response_reference_id: Option<String>,
pub connector_transaction_id: Option<String>,
Expand All @@ -63,6 +67,7 @@ pub struct PaymentAttemptBatchNew {
pub unified_code: Option<String>,
pub unified_message: Option<String>,
pub net_amount: Option<i64>,
pub mandate_data: Option<MandateDetails>,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -116,6 +121,7 @@ impl PaymentAttemptBatchNew {
unified_code: self.unified_code,
unified_message: self.unified_message,
net_amount: self.net_amount,
mandate_data: self.mandate_data,
}
}
}
1 change: 1 addition & 0 deletions crates/openapi/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Never share your secret api keys. Keep them guarded and secure.
routes::customers::customers_list,
routes::customers::customers_update,
routes::customers::customers_delete,
routes::customers::customers_mandates_list,
//Routes for payment methods
routes::payment_method::create_payment_method_api,
Expand Down
16 changes: 16 additions & 0 deletions crates/openapi/src/routes/customers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,19 @@ pub async fn customers_delete() {}
security(("api_key" = []))
)]
pub async fn customers_list() {}

/// Customers - Mandates List
///
/// Lists all the mandates for a particular customer id.
#[utoipa::path(
post,
path = "/customers/{customer_id}/mandates",
responses(
(status = 200, description = "List of retrieved mandates for a customer", body = Vec<MandateResponse>),
(status = 400, description = "Invalid Data"),
),
tag = "Customers Mandates List",
operation_id = "List all Mandates for a Customer",
security(("api_key" = []))
)]
pub async fn customers_mandates_list() {}
Loading

0 comments on commit 9390a93

Please sign in to comment.