diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs index eae8be573f58..c9f0645aac33 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -230,6 +230,7 @@ pub enum RoutableConnectors { Payu, Powertranz, Prophetpay, + Rapyd, Shift4, Square, Stax, diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rs index 363df5389a79..c5739ce1043e 100644 --- a/crates/api_models/src/routing.rs +++ b/crates/api_models/src/routing.rs @@ -336,6 +336,7 @@ impl From for ast::ConnectorChoice { RoutableConnectors::Paypal => euclid_enums::Connector::Paypal, RoutableConnectors::Payu => euclid_enums::Connector::Payu, RoutableConnectors::Powertranz => euclid_enums::Connector::Powertranz, + RoutableConnectors::Prophetpay => euclid_enums::Connector::Prophetpay, RoutableConnectors::Rapyd => euclid_enums::Connector::Rapyd, RoutableConnectors::Shift4 => euclid_enums::Connector::Shift4, RoutableConnectors::Square => euclid_enums::Connector::Square, diff --git a/crates/euclid/src/enums.rs b/crates/euclid/src/enums.rs index 4188860ab90f..32e0274f7009 100644 --- a/crates/euclid/src/enums.rs +++ b/crates/euclid/src/enums.rs @@ -116,6 +116,7 @@ pub enum Connector { Paypal, Payu, Powertranz, + Prophetpay, Rapyd, Shift4, Square, diff --git a/crates/euclid/src/frontend/dir/enums.rs b/crates/euclid/src/frontend/dir/enums.rs index 17699940363f..f049ad35328e 100644 --- a/crates/euclid/src/frontend/dir/enums.rs +++ b/crates/euclid/src/frontend/dir/enums.rs @@ -225,6 +225,7 @@ pub enum CardRedirectType { Benefit, Knet, MomoAtm, + CardRedirect, } #[derive( diff --git a/crates/euclid/src/frontend/dir/lowering.rs b/crates/euclid/src/frontend/dir/lowering.rs index 516e10e0389e..b1f03e8dd557 100644 --- a/crates/euclid/src/frontend/dir/lowering.rs +++ b/crates/euclid/src/frontend/dir/lowering.rs @@ -134,6 +134,7 @@ impl From for global_enums::PaymentMethodType { enums::CardRedirectType::Benefit => Self::Benefit, enums::CardRedirectType::Knet => Self::Knet, enums::CardRedirectType::MomoAtm => Self::MomoAtm, + enums::CardRedirectType::CardRedirect => Self::CardRedirect, } } } diff --git a/crates/euclid/src/frontend/dir/transformers.rs b/crates/euclid/src/frontend/dir/transformers.rs index da413d380c0f..c99b39e36f46 100644 --- a/crates/euclid/src/frontend/dir/transformers.rs +++ b/crates/euclid/src/frontend/dir/transformers.rs @@ -161,6 +161,9 @@ impl IntoDirValue for (global_enums::PaymentMethodType, global_enums::PaymentMet } global_enums::PaymentMethodType::MomoAtm => Ok(dirval!(CardRedirectType = MomoAtm)), global_enums::PaymentMethodType::Oxxo => Ok(dirval!(VoucherType = Oxxo)), + global_enums::PaymentMethodType::CardRedirect => { + Ok(dirval!(CardRedirectType = CardRedirect)) + } } } } diff --git a/crates/kgraph_utils/src/transformers.rs b/crates/kgraph_utils/src/transformers.rs index 3d32cce38bd8..b1636418aa17 100644 --- a/crates/kgraph_utils/src/transformers.rs +++ b/crates/kgraph_utils/src/transformers.rs @@ -280,6 +280,9 @@ impl IntoDirValue for (api_enums::PaymentMethodType, api_enums::PaymentMethod) { } api_enums::PaymentMethodType::MomoAtm => Ok(dirval!(CardRedirectType = MomoAtm)), api_enums::PaymentMethodType::Oxxo => Ok(dirval!(VoucherType = Oxxo)), + api_enums::PaymentMethodType::CardRedirect => { + Ok(dirval!(CardRedirectType = CardRedirect)) + } } } } diff --git a/crates/router/src/connector/prophetpay.rs b/crates/router/src/connector/prophetpay.rs index a7d735c5808b..6765fad2653d 100644 --- a/crates/router/src/connector/prophetpay.rs +++ b/crates/router/src/connector/prophetpay.rs @@ -276,6 +276,7 @@ impl fn get_request_body( &self, req: &types::PaymentsCompleteAuthorizeRouterData, + _connectors: &settings::Connectors, ) -> CustomResult, errors::ConnectorError> { let connector_router_data = prophetpay::ProphetpayRouterData::try_from(( &self.get_currency_unit(), @@ -309,7 +310,7 @@ impl self, req, connectors, )?) .body(types::PaymentsCompleteAuthorizeType::get_request_body( - self, req, + self, req, connectors, )?) .build(), )) @@ -371,6 +372,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let req_obj = prophetpay::ProphetpaySyncRequest::try_from(req)?; @@ -389,10 +391,13 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { Ok(Some( services::RequestBuilder::new() - .method(services::Method::Get) + .method(services::Method::Post) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .body(types::PaymentsSyncType::get_request_body( + self, req, connectors, + )?) .build(), )) } @@ -455,6 +460,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let req_obj = prophetpay::ProphetpayVoidRequest::try_from(req)?; @@ -582,6 +588,7 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { let req_obj = prophetpay::ProphetpayRefundSyncRequest::try_from(req)?; diff --git a/crates/router/src/connector/prophetpay/transformers.rs b/crates/router/src/connector/prophetpay/transformers.rs index f020617ae62b..74071d5b85cb 100644 --- a/crates/router/src/connector/prophetpay/transformers.rs +++ b/crates/router/src/connector/prophetpay/transformers.rs @@ -357,20 +357,31 @@ impl TryFrom<&types::PaymentsSyncRouterData> for ProphetpaySyncRequest { #[derive(Debug, Clone, Deserialize)] pub enum ProphetpayPaymentStatus { Success, + #[serde(rename = "Transaction Approved")] + Charged, Failure, #[serde(rename = "Transaction Voided")] Voided, #[serde(rename = "Requires a card on file.")] CardTokenNotFound, + #[serde(rename = "RefInfo and InquiryReference are duplicated")] + DuplicateValue, + #[serde(rename = "Profile is missing")] + MissingProfile, + #[serde(rename = "RefInfo is empty.")] + EmptyRef, } impl From for enums::AttemptStatus { fn from(item: ProphetpayPaymentStatus) -> Self { match item { - ProphetpayPaymentStatus::Success => Self::Charged, - ProphetpayPaymentStatus::Failure => Self::Failure, + ProphetpayPaymentStatus::Success | ProphetpayPaymentStatus::Charged => Self::Charged, + ProphetpayPaymentStatus::Failure + | ProphetpayPaymentStatus::CardTokenNotFound + | ProphetpayPaymentStatus::DuplicateValue + | ProphetpayPaymentStatus::MissingProfile + | ProphetpayPaymentStatus::EmptyRef => Self::Failure, ProphetpayPaymentStatus::Voided => Self::Voided, - ProphetpayPaymentStatus::CardTokenNotFound => Self::Failure, } } } @@ -466,15 +477,29 @@ impl TryFrom<&ProphetpayRouterData<&types::RefundsRouterData>> for Prophet pub enum RefundStatus { Success, Failure, + #[serde(rename = "Transaction Voided")] + Voided, #[serde(rename = "Requires a card on file.")] CardTokenNotFound, + #[serde(rename = "RefInfo and InquiryReference are duplicated")] + DuplicateValue, + #[serde(rename = "Profile is missing")] + MissingProfile, + #[serde(rename = "RefInfo is empty.")] + EmptyRef, } impl From for enums::RefundStatus { fn from(item: RefundStatus) -> Self { match item { - RefundStatus::Success => Self::Success, - RefundStatus::Failure | RefundStatus::CardTokenNotFound => Self::Failure, + RefundStatus::Success + // in retrieving refund, if it is successful, it is shown as voided + | RefundStatus::Voided => Self::Success, + RefundStatus::Failure + | RefundStatus::CardTokenNotFound + | RefundStatus::DuplicateValue + | RefundStatus::MissingProfile + | RefundStatus::EmptyRef => Self::Failure, } } } @@ -483,8 +508,6 @@ impl From for enums::RefundStatus { #[serde(rename_all = "camelCase")] pub struct ProphetpayRefundResponse { pub response_text: RefundStatus, - #[serde(rename = "transactionID")] - pub transaction_id: String, } impl TryFrom> @@ -496,7 +519,8 @@ impl TryFrom Result { Ok(Self { response: Ok(types::RefundsResponseData { - connector_refund_id: item.response.transaction_id.to_string(), + // no refund id is generated, rather transaction id is used for referring to status in refund also + connector_refund_id: item.data.request.connector_transaction_id.clone(), refund_status: enums::RefundStatus::from(item.response.response_text), }), ..item.data @@ -533,7 +557,7 @@ impl TryFrom Result { Ok(Self { response: Ok(types::RefundsResponseData { - connector_refund_id: item.response.transaction_id.to_string(), + connector_refund_id: item.data.request.connector_transaction_id.clone(), refund_status: enums::RefundStatus::from(item.response.response_text), }), ..item.data diff --git a/crates/router/src/connector/zen/transformers.rs b/crates/router/src/connector/zen/transformers.rs index 6b0d46dec8d1..689894176b26 100644 --- a/crates/router/src/connector/zen/transformers.rs +++ b/crates/router/src/connector/zen/transformers.rs @@ -790,7 +790,8 @@ impl TryFrom<&api_models::payments::CardRedirectData> for ZenPaymentsRequest { match value { api_models::payments::CardRedirectData::Knet {} | api_models::payments::CardRedirectData::Benefit {} - | api_models::payments::CardRedirectData::MomoAtm {} => { + | api_models::payments::CardRedirectData::MomoAtm {} + | api_models::payments::CardRedirectData::CardRedirect {} => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Zen"), ) diff --git a/crates/router/src/core/payments/routing/transformers.rs b/crates/router/src/core/payments/routing/transformers.rs index de94a36248ff..8905742dcca1 100644 --- a/crates/router/src/core/payments/routing/transformers.rs +++ b/crates/router/src/core/payments/routing/transformers.rs @@ -104,6 +104,7 @@ impl ForeignFrom for dsl_enums::Connector { api_enums::RoutableConnectors::Paypal => Self::Paypal, api_enums::RoutableConnectors::Payu => Self::Payu, api_enums::RoutableConnectors::Powertranz => Self::Powertranz, + api_enums::RoutableConnectors::Prophetpay => Self::Prophetpay, api_enums::RoutableConnectors::Rapyd => Self::Rapyd, api_enums::RoutableConnectors::Shift4 => Self::Shift4, api_enums::RoutableConnectors::Square => Self::Square, diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 71e2ff4f7a60..2ab4584b7d4b 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -229,6 +229,7 @@ impl ForeignTryFrom for api_enums::RoutableConnectors { .into_report()? } api_enums::Connector::Powertranz => Self::Powertranz, + api_enums::Connector::Prophetpay => Self::Prophetpay, api_enums::Connector::Rapyd => Self::Rapyd, api_enums::Connector::Shift4 => Self::Shift4, api_enums::Connector::Signifyd => { @@ -302,6 +303,7 @@ impl ForeignFrom for api_enums::RoutableConnectors { dsl_enums::Connector::Paypal => Self::Paypal, dsl_enums::Connector::Payu => Self::Payu, dsl_enums::Connector::Powertranz => Self::Powertranz, + dsl_enums::Connector::Prophetpay => Self::Prophetpay, dsl_enums::Connector::Rapyd => Self::Rapyd, dsl_enums::Connector::Shift4 => Self::Shift4, dsl_enums::Connector::Square => Self::Square,