Skip to content

Commit

Permalink
psync added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sweta-Kumari-Sharma committed Nov 20, 2024
1 parent 9d34f0d commit 3d5508c
Show file tree
Hide file tree
Showing 21 changed files with 226 additions and 240 deletions.
2 changes: 1 addition & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ impl GetPaymentMethodType for PayLaterData {
match self {
Self::KlarnaRedirect { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaSdk { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaCheckout { .. } => api_enums::PaymentMethodType::KlarnaCheckout,
Self::KlarnaCheckout {} => api_enums::PaymentMethodType::Klarna,
Self::AffirmRedirect {} => api_enums::PaymentMethodType::Affirm,
Self::AfterpayClearpayRedirect { .. } => api_enums::PaymentMethodType::AfterpayClearpay,
Self::PayBrightRedirect {} => api_enums::PaymentMethodType::PayBright,
Expand Down
1 change: 0 additions & 1 deletion crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,6 @@ pub enum PaymentMethodType {
Interac,
Indomaret,
Klarna,
KlarnaCheckout,
KakaoPay,
LocalBankRedirect,
MandiriVa,
Expand Down
1 change: 0 additions & 1 deletion crates/common_enums/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,6 @@ impl From<PaymentMethodType> for PaymentMethod {
PaymentMethodType::Mifinity => Self::Wallet,
PaymentMethodType::Ideal => Self::BankRedirect,
PaymentMethodType::Klarna => Self::PayLater,
PaymentMethodType::KlarnaCheckout => Self::PayLater,
PaymentMethodType::KakaoPay => Self::Wallet,
PaymentMethodType::Knet => Self::CardRedirect,
PaymentMethodType::LocalBankRedirect => Self::BankRedirect,
Expand Down
1 change: 0 additions & 1 deletion crates/euclid/src/frontend/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,6 @@ mod test {
dirval!(CardType = Credit),
dirval!(CardNetwork = Visa),
dirval!(PayLaterType = Klarna),
dirval!(PayLaterType = KlarnaCheckout),
dirval!(WalletType = Paypal),
dirval!(BankRedirectType = Sofort),
dirval!(BankDebitType = Bacs),
Expand Down
1 change: 0 additions & 1 deletion crates/euclid/src/frontend/dir/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pub enum PayLaterType {
AfterpayClearpay,
Alma,
Klarna,
KlarnaCheckout,
PayBright,
Walley,
Atome,
Expand Down
1 change: 0 additions & 1 deletion crates/euclid/src/frontend/dir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl From<enums::PayLaterType> for global_enums::PaymentMethodType {
enums::PayLaterType::AfterpayClearpay => Self::AfterpayClearpay,
enums::PayLaterType::Alma => Self::Alma,
enums::PayLaterType::Klarna => Self::Klarna,
enums::PayLaterType::KlarnaCheckout => Self::KlarnaCheckout,
enums::PayLaterType::PayBright => Self::PayBright,
enums::PayLaterType::Walley => Self::Walley,
enums::PayLaterType::Atome => Self::Atome,
Expand Down
3 changes: 0 additions & 3 deletions crates/euclid/src/frontend/dir/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet
global_enums::PaymentMethodType::Eps => Ok(dirval!(BankRedirectType = Eps)),
global_enums::PaymentMethodType::Fps => Ok(dirval!(RealTimePaymentType = Fps)),
global_enums::PaymentMethodType::Klarna => Ok(dirval!(PayLaterType = Klarna)),
global_enums::PaymentMethodType::KlarnaCheckout => {
Ok(dirval!(PayLaterType = KlarnaCheckout))
}
global_enums::PaymentMethodType::Affirm => Ok(dirval!(PayLaterType = Affirm)),
global_enums::PaymentMethodType::AfterpayClearpay => {
Ok(dirval!(PayLaterType = AfterpayClearpay))
Expand Down
2 changes: 1 addition & 1 deletion crates/hyperswitch_connectors/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ impl From<PaymentMethodData> for PaymentMethodDataType {
PaymentMethodData::PayLater(pay_later_data) => match pay_later_data {
hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaRedirect { .. } => Self::KlarnaRedirect,
hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaSdk { .. } => Self::KlarnaSdk,
hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaCheckout { .. } => Self::KlarnaCheckout,
hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaCheckout {} => Self::KlarnaCheckout,
hyperswitch_domain_models::payment_method_data::PayLaterData::AffirmRedirect {} => Self::AffirmRedirect,
hyperswitch_domain_models::payment_method_data::PayLaterData::AfterpayClearpayRedirect { .. } => {
Self::AfterpayClearpayRedirect
Expand Down
4 changes: 2 additions & 2 deletions crates/hyperswitch_domain_models/src/payment_method_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ impl From<api_models::payments::PayLaterData> for PayLaterData {
match value {
api_models::payments::PayLaterData::KlarnaRedirect { .. } => Self::KlarnaRedirect {},
api_models::payments::PayLaterData::KlarnaSdk { token } => Self::KlarnaSdk { token },
api_models::payments::PayLaterData::KlarnaCheckout { .. } => Self::KlarnaCheckout {},
api_models::payments::PayLaterData::KlarnaCheckout {} => Self::KlarnaCheckout {},
api_models::payments::PayLaterData::AffirmRedirect {} => Self::AffirmRedirect {},
api_models::payments::PayLaterData::AfterpayClearpayRedirect { .. } => {
Self::AfterpayClearpayRedirect {}
Expand Down Expand Up @@ -1551,7 +1551,7 @@ impl GetPaymentMethodType for PayLaterData {
match self {
Self::KlarnaRedirect { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaSdk { .. } => api_enums::PaymentMethodType::Klarna,
Self::KlarnaCheckout {} => api_enums::PaymentMethodType::KlarnaCheckout,
Self::KlarnaCheckout {} => api_enums::PaymentMethodType::Klarna,
Self::AffirmRedirect {} => api_enums::PaymentMethodType::Affirm,
Self::AfterpayClearpayRedirect { .. } => api_enums::PaymentMethodType::AfterpayClearpay,
Self::PayBrightRedirect {} => api_enums::PaymentMethodType::PayBright,
Expand Down
1 change: 0 additions & 1 deletion crates/hyperswitch_domain_models/src/router_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ pub struct KlarnaSdkResponse {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct KlarnaCheckoutResponse {
pub payment_type: Option<String>,
// pub html_snippet: Option<String>,
}

#[derive(Clone, Debug, serde::Serialize)]
Expand Down
1 change: 0 additions & 1 deletion crates/kgraph_utils/src/mca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ fn get_dir_value_payment_method(
api_enums::PaymentMethodType::Sofort => Ok(dirval!(BankRedirectType = Sofort)),
api_enums::PaymentMethodType::Eps => Ok(dirval!(BankRedirectType = Eps)),
api_enums::PaymentMethodType::Klarna => Ok(dirval!(PayLaterType = Klarna)),
api_enums::PaymentMethodType::KlarnaCheckout => Ok(dirval!(PayLaterType = KlarnaCheckout)),
api_enums::PaymentMethodType::Affirm => Ok(dirval!(PayLaterType = Affirm)),
api_enums::PaymentMethodType::AfterpayClearpay => {
Ok(dirval!(PayLaterType = AfterpayClearpay))
Expand Down
1 change: 0 additions & 1 deletion crates/kgraph_utils/src/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ impl IntoDirValue for (api_enums::PaymentMethodType, api_enums::PaymentMethod) {
api_enums::PaymentMethodType::Sofort => Ok(dirval!(BankRedirectType = Sofort)),
api_enums::PaymentMethodType::Eps => Ok(dirval!(BankRedirectType = Eps)),
api_enums::PaymentMethodType::Klarna => Ok(dirval!(PayLaterType = Klarna)),
api_enums::PaymentMethodType::KlarnaCheckout => Ok(dirval!(PayLaterType = Klarna)),
api_enums::PaymentMethodType::Affirm => Ok(dirval!(PayLaterType = Affirm)),
api_enums::PaymentMethodType::AfterpayClearpay => {
Ok(dirval!(PayLaterType = AfterpayClearpay))
Expand Down
1 change: 0 additions & 1 deletion crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl ConnectorValidation for Adyen {
| PaymentMethodType::Bacs
| PaymentMethodType::Givex
| PaymentMethodType::Klarna
| PaymentMethodType::KlarnaCheckout
| PaymentMethodType::Twint
| PaymentMethodType::Walley => match capture_method {
enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()),
Expand Down
32 changes: 23 additions & 9 deletions crates/router/src/connector/klarna.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,26 @@ impl
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
let endpoint =
build_region_specific_endpoint(self.base_url(connectors), &req.connector_meta_data)?;
let checkout_endpoint = get_klarna_checkout_endpoint(self.base_url(connectors));

let payment_experience = req.request.payment_experience;

Ok(format!("{endpoint}ordermanagement/v1/orders/{order_id}"))
match payment_experience {
Some(common_enums::PaymentExperience::InvokeSdkClient) => {
Ok(format!("{endpoint}ordermanagement/v1/orders/{order_id}"))
}
Some(common_enums::PaymentExperience::RedirectToUrl) => {
Ok(format!("{checkout_endpoint}checkout/v3/orders/{order_id}"))
}
None => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "payment_experience not supported".to_string(),
connector: "klarna",
})),
_ => Err(error_stack::report!(errors::ConnectorError::NotSupported {
message: "payment_experience not supported".to_string(),
connector: "klarna",
})),
}
}

fn build_request(
Expand Down Expand Up @@ -478,7 +496,6 @@ impl
.response
.parse_struct("klarna KlarnaPsyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;

event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);

Expand Down Expand Up @@ -597,7 +614,6 @@ impl
| common_enums::PaymentMethodType::Interac
| common_enums::PaymentMethodType::Indomaret
| common_enums::PaymentMethodType::Klarna
| common_enums::PaymentMethodType::KlarnaCheckout
| common_enums::PaymentMethodType::KakaoPay
| common_enums::PaymentMethodType::MandiriVa
| common_enums::PaymentMethodType::Knet
Expand Down Expand Up @@ -662,8 +678,8 @@ impl
domain::PaymentMethodData::PayLater(domain::PayLaterData::KlarnaCheckout {}) => {
match (payment_experience, payment_method_type) {
(
common_enums::PaymentExperience::InvokeSdkClient,
common_enums::PaymentMethodType::KlarnaCheckout,
common_enums::PaymentExperience::RedirectToUrl,
common_enums::PaymentMethodType::Klarna,
) => Ok(format!("{checkout_endpoint}checkout/v3/orders",)),
(
common_enums::PaymentExperience::DisplayQrCode
Expand Down Expand Up @@ -715,7 +731,6 @@ impl
| common_enums::PaymentMethodType::Interac
| common_enums::PaymentMethodType::Indomaret
| common_enums::PaymentMethodType::Klarna
| common_enums::PaymentMethodType::KlarnaCheckout
| common_enums::PaymentMethodType::KakaoPay
| common_enums::PaymentMethodType::MandiriVa
| common_enums::PaymentMethodType::Knet
Expand Down Expand Up @@ -816,8 +831,7 @@ impl
req.request.currency,
)?;
let connector_router_data = klarna::KlarnaRouterData::from((amount, req));
let connector_req = klarna::KlarnaPaymentsRequest::try_from(&connector_router_data)?;

let connector_req = klarna::KlarnaAuthRequest::try_from(&connector_router_data)?;
Ok(RequestContent::Json(Box::new(connector_req)))
}

Expand Down Expand Up @@ -849,7 +863,7 @@ impl
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: klarna::KlarnaPaymentsResponse = res
let response: klarna::KlarnaAuthResponse = res
.response
.parse_struct("KlarnaPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
Expand Down
Loading

0 comments on commit 3d5508c

Please sign in to comment.