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(payout): [Payone] add payone connector #4553
base: main
Are you sure you want to change the base?
Conversation
Required CI checks are failing, could you address that |
59714bb
to
4a9d2b1
Compare
45c0606
to
db1737b
Compare
625a23c
to
1b31b63
Compare
6759bf9
to
d9c8711
Compare
…one-payout-flows
2cf17fd
to
82c8fe4
Compare
448e201
to
25a8001
Compare
date_header.trim(), | ||
canonicalized_path.trim() | ||
); | ||
println!("{string_to_hash:?}"); |
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 this print statement
pub fn get_current_date_time() -> CustomResult<String, errors::ConnectorError> { | ||
let format = format_description::parse( | ||
"[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT", | ||
) | ||
.change_context(errors::ConnectorError::InvalidDateFormat)?; | ||
OffsetDateTime::now_utc() | ||
.format(&format) | ||
.change_context(errors::ConnectorError::InvalidDateFormat) | ||
} |
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.
Please move this into utils
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.
Please create the utils function in an generalized manner so that the format can be passed as an argument. @KiranKBR
req, | ||
))?; | ||
let connector_req = payone::PayoneRefundRequest::try_from(&connector_router_data)?; | ||
let connector_req = payone::PayonePayoutFulfillRequest::try_from(req)?; |
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.
Create PayoneRouterData first, then create request body
let connector_req = payone::PayonePayoutFulfillRequest::try_from(req)?; | |
let connector_router_data = payone::PayoneRouterData::try_from(( | |
&self.get_currency_unit(), | |
req.request.destination_currency, | |
req.request.amount, | |
req, | |
))?; | |
let connector_req = payone::PayonePayoutFulfillRequest::try_from(&connector_router_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.
not required
} | ||
|
||
impl TryFrom<&types::ConnectorAuthType> for PayoneAuthType { | ||
type Error = error_stack::Report<errors::ConnectorError>; | ||
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> { | ||
match auth_type { | ||
types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self { | ||
if let types::ConnectorAuthType::SignatureKey { |
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 match statement instead of if let to for the ConnectorAuthType and state all the enums to know explicitly what we are handling
impl Card { | ||
fn get_card_issuer(&self) -> Result<CardIssuer, Error> { | ||
for (k, v) in CARD_REGEX.iter() { | ||
let regex: Regex = v | ||
.clone() | ||
.change_context(errors::ConnectorError::RequestEncodingFailed)?; | ||
if regex.is_match(self.card_number.clone().get_card_no().as_str()) { | ||
return Ok(*k); | ||
} | ||
} | ||
Err(error_stack::Report::new( | ||
errors::ConnectorError::NotImplemented("Card Type".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.
Remove this and use the one from utils
refund_status: enums::RefundStatus::from(item.response.status), | ||
response: Ok(types::PayoutsResponseData { | ||
status: Some(storage_enums::PayoutStatus::foreign_from(response.status)), | ||
connector_payout_id: "".to_string(), |
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.
connector_payout_id: "".to_string(), | |
connector_payout_id: response.id, |
You can provide the id present in response as connector_payout_id
…one-payout-flows
…one-payout-flows
@@ -1096,6 +1096,7 @@ pub trait CardData { | |||
fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret<String>; | |||
fn get_expiry_year_4_digit(&self) -> Secret<String>; | |||
fn get_expiry_date_as_yymm(&self) -> Result<Secret<String>, errors::ConnectorError>; | |||
fn get_expiry_date_as_mmyy(&self) -> Result<Secret<String>, errors::ConnectorError>; |
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.
No need of this util, you can use this function get_card_expiry_month_year_2_digit_with_delimiter
api_enums::Connector::Payone => { | ||
payone::transformers::PayoneAuthType::try_from(val)?; | ||
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.
Please place this in alphabetical order
connector: Box::new(&Payone), | ||
connector_name: types::Connector::Adyen, |
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.
I suppose you need to change the name to Payone
connector: Box::new(&Payone), | |
connector_name: types::Connector::Adyen, | |
connector: Box::new(&Payone), | |
connector_name: types::Connector::Payone, |
@@ -282,6 +285,7 @@ impl ConnectorConfig { | |||
Connector::Noon => Ok(connector_data.noon), | |||
Connector::Nuvei => Ok(connector_data.nuvei), | |||
Connector::Payme => Ok(connector_data.payme), | |||
Connector::Payone => Err("Use get_payout_connector_config".to_string()), |
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.
What is the difference between Ebanx
and Payone
? why are we throwing error here?
pub fn get_current_date_time() -> CustomResult<String, errors::ConnectorError> { | ||
let format = format_description::parse( | ||
"[weekday repr:short], [day] [month repr:short] [year] [hour]:[minute]:[second] GMT", | ||
) | ||
.change_context(errors::ConnectorError::InvalidDateFormat)?; | ||
OffsetDateTime::now_utc() | ||
.format(&format) | ||
.change_context(errors::ConnectorError::InvalidDateFormat) | ||
} |
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.
Please create the utils function in an generalized manner so that the format can be passed as an argument. @KiranKBR
currency_code: item.router_data.request.destination_currency.to_string(), | ||
}; | ||
let _card_issuer = | ||
CardAndCardIssuer::try_from(&item.router_data.get_payout_method_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.
This try_from
is not required rather add a match on payment_method_data
and then impl a try_from
to return the whole Object card_payout_method_specific_input
|
||
let card_payout_method_specific_input: CardPayoutMethodSpecificInput = | ||
CardPayoutMethodSpecificInput { | ||
#[allow(clippy::as_conversions)] |
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.
Why is this lint added?
match issuer { | ||
CardIssuer::Master => Ok(Self::MasterCard), | ||
CardIssuer::Visa => Ok(Self::Visa), | ||
_ => Err(errors::ConnectorError::NotImplemented( | ||
get_unimplemented_payment_method_error_message("payone"), | ||
) | ||
.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.
Why are we not covering all the card issuer networks?
}), | ||
..item.data | ||
}) | ||
#[allow(dead_code)] |
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.
Why dead_code
?
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.
Also Serialize
is not required in the derives as this is response.
Please take care of this at all the applicable places
PayoneStatus::RejectedCredit | PayoneStatus::Rejected => Self::Cancelled, | ||
PayoneStatus::Cancelled | PayoneStatus::Reversed => Self::Cancelled, |
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.
PayoneStatus::RejectedCredit | PayoneStatus::Rejected => Self::Cancelled, | |
PayoneStatus::Cancelled | PayoneStatus::Reversed => Self::Cancelled, | |
PayoneStatus::RejectedCredit | PayoneStatus::Rejected | | |
PayoneStatus::Cancelled | PayoneStatus::Reversed => Self::Cancelled, |
Type of Change
Description
Merchant Connector:
response:
Payout Creation:
response:
Additional Changes
Motivation and Context
How did you test it?
Checklist
cargo +nightly fmt --all
cargo clippy