-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(connector): [MIFINITY] Implement payment flows and Mifinity payment method #4592
base: main
Are you sure you want to change the base?
Conversation
…into mifinity-impl
…into mifinity-impl
@@ -1949,6 +1949,10 @@ pub(crate) fn validate_auth_and_metadata_type( | |||
klarna::transformers::KlarnaAuthType::try_from(val)?; | |||
Ok(()) | |||
} | |||
api_enums::Connector::Mifinity => { | |||
mifinity::transformers::MifinityAuthType::try_from(val)?; |
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.
mifinity::transformers::MifinityAuthType::try_from(val)?; | |
mifinity::transformers::MifinityAuthType::try_from(val)?; | |
mifinity::transformers::MifinityConnectorMetadataObject::try_from(connector_meta_data)?; |
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] | ||
pub enum MifinityPaymentStatus { | ||
Successful, | ||
#[default] |
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.
default should not be implemented for payment status
refund_status: enums::RefundStatus::from(item.response.status), | ||
status: enums::AttemptStatus::from(status), | ||
response: Ok(types::PaymentsResponseData::TransactionResponse { | ||
resource_id: types::ResponseId::ConnectorTransactionId(transaction_reference), |
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.
instead of collecting all the reference_id, just take the first one.
} | ||
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()), | ||
} | ||
} | ||
} | ||
|
||
//TODO: Fill the struct with respective fields |
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.
remove todo's
dialing_code: String, | ||
nationality: api_models::enums::CountryAlpha2, | ||
email_address: Email, | ||
dob: Secret<Date>, | ||
} | ||
|
||
#[derive(Default, Debug, Serialize, Eq, PartialEq)] |
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 we need all the derives ?
crates/api_models/src/payments.rs
Outdated
#[schema(value_type = String)] | ||
pub destination_account_number: Secret<String>, | ||
#[schema(value_type = Date)] | ||
pub dob: Secret<Date>, |
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.
pub dob: Secret<Date>, | |
pub date_of_birth: Secret<Date>, |
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)] | ||
pub struct MifinityData { | ||
pub destination_account_number: Secret<String>, | ||
pub dob: Secret<Date>, |
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.
pub dob: Secret<Date>, | |
pub date_of_birth: Secret<Date>, |
), | ||
( | ||
auth_headers::API_VERSION.to_string(), | ||
"1".to_string().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.
Define this as a const in this file
code: response | ||
.errors | ||
.iter() | ||
.map(|error| error.error_code.clone()) | ||
.collect(), | ||
message: response | ||
.errors | ||
.iter() | ||
.map(|error| error.message.clone()) | ||
.collect(), |
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 a join
over the errors with a delimiter like ,
or &
reason: Some( | ||
response | ||
.errors | ||
.iter() | ||
.map(|error| error.message.clone()) | ||
.collect(), | ||
), |
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 a join here as well
pub struct MifinityClientResponse { | ||
first_name: Secret<String>, | ||
last_name: Secret<String>, | ||
phone: Secret<String>, | ||
dialing_code: String, | ||
nationality: String, | ||
email_address: String, | ||
dob: Secret<Date>, | ||
} |
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.
Where do we use this?
let trace_id = payload.map(|payload| payload.trace_id.clone()).ok_or( | ||
errors::ConnectorError::MissingRequiredField { | ||
field_name: "trace_id", | ||
}, | ||
)?; |
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.
If trace_id
is not present, we should not throw error, as we can recover using our payment_id, also trace_id is not optional, this is not the correct way of handling
@@ -124,109 +278,147 @@ impl<F, T> | |||
types::PaymentsResponseData, | |||
>, | |||
) -> Result<Self, Self::Error> { | |||
let payload = item.response.payload.first(); |
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.
Throw error here if payload is not present, instead of using .map
on top of it
.map(|payload| payload.to_owned().status.clone()) | ||
.ok_or(errors::ConnectorError::MissingRequiredField { | ||
field_name: "status", | ||
})?; |
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.
Should not throw 4xx, this is not what its meant for. 4xx are in case of bad request that user made to our application, we shall only throw it if such scenario happened or connector gave 4xx, you cannot use 4xx to handle your coding scenarios
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.
Everywhere this practice is being used and this is wrong, please correct the PR at all the applicable places
@@ -30,6 +30,9 @@ impl SerializableSecret for u16 {} | |||
impl SerializableSecret for i8 {} | |||
impl SerializableSecret for i32 {} | |||
|
|||
#[cfg(feature = "time")] | |||
impl SerializableSecret for time::Date {} |
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.
Get it reviewed from @SanchithHegde , along with cargo changes
…into mifinity-impl
Type of Change
Description
Additional Changes
Motivation and Context
How did you test it?
Response
redirection_url
in response complete the paymentpayment_id
Checklist
cargo +nightly fmt --all
cargo clippy