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

feat(core): Added integrity framework for Authorize and Sync flow with connector as Stripe #5109

Merged
merged 168 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
9ef9de9
refactor(router): added a new type minor unit to amount
sahkal May 13, 2024
a1bb647
chore: run formatter
hyperswitch-bot[bot] May 13, 2024
f6c4946
refactor(router): fixed clippy issue
sahkal May 13, 2024
937687a
Merge branch 'change_core_amount_to_domain_type' of https://github.co…
sahkal May 13, 2024
61850dc
refactor(router): fixed openapi specs
sahkal May 13, 2024
c840348
Merge branch 'main' into change_core_amount_to_domain_type
sahkal May 13, 2024
6103485
refactor(router): fixed capture amount unequal bug
sahkal May 13, 2024
0c214b7
Merge branch 'change_core_amount_to_domain_type' of https://github.co…
sahkal May 13, 2024
a994132
refactor(router): fixed open-api issue
sahkal May 13, 2024
02a7048
refactor(router): addressed pr comments
sahkal May 14, 2024
fe6dd36
refactor(router): resolved merge conflicts
sahkal May 15, 2024
9852bf4
refactor(router): fixed spell check issue
sahkal May 15, 2024
41af58f
refactor(router): resolved pr comments:
sahkal May 16, 2024
3df68ba
Merge branch 'main' into change_core_amount_to_domain_type
hrithikesh026 May 16, 2024
6e6726f
refactor(router): resolved pr comments
sahkal May 17, 2024
68034cb
Merge branch 'change_core_amount_to_domain_type' of https://github.co…
sahkal May 17, 2024
1b623a8
refactor(router): fixed clippy issue
sahkal May 17, 2024
eff793f
refactor(router): fixed clippy issue
sahkal May 17, 2024
bce3de0
refactor(router): fixed open-api-specs
sahkal May 17, 2024
63ef54c
refactor(router): fixed open-api specs
sahkal May 17, 2024
17c58f4
chore: run formatter
hyperswitch-bot[bot] May 17, 2024
f76ba1d
refactor(router): fixed clippy issue
sahkal May 17, 2024
5b657f9
Merge branch 'change_core_amount_to_domain_type' of https://github.co…
sahkal May 17, 2024
59ffc34
refactor(router): resolved comments
sahkal May 17, 2024
9ba21c4
chore: run formatter
hyperswitch-bot[bot] May 17, 2024
3bce742
refactor(router): resolved comments
sahkal May 17, 2024
5b8cf34
Merge branch 'change_core_amount_to_domain_type' of https://github.co…
sahkal May 17, 2024
23e9158
refactor(router): fixed clippy issue
sahkal May 17, 2024
78d71ba
feat(router
sahkal May 20, 2024
d4c363f
wip: reduce errors
Narayanbhat166 May 20, 2024
ddee2bd
chore: make it finally compile
Narayanbhat166 May 20, 2024
6e0070d
chore: run formatter
hyperswitch-bot[bot] May 20, 2024
44caf0b
feat(router): added conversion trait in core for connector to use
sahkal May 21, 2024
d5f951f
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 21, 2024
c0f549e
chore: run formatter
hyperswitch-bot[bot] May 21, 2024
1a9fe2a
refactor
sahkal May 23, 2024
53f0465
refactor(router): resolved merge conflicts
sahkal May 23, 2024
f30b388
refactor(router): fixed clippy issues
sahkal May 23, 2024
8647c28
refactor(router): resolved merge conflicts
sahkal May 23, 2024
fc05741
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 23, 2024
db98d60
refactor(router):fixed open-api issue
sahkal May 23, 2024
4ddb24c
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 23, 2024
d94ef10
refactor(router): removed unnecessary code
sahkal May 23, 2024
4910dec
refactor(router): added unit test case for amount conversions
sahkal May 27, 2024
37f5b1c
refactor(router): added unit case for three_decimal_currency
sahkal May 27, 2024
bc00c63
refactor(router): addressed pr comments
sahkal May 28, 2024
11a6b2c
refactor(router): resolved merge conflicts
sahkal May 28, 2024
3547356
refactor(router): removed test_amount from tests
sahkal May 28, 2024
7a916a5
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 28, 2024
d9b564b
refactor(router): fixed clippy issues
sahkal May 28, 2024
5b9c363
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 28, 2024
6b8c733
refactor(router): fixed open api issue
sahkal May 28, 2024
56ea730
refactor(connector): changed amount to minor Unit for stripe
sahkal May 28, 2024
96f9aa3
chore: run formatter
hyperswitch-bot[bot] May 28, 2024
5be12e1
refactor(router): mapped error to error message
sahkal May 28, 2024
fa440df
chore: run formatter
hyperswitch-bot[bot] May 28, 2024
0ba13c1
refactor(router): resolved merge conflict
sahkal May 29, 2024
34f220c
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 29, 2024
6967e5f
chore: run formatter
hyperswitch-bot[bot] May 29, 2024
773b458
refactor(router): addressed pr comments
sahkal May 29, 2024
8d51b46
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 29, 2024
64b8693
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 29, 2024
1939b5f
refactor(router): fixed open-api specs'
sahkal May 29, 2024
1daa5a9
refactor(router): fixed open-api specs'
sahkal May 29, 2024
7edf17b
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] May 29, 2024
8ac5ecc
refactor(router): fixed clippy issue
sahkal May 29, 2024
511322c
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 29, 2024
97113c9
chore: run formatter
hyperswitch-bot[bot] May 29, 2024
7fd1af9
refactor(router): fixed open-api specs
sahkal May 29, 2024
f2a70b5
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 29, 2024
9cdea2d
refactor(router): resolved merge conflicts
sahkal May 29, 2024
c4bd128
chore: run formatter
hyperswitch-bot[bot] May 29, 2024
35c47fe
refactor(router): fixed cargo hack issue
sahkal May 29, 2024
d009312
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 29, 2024
3135548
chore: run formatter
hyperswitch-bot[bot] May 29, 2024
d20810c
Merge branch 'move-newType-amount-to-connector-module' of https://git…
sahkal May 30, 2024
4a259a4
refactor(connector): added amount frame work support for stripe
sahkal May 30, 2024
3366b2e
chore: run formatter
hyperswitch-bot[bot] May 30, 2024
88ea441
refactor(connector): added amount frame work to bluesnap
sahkal May 30, 2024
94f6f55
refactor(connector): addressed pr comments
sahkal May 30, 2024
0dceb91
refactor(connector): added captured amount to router data
sahkal May 30, 2024
2867fb6
chore: run formatter
hyperswitch-bot[bot] May 30, 2024
bf9393a
refactor(connector):added amount framework to charged object
sahkal May 30, 2024
80efa5a
Merge branch '5177-amount-conversion-do-amount-conversion-for-stripe'…
sahkal May 30, 2024
8efa34e
refactor(connector): resolved pr comments
sahkal May 30, 2024
4be4348
refactor(connector): resolved merge conflicts
sahkal May 31, 2024
14c6bbc
Merge branch '5177-amount-conversion-do-amount-conversion-for-stripe'…
sahkal May 31, 2024
7c34670
refactor(connector): fixed compile issue
sahkal May 31, 2024
fcccf0b
chore: run formatter
hyperswitch-bot[bot] May 31, 2024
c286940
refactor(connector): added amount framework to payme connector
sahkal May 31, 2024
2a8e628
chore: run formatter
hyperswitch-bot[bot] May 31, 2024
e9b59e7
refactor(connector): fixed clippy issue
sahkal May 31, 2024
0bb7164
Merge branch '5178-amount-conversion-do-amount-conversion-for-bluesna…
sahkal May 31, 2024
b63687d
refactor(connector): added uniformity in stripe for amount framework
sahkal May 31, 2024
c5ff47f
chore: run formatter
hyperswitch-bot[bot] May 31, 2024
0ba9923
Merge branch '5177-amount-conversion-do-amount-conversion-for-stripe'…
sahkal May 31, 2024
3ee29da
refactor(connector): added convertion uniformity to payme for amount …
sahkal May 31, 2024
64b2a40
chore: run formatter
hyperswitch-bot[bot] May 31, 2024
64cdad8
refactor(connector): added amount frame work for noon
sahkal May 31, 2024
5f84aa5
chore: run formatter
hyperswitch-bot[bot] May 31, 2024
3462c59
Refactor(connector): added amount framework for trustpay
sahkal Jun 3, 2024
161a013
refactor(connector): added applepay fix for connectors
sahkal Jun 3, 2024
875071b
chore: run formatter
hyperswitch-bot[bot] Jun 3, 2024
9ba500e
refactor(connector): added amount frame work for google pay apple pay
sahkal Jun 3, 2024
3c5a29f
refactor(connector): resolved merge conflicts
sahkal Jun 3, 2024
66dba1d
refactor(connector): fixed open-api specs
sahkal Jun 3, 2024
99824e2
refactor(connector): added amount conversion framework for cryptopay
sahkal Jun 3, 2024
4e53651
refactor(connector): added amount framework to cashtocode
sahkal Jun 3, 2024
89153e3
chore: run formatter
hyperswitch-bot[bot] Jun 3, 2024
1e8a332
refactor(connector): added amount framework to paypal, payouts and ro…
sahkal Jun 4, 2024
5d6b780
refactor(connector): added amount framework to IATAPAY
sahkal Jun 4, 2024
1b3f8f4
refactor(core): added amount conversion changes to connector generati…
sahkal Jun 6, 2024
4f8bbf3
chore: run formatter
hyperswitch-bot[bot] Jun 6, 2024
05a456c
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jun 6, 2024
7def115
refactor(core): try fix to connector template
sahkal Jun 6, 2024
aa0b952
Merge branch '5188-amount-conversion-do-amount-conversion-for-iatapay…
sahkal Jun 6, 2024
963da1f
trial 101
sahkal Jun 6, 2024
12d0244
trial 102
sahkal Jun 6, 2024
26dd395
trial 103
sahkal Jun 6, 2024
e5ee829
trial 104
sahkal Jun 6, 2024
3728dbb
trial 105
sahkal Jun 6, 2024
8191849
trial 105
sahkal Jun 6, 2024
af70beb
trial 107
sahkal Jun 6, 2024
914e7f5
final fix
sahkal Jun 6, 2024
9f1a1a1
final fix101
sahkal Jun 6, 2024
5d844c9
final fix102
sahkal Jun 6, 2024
388af1f
final fix103
sahkal Jun 6, 2024
a0072ee
final fix104
sahkal Jun 6, 2024
4a8a1e6
final fix105
sahkal Jun 6, 2024
4f70ca9
refactor(router): fixed connector-template
sahkal Jun 6, 2024
e5e4ecc
refactor(connector): fixed spell check issue
sahkal Jun 6, 2024
4e858e8
Merge branch '5185-amount-conversion-do-amount-conversion-for-cashtoc…
sahkal Jun 7, 2024
5ef345e
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Jun 7, 2024
58b97af
refactor(router): fixed cargo clippy issue in routing test cases
sahkal Jun 7, 2024
745c858
Merge branch '5187-amount-conversion-do-amount-conversion-for-paypal'…
sahkal Jun 7, 2024
ee89ce6
refactor(router): addressed pr comments
sahkal Jun 7, 2024
8664c0d
refactor(router): fixed extra spacing issue
sahkal Jun 7, 2024
08ed1bb
refactor(router): fixed connector template
sahkal Jun 7, 2024
6ec73fc
feat(router): added integrity check 101
sahkal Jun 13, 2024
c6cfe2a
refactor(core): enhanced integrity checks
sahkal Jun 18, 2024
6e4b7a3
refactor(router): moved integrity check to core
sahkal Jun 20, 2024
f710241
refactor(router): cleaning integrity implementation
sahkal Jun 20, 2024
3993d0a
refactor(core): removed warnings
sahkal Jun 20, 2024
2076727
refactor(router): removed unnecessary comments
sahkal Jun 20, 2024
3b8b29e
refactor(router): added integrity checks for sync
sahkal Jun 21, 2024
403ba6c
chore: run formatter
hyperswitch-bot[bot] Jun 21, 2024
2fe0d73
refactor(router): merged with main
sahkal Jun 21, 2024
43b2681
refactor(router): merged with main
sahkal Jun 21, 2024
d7d3614
chore: run formatter
hyperswitch-bot[bot] Jun 21, 2024
ebefe2f
refactor(router): fixed missing documents warning
sahkal Jun 21, 2024
67e7ff8
Merge branch '4889-enable-integrity-check-for-authorize-flow' of http…
sahkal Jun 21, 2024
3513140
refactor(router): fixed missing documents warning
sahkal Jun 21, 2024
de1cd35
refactor(connector): syned with main
sahkal Jun 21, 2024
80ef922
refactor(router): resolved merge conflicts
sahkal Jun 21, 2024
5e4f3e3
refactor(router): removed unnecessary comments
sahkal Jun 21, 2024
c74c882
refactor(router): removed unnessary comments
sahkal Jun 21, 2024
ccd4885
refactor(router): fixed ci and spell check errors
sahkal Jun 23, 2024
a811e36
refactor(router): added debug log to postman test case
sahkal Jun 23, 2024
d2e9a6e
refactor(router): added debug log to postman test case
sahkal Jun 23, 2024
ecb5c67
refactor(router): fixed sync surcharge bug for integrity check
sahkal Jun 23, 2024
8353f0a
refactor(router): removed postman debug logs
sahkal Jun 23, 2024
49198b6
refactor(router): resolve comments
sahkal Jun 24, 2024
d6e2b93
refactor(router): resolved pr comments
sahkal Jun 24, 2024
ac5d845
refactor(router): resolved merge conflicts
sahkal Jul 1, 2024
23c7d21
Merge branch 'main' into 4889-enable-integrity-check-for-authorize-flow
sahkal Jul 2, 2024
4794efe
refactor(router): fixed ci check failures
sahkal Jul 2, 2024
d49973a
refactor(router): resolved pr comments for integrity checks
sahkal Jul 4, 2024
d272bdf
refactor
sahkal Jul 4, 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
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/api_models/src/errors/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ pub struct Extra {
pub connector: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub connector_transaction_id: Option<String>,
}

#[derive(Serialize, Debug, Clone)]
Expand Down
9 changes: 9 additions & 0 deletions crates/common_utils/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ pub enum ValidationError {
InvalidValue { message: String },
}

/// Integrity check errors.
#[derive(Debug, Clone, PartialEq, Default)]
pub struct IntegrityCheckError {
/// Field names for which integrity check failed!
pub field_names: String,
/// Connector transaction reference id
pub connector_transaction_id: Option<String>,
}

/// Cryptographic algorithm errors
#[derive(Debug, thiserror::Error)]
pub enum CryptoError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ pub enum ApiErrorResponse {
InvalidCookie,
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_27", message = "Extended card info does not exist")]
ExtendedCardInfoNotFound,
#[error(error_type = ErrorType::ServerNotAvailable, code = "IE", message = "{reason} as data mismatched for {field_names}", ignore = "status_code")]
IntegrityCheckFailed {
reason: String,
field_names: String,
connector_transaction_id: Option<String>,
},
#[error(error_type = ErrorType::ProcessingError, code = "HE_06", message = "Missing tenant id")]
MissingTenantId,
#[error(error_type = ErrorType::ProcessingError, code = "HE_06", message = "Invalid tenant id: {tenant_id}")]
Expand Down Expand Up @@ -609,6 +615,19 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon
Self::ExtendedCardInfoNotFound => {
AER::NotFound(ApiError::new("IR", 27, "Extended card info does not exist", None))
}
Self::IntegrityCheckFailed {
reason,
field_names,
connector_transaction_id
} => AER::InternalServerError(ApiError::new(
"IE",
0,
format!("{} as data mismatched for {}", reason, field_names),
Some(Extra {
connector_transaction_id: connector_transaction_id.to_owned(),
..Default::default()
})
)),
Self::MissingTenantId => {
AER::InternalServerError(ApiError::new("HE", 6, "Missing Tenant ID in the request".to_string(), None))
}
Expand Down
4 changes: 3 additions & 1 deletion crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, marker::PhantomData};

use common_utils::{id_type, types::MinorUnit};
use common_utils::{errors::IntegrityCheckError, id_type, types::MinorUnit};
use masking::Secret;

use crate::{payment_address::PaymentAddress, payment_method_data};
Expand Down Expand Up @@ -70,6 +70,8 @@ pub struct RouterData<Flow, Request, Response> {

// minor amount for amount framework
pub minor_amount_captured: Option<MinorUnit>,

pub integrity_check: Result<(), IntegrityCheckError>,
}

// Different patterns of authentication.
Expand Down
20 changes: 20 additions & 0 deletions crates/hyperswitch_domain_models/src/router_request_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ pub struct PaymentsAuthorizeData {

// New amount for amount frame work
pub minor_amount: MinorUnit,
pub integrity_object: Option<AuthoriseIntegrityObject>,
}

#[derive(Debug, Clone, PartialEq)]
pub struct AuthoriseIntegrityObject {
/// Authorise amount
pub amount: MinorUnit,
/// Authorise currency
pub currency: storage_enums::Currency,
}

#[derive(Debug, Clone, PartialEq)]
pub struct SyncIntegrityObject {
/// Sync amount
pub amount: Option<MinorUnit>,
/// Sync currency
pub currency: Option<storage_enums::Currency>,
}

#[derive(Debug, serde::Deserialize, Clone)]
Expand Down Expand Up @@ -348,6 +365,9 @@ pub struct PaymentsSyncData {
pub payment_method_type: Option<storage_enums::PaymentMethodType>,
pub currency: storage_enums::Currency,
pub payment_experience: Option<common_enums::PaymentExperience>,

pub amount: MinorUnit,
pub integrity_object: Option<SyncIntegrityObject>,
}

#[derive(Debug, Default, Clone)]
Expand Down
168 changes: 168 additions & 0 deletions crates/hyperswitch_interfaces/src/integrity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
use common_utils::errors::IntegrityCheckError;
use hyperswitch_domain_models::router_request_types::{
AuthoriseIntegrityObject, PaymentsAuthorizeData, PaymentsSyncData, SyncIntegrityObject,
};

/// Connector Integrity trait to check connector data integrity
pub trait FlowIntegrity {
/// Output type for the connector
type IntegrityObject;
/// helps in connector integrity check
fn compare(
req_integrity_object: Self::IntegrityObject,
res_integrity_object: Self::IntegrityObject,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError>;
}

/// Trait to get connector integrity object based on request and response
pub trait GetIntegrityObject<T: FlowIntegrity> {
/// function to get response integrity object
fn get_response_integrity_object(&self) -> Option<T::IntegrityObject>;
/// function to get request integrity object
fn get_request_integrity_object(&self) -> T::IntegrityObject;
}

/// Trait to check flow type, based on which various integrity checks will be performed
pub trait CheckIntegrity<Request, T> {
/// Function to check to initiate integrity check
fn check_integrity(
&self,
request: &Request,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError>;
}

impl<T, Request> CheckIntegrity<Request, T> for PaymentsAuthorizeData
where
T: FlowIntegrity,
Request: GetIntegrityObject<T>,
{
fn check_integrity(
&self,
request: &Request,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError> {
match request.get_response_integrity_object() {
Some(res_integrity_object) => {
let req_integrity_object = request.get_request_integrity_object();
T::compare(
req_integrity_object,
res_integrity_object,
connector_transaction_id,
)
}
None => Ok(()),
}
}
}

impl<T, Request> CheckIntegrity<Request, T> for PaymentsSyncData
where
T: FlowIntegrity,
Request: GetIntegrityObject<T>,
{
fn check_integrity(
&self,
request: &Request,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError> {
match request.get_response_integrity_object() {
Some(res_integrity_object) => {
let req_integrity_object = request.get_request_integrity_object();
T::compare(
req_integrity_object,
res_integrity_object,
connector_transaction_id,
)
}
None => Ok(()),
}
}
}

impl FlowIntegrity for AuthoriseIntegrityObject {
type IntegrityObject = Self;
fn compare(
req_integrity_object: Self,
res_integrity_object: Self,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError> {
let mut mismatched_fields = Vec::new();

if req_integrity_object.amount != res_integrity_object.amount {
mismatched_fields.push("amount".to_string());
}

if req_integrity_object.currency != res_integrity_object.currency {
mismatched_fields.push("currency".to_string());
}

if mismatched_fields.is_empty() {
Ok(())
} else {
let field_names = mismatched_fields.join(", ");

Err(IntegrityCheckError {
field_names,
connector_transaction_id,
})
}
}
}

impl FlowIntegrity for SyncIntegrityObject {
type IntegrityObject = Self;
fn compare(
req_integrity_object: Self,
res_integrity_object: Self,
connector_transaction_id: Option<String>,
) -> Result<(), IntegrityCheckError> {
let mut mismatched_fields = Vec::new();

if req_integrity_object.amount != res_integrity_object.amount {
mismatched_fields.push("amount".to_string());
}

if req_integrity_object.currency != res_integrity_object.currency {
mismatched_fields.push("currency".to_string());
}

if mismatched_fields.is_empty() {
Ok(())
} else {
let field_names = mismatched_fields.join(", ");

Err(IntegrityCheckError {
field_names,
connector_transaction_id,
})
}
}
}

impl GetIntegrityObject<AuthoriseIntegrityObject> for PaymentsAuthorizeData {
fn get_response_integrity_object(&self) -> Option<AuthoriseIntegrityObject> {
self.integrity_object.clone()
}

fn get_request_integrity_object(&self) -> AuthoriseIntegrityObject {
AuthoriseIntegrityObject {
amount: self.minor_amount,
currency: self.currency,
}
}
}

impl GetIntegrityObject<SyncIntegrityObject> for PaymentsSyncData {
fn get_response_integrity_object(&self) -> Option<SyncIntegrityObject> {
self.integrity_object.clone()
}

fn get_request_integrity_object(&self) -> SyncIntegrityObject {
SyncIntegrityObject {
amount: Some(self.amount),
currency: Some(self.currency),
}
}
}
2 changes: 2 additions & 0 deletions crates/hyperswitch_interfaces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub mod consts;
pub mod encryption_interface;
pub mod errors;
pub mod events;
/// connector integrity check interface
pub mod integrity;
pub mod metrics;
pub mod secrets_interface;
pub mod types;
16 changes: 16 additions & 0 deletions crates/router/src/compatibility/stripe/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ pub enum StripeErrorCode {
PaymentMethodDeleteFailed,
#[error(error_type = StripeErrorType::InvalidRequestError, code = "", message = "Extended card info does not exist")]
ExtendedCardInfoNotFound,
#[error(error_type = StripeErrorType::ConnectorError, code = "CE", message = "{reason} as data mismatched for {field_names}")]
IntegrityCheckFailed {
reason: String,
field_names: String,
connector_transaction_id: Option<String>,
},
#[error(error_type = StripeErrorType::InvalidRequestError, code = "IR_28", message = "Invalid tenant")]
InvalidTenant,
#[error(error_type = StripeErrorType::HyperswitchError, code = "HE_01", message = "Failed to convert amount to {amount_type} type")]
Expand Down Expand Up @@ -650,6 +656,15 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode {
Self::InvalidWalletToken { wallet_name }
}
errors::ApiErrorResponse::ExtendedCardInfoNotFound => Self::ExtendedCardInfoNotFound,
errors::ApiErrorResponse::IntegrityCheckFailed {
reason,
field_names,
connector_transaction_id,
} => Self::IntegrityCheckFailed {
reason,
field_names,
connector_transaction_id,
},
errors::ApiErrorResponse::InvalidTenant { tenant_id: _ }
| errors::ApiErrorResponse::MissingTenantId => Self::InvalidTenant,
errors::ApiErrorResponse::AmountConversionFailed { amount_type } => {
Expand Down Expand Up @@ -741,6 +756,7 @@ impl actix_web::ResponseError for StripeErrorCode {
Self::ExternalConnectorError { status_code, .. } => {
StatusCode::from_u16(*status_code).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)
}
Self::IntegrityCheckFailed { .. } => StatusCode::INTERNAL_SERVER_ERROR,
Self::PaymentBlockedError { code, .. } => {
StatusCode::from_u16(*code).unwrap_or(StatusCode::OK)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/router/src/connector/cryptopay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
let capture_amount_in_minor_units = match response.data.price_amount {
Some(ref amount) => Some(utils::convert_back(
Some(ref amount) => Some(utils::convert_back_amount_to_minor_units(
self.amount_converter,
amount.clone(),
data.request.currency,
Expand Down Expand Up @@ -393,7 +393,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
let capture_amount_in_minor_units = match response.data.price_amount {
Some(ref amount) => Some(utils::convert_back(
Some(ref amount) => Some(utils::convert_back_amount_to_minor_units(
self.amount_converter,
amount.clone(),
data.request.currency,
Expand Down
Loading
Loading