-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(connector): [STRIPE] Retrieving Connect Account Id from Mandate Metadata in MITs #8326
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
Conversation
Changed Files
|
crates/storage_impl/src/errors.rs
Outdated
@@ -193,6 +193,8 @@ pub enum ConnectorError { | |||
InvalidDataFormat { field_name: &'static str }, | |||
#[error("Payment Method data / Payment Method Type / Payment Experience Mismatch ")] | |||
MismatchedPaymentData, | |||
#[error("transfer_account_id/application_fees/charge_type sent in request doesn't match with the values used during mandate creation ")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use generic field name instead of transfer_account_id/application_fees/charge_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to say i should make the error message Dynamic and at the connector level populate the message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like we do for FlowNotSupported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -290,6 +290,8 @@ pub enum ApiErrorResponse { | |||
InvalidPlatformOperation, | |||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_45", message = "External vault failed during processing with connector")] | |||
ExternalVaultFailed, | |||
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_46", message = "Fields like {fields} doesn't match with the ones used during mandate creation")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_46", message = "Fields like {fields} doesn't match with the ones used during mandate creation")] | |
#[error(error_type = ErrorType::InvalidRequestError, code = "IR_46", message = "Field {fields} doesn't match with the ones used during mandate creation")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -651,6 +653,9 @@ impl ErrorSwitch<api_models::errors::types::ApiErrorResponse> for ApiErrorRespon | |||
Self::ExternalVaultFailed => { | |||
AER::BadRequest(ApiError::new("IR", 45, "External Vault failed while processing with connector.", None)) | |||
}, | |||
Self::MandatePaymentDataMismatch { fields} => { | |||
AER::BadRequest(ApiError::new("IR", 46, format!("Fields like {fields} doesn't match with the ones used during mandate creation"), Some(Extra {fields: Some(fields.to_owned()), ..Default::default()}))) //FIXME: error message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AER::BadRequest(ApiError::new("IR", 46, format!("Fields like {fields} doesn't match with the ones used during mandate creation"), Some(Extra {fields: Some(fields.to_owned()), ..Default::default()}))) //FIXME: error message | |
AER::BadRequest(ApiError::new("IR", 46, format!("Field {fields} doesn't match with the ones used during mandate creation"), Some(Extra {fields: Some(fields.to_owned()), ..Default::default()}))) //FIXME: error message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
crates/storage_impl/src/errors.rs
Outdated
@@ -193,6 +193,8 @@ pub enum ConnectorError { | |||
InvalidDataFormat { field_name: &'static str }, | |||
#[error("Payment Method data / Payment Method Type / Payment Experience Mismatch ")] | |||
MismatchedPaymentData, | |||
#[error("Fields like {fields} doesn't match with the ones used during mandate creation")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[error("Fields like {fields} doesn't match with the ones used during mandate creation")] | |
#[error("Field {fields} doesn't match with the ones used during mandate creation")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Framework changes looks good. please update the PR description as it is empty now
}) | ||
.and_then(|secret_value| { | ||
let json_value = secret_value.clone().expose(); | ||
serde_json::from_value::<Self>(json_value).ok() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not ignore error here, instead log the error if not populate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
@@ -600,6 +600,9 @@ impl From<errors::ApiErrorResponse> for StripeErrorCode { | |||
errors::ApiErrorResponse::AddressNotFound => Self::AddressNotFound, | |||
errors::ApiErrorResponse::NotImplemented { .. } => Self::Unauthorized, | |||
errors::ApiErrorResponse::FlowNotSupported { .. } => Self::InternalServerError, | |||
errors::ApiErrorResponse::MandatePaymentDataMismatch { .. } => { | |||
Self::InternalServerError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 4xx if we are checking some request data to our internal saved data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
.get_amount_as_i64() | ||
!= 0 | ||
{ | ||
return Err(errors::ApiErrorResponse::InvalidDataValue { | ||
field_name: "split_payments.stripe_split_payment.application_fees", | ||
}); | ||
} | ||
} | ||
api::Amount::Value(amount) => { | ||
if stripe_split_payment.application_fees.get_amount_as_i64() > amount.into() { | ||
if stripe_split_payment | ||
.application_fees | ||
.as_ref() | ||
.map_or(MinorUnit::zero(), |amount| *amount) | ||
.get_amount_as_i64() | ||
> amount.into() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we please try removing get_amount_as_i64()
function from here, also not use it any of the future use cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright
2edd8d0
crates/common_utils/src/types.rs
Outdated
@@ -386,6 +386,14 @@ impl AmountConvertor for MinorUnitForConnector { | |||
#[diesel(sql_type = sql_types::BigInt)] | |||
pub struct MinorUnit(i64); | |||
|
|||
use std::num::NonZeroI64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this import to top of the file
Type of Change
Description
In the CIT call, we store the stripe split payment details inside Mandate Metadata and during the MIT calls we retrieve the split payments data from there and use it in the MIT calls. And if the merchant sends split payment details again in the MIT call, we match it. If its the same we move forward. If different we throw an error.
Additional Changes
Motivation and Context
How did you test it?
Case 1 : In MIT call donot pass Split Object
Do a CIT Call in Stripe :
cURL :
Response:
Do a MIT call now (without passing any split payment object now) :
cURL:
Response:
Case 2: Pass same Split Payment object in MIT
CIT ->
cURL:
Response:
MIT ->
cURL :
Response:
Case 3: Pass Split Payment object in MIT but different from the one which was sent in CIT (conflicted case)
CIT ->
cURL :
Response:
MIT (application_fees passed is different than the one sent in MIT) ->
cURL:
Response:
Checklist
cargo +nightly fmt --all
cargo clippy