fix(connector): [STRIPE] Retrieving Connect Account Id from Mandate Metadata in MITs#8326
fix(connector): [STRIPE] Retrieving Connect Account Id from Mandate Metadata in MITs#8326Gnanasundari24 merged 8 commits intomainfrom
Conversation
Changed Files
|
crates/storage_impl/src/errors.rs
Outdated
| 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.
Use generic field name instead of transfer_account_id/application_fees/charge_type
There was a problem hiding this comment.
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.
like we do for FlowNotSupported
| 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.
| #[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")] |
| 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.
| 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 |
crates/storage_impl/src/errors.rs
Outdated
| 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.
| #[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")] |
jagan-jaya
left a comment
There was a problem hiding this comment.
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.
can we not ignore error here, instead log the error if not populate
| errors::ApiErrorResponse::NotImplemented { .. } => Self::Unauthorized, | ||
| errors::ApiErrorResponse::FlowNotSupported { .. } => Self::InternalServerError, | ||
| errors::ApiErrorResponse::MandatePaymentDataMismatch { .. } => { | ||
| Self::InternalServerError |
There was a problem hiding this comment.
This should be 4xx if we are checking some request data to our internal saved data
| .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.
can we please try removing get_amount_as_i64() function from here, also not use it any of the future use cases
2edd8d0
crates/common_utils/src/types.rs
Outdated
| #[diesel(sql_type = sql_types::BigInt)] | ||
| pub struct MinorUnit(i64); | ||
|
|
||
| use std::num::NonZeroI64; |
There was a problem hiding this comment.
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 --allcargo clippy