-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(router): add payments incremental authorization api (#3038)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9274cef
commit a0cfdd3
Showing
60 changed files
with
1,792 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ pub enum Method { | |
Post, | ||
Put, | ||
Delete, | ||
Patch, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, Debug)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use diesel::{AsChangeset, Identifiable, Insertable, Queryable}; | ||
use serde::{Deserialize, Serialize}; | ||
use time::PrimitiveDateTime; | ||
|
||
use crate::{enums as storage_enums, schema::incremental_authorization}; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Identifiable, Queryable, Serialize, Deserialize, Hash)] | ||
#[diesel(table_name = incremental_authorization)] | ||
#[diesel(primary_key(authorization_id, merchant_id))] | ||
pub struct Authorization { | ||
pub authorization_id: String, | ||
pub merchant_id: String, | ||
pub payment_id: String, | ||
pub amount: i64, | ||
#[serde(with = "common_utils::custom_serde::iso8601")] | ||
pub created_at: PrimitiveDateTime, | ||
#[serde(with = "common_utils::custom_serde::iso8601")] | ||
pub modified_at: PrimitiveDateTime, | ||
pub status: storage_enums::AuthorizationStatus, | ||
pub error_code: Option<String>, | ||
pub error_message: Option<String>, | ||
pub connector_authorization_id: Option<String>, | ||
pub previously_authorized_amount: i64, | ||
} | ||
|
||
#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay, Serialize, Deserialize)] | ||
#[diesel(table_name = incremental_authorization)] | ||
pub struct AuthorizationNew { | ||
pub authorization_id: String, | ||
pub merchant_id: String, | ||
pub payment_id: String, | ||
pub amount: i64, | ||
pub status: storage_enums::AuthorizationStatus, | ||
pub error_code: Option<String>, | ||
pub error_message: Option<String>, | ||
pub connector_authorization_id: Option<String>, | ||
pub previously_authorized_amount: i64, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub enum AuthorizationUpdate { | ||
StatusUpdate { | ||
status: storage_enums::AuthorizationStatus, | ||
error_code: Option<String>, | ||
error_message: Option<String>, | ||
connector_authorization_id: Option<String>, | ||
}, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)] | ||
#[diesel(table_name = incremental_authorization)] | ||
pub struct AuthorizationUpdateInternal { | ||
pub status: Option<storage_enums::AuthorizationStatus>, | ||
pub error_code: Option<String>, | ||
pub error_message: Option<String>, | ||
pub modified_at: Option<PrimitiveDateTime>, | ||
pub connector_authorization_id: Option<String>, | ||
} | ||
|
||
impl From<AuthorizationUpdate> for AuthorizationUpdateInternal { | ||
fn from(authorization_child_update: AuthorizationUpdate) -> Self { | ||
let now = Some(common_utils::date_time::now()); | ||
match authorization_child_update { | ||
AuthorizationUpdate::StatusUpdate { | ||
status, | ||
error_code, | ||
error_message, | ||
connector_authorization_id, | ||
} => Self { | ||
status: Some(status), | ||
error_code, | ||
error_message, | ||
connector_authorization_id, | ||
modified_at: now, | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.