Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor: Refactor create order interface to support redirection and SDK session tokens for Trustpay and Payme (#10779)

Hrithikesh01461cfc46fd
diff --git a/config/development.toml b/config/development.toml
index dec6d0873f..30b88fd25e 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -37,6 +37,10 @@ dbname = "hyperswitch_db"
pool_size = 5
connection_timeout = 10
+[preprocessing_flow_config]
+authentication_bloated_connectors = "paypal,nmi,cybersource"
+order_create_bloated_connectors = "trustpay,payme"
+
[redis]
host = "127.0.0.1"
port = 6379
diff --git a/crates/hyperswitch_connectors/src/connectors/payme.rs b/crates/hyperswitch_connectors/src/connectors/payme.rs
index 84d713c610..7f38e97b26 100644
--- a/crates/hyperswitch_connectors/src/connectors/payme.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payme.rs
@@ -1455,6 +1455,18 @@ static PAYME_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 3] = [
];
impl ConnectorSpecifications for Payme {
+ fn is_order_create_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize {
+ auth_type: _,
+ request_data,
+ } => matches!(
+ &request_data.payment_method_data,
+ PaymentMethodData::Card(_) | PaymentMethodData::Wallet(_)
+ ),
+ api::CurrentFlowInfo::CompleteAuthorize { .. } => false,
+ }
+ }
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&PAYME_CONNECTOR_INFO)
}
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay.rs b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
index ed16835534..f8a609c0aa 100644
--- a/crates/hyperswitch_connectors/src/connectors/trustpay.rs
+++ b/crates/hyperswitch_connectors/src/connectors/trustpay.rs
@@ -15,25 +15,26 @@ use common_utils::{
};
use error_stack::{Report, ResultExt};
use hyperswitch_domain_models::{
+ payment_method_data,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
refunds::{Execute, RSync},
- PreProcessing,
+ CreateOrder, PreProcessing,
},
router_request_types::{
- AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
- PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSessionData,
- PaymentsSyncData, RefundsData, SetupMandateRequestData,
+ AccessTokenRequestData, CreateOrderRequestData, PaymentMethodTokenizationData,
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData,
+ PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData,
},
router_response_types::{
ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData,
SupportedPaymentMethods, SupportedPaymentMethodsExt,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsPreProcessingRouterData, PaymentsSyncRouterData,
- RefreshTokenRouterData, RefundSyncRouterData, RefundsRouterData,
+ CreateOrderRouterData, PaymentsAuthorizeRouterData, PaymentsPreProcessingRouterData,
+ PaymentsSyncRouterData, RefreshTokenRouterData, RefundSyncRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{
@@ -47,8 +48,8 @@ use hyperswitch_interfaces::{
errors,
events::connector_api_logs::ConnectorEvent,
types::{
- PaymentsAuthorizeType, PaymentsPreProcessingType, PaymentsSyncType, RefreshTokenType,
- RefundExecuteType, RefundSyncType, Response,
+ CreateOrderType, PaymentsAuthorizeType, PaymentsPreProcessingType, PaymentsSyncType,
+ RefreshTokenType, RefundExecuteType, RefundSyncType, Response,
},
webhooks,
};
@@ -498,6 +499,100 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Tru
impl api::PaymentCapture for Trustpay {}
impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Trustpay {}
+impl api::PaymentsCreateOrder for Trustpay {}
+impl ConnectorIntegration<CreateOrder, CreateOrderRequestData, PaymentsResponseData> for Trustpay {
+ fn get_headers(
+ &self,
+ req: &CreateOrderRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ let mut header = vec![(
+ headers::CONTENT_TYPE.to_string(),
+ PaymentsPreProcessingType::get_content_type(self)
+ .to_string()
+ .into(),
+ )];
+ let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
+ header.append(&mut api_key);
+ Ok(header)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ _req: &CreateOrderRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}{}", self.base_url(connectors), "api/v1/intent"))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &CreateOrderRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let req_currency = req.request.currency;
+ let req_amount = req.request.minor_amount;
+
+ let amount = utils::convert_amount(self.amount_converter, req_amount, req_currency)?;
+
+ let connector_router_data = trustpay::TrustpayRouterData::try_from((amount, req))?;
+ let connector_req =
+ trustpay::TrustpayCreateIntentRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &CreateOrderRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ let req = Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .attach_default_headers()
+ .headers(CreateOrderType::get_headers(self, req, connectors)?)
+ .url(&CreateOrderType::get_url(self, req, connectors)?)
+ .set_body(CreateOrderType::get_request_body(self, req, connectors)?)
+ .build(),
+ );
+ Ok(req)
+ }
+
+ fn handle_response(
+ &self,
+ data: &CreateOrderRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<CreateOrderRouterData, errors::ConnectorError> {
+ let response: trustpay::TrustpayCreateIntentResponse = res
+ .response
+ .parse_struct("TrustpayCreateIntentResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
impl api::PaymentsPreProcessing for Trustpay {}
impl ConnectorIntegration<PreProcessing, PaymentsPreProcessingData, PaymentsResponseData>
@@ -1352,6 +1447,18 @@ static TRUSTPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 3] = [
];
impl ConnectorSpecifications for Trustpay {
+ fn is_order_create_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize {
+ auth_type: _,
+ request_data,
+ } => matches!(
+ &request_data.payment_method_data,
+ payment_method_data::PaymentMethodData::Wallet(_)
+ ),
+ api::CurrentFlowInfo::CompleteAuthorize { .. } => false,
+ }
+ }
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&TRUSTPAY_CONNECTOR_INFO)
}
diff --git a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs
index 515cdc300f..d50e9650a6 100644
--- a/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/trustpay/transformers.rs
@@ -5,6 +5,7 @@ use cards::NetworkToken;
use common_enums::enums;
use common_utils::{
errors::CustomResult,
+ ext_traits::OptionExt,
pii::{self, Email},
request::Method,
types::{FloatMajorUnit, StringMajorUnit},
@@ -18,8 +19,8 @@ use hyperswitch_domain_models::{
PaymentsResponseData, PreprocessingResponseId, RedirectForm, RefundsResponseData,
},
types::{
- PaymentsAuthorizeRouterData, PaymentsPreProcessingRouterData, RefreshTokenRouterData,
- RefundsRouterData,
+ CreateOrderRouterData, PaymentsAuthorizeRouterData, PaymentsPreProcessingRouterData,
+ RefreshTokenRouterData, RefundsRouterData,
},
};
use hyperswitch_interfaces::{consts, errors};
@@ -29,7 +30,8 @@ use serde::{Deserialize, Serialize};
use crate::{
types::{
- PaymentsPreprocessingResponseRouterData, RefundsResponseRouterData, ResponseRouterData,
+ CreateOrderResponseRouterData, PaymentsPreprocessingResponseRouterData,
+ RefundsResponseRouterData, ResponseRouterData,
},
utils::{
self, AddressDetailsData, BrowserInformationData, CardData, NetworkTokenData,
@@ -1208,6 +1210,36 @@ pub struct TrustpayCreateIntentRequest {
pub reference: String,
}
+impl TryFrom<&TrustpayRouterData<&CreateOrderRouterData>> for TrustpayCreateIntentRequest {
+ type Error = Error;
+ fn try_from(item: &TrustpayRouterData<&CreateOrderRouterData>) -> Result<Self, Self::Error> {
+ let is_apple_pay = item
+ .router_data
+ .request
+ .payment_method_type
+ .as_ref()
+ .map(|pmt| matches!(pmt, enums::PaymentMethodType::ApplePay));
+
+ let is_google_pay = item
+ .router_data
+ .request
+ .payment_method_type
+ .as_ref()
+ .map(|pmt| matches!(pmt, enums::PaymentMethodType::GooglePay));
+
+ let currency = item.router_data.request.currency;
+ let amount = item.amount.to_owned();
+
+ Ok(Self {
+ amount,
+ currency: currency.to_string(),
+ init_apple_pay: is_apple_pay,
+ init_google_pay: is_google_pay,
+ reference: item.router_data.connector_request_reference_id.clone(),
+ })
+ }
+}
+
impl TryFrom<&TrustpayRouterData<&PaymentsPreProcessingRouterData>>
for TrustpayCreateIntentRequest
{
@@ -1341,6 +1373,39 @@ pub struct ApplePayTotalInfo {
pub amount: StringMajorUnit,
}
+impl TryFrom<CreateOrderResponseRouterData<TrustpayCreateIntentResponse>>
+ for CreateOrderRouterData
+{
+ type Error = Error;
+ fn try_from(
+ item: CreateOrderResponseRouterData<TrustpayCreateIntentResponse>,
+ ) -> Result<Self, Self::Error> {
+ let create_intent_response = item.response.init_result_data.to_owned();
+ let secrets = item.response.secrets.to_owned();
+ let instance_id = item.response.instance_id.to_owned();
+ let pmt = item
+ .data
+ .request
+ .payment_method_type
+ .get_required_value("payment_method_type")
+ .change_context(errors::ConnectorError::MissingRequiredField {
+ field_name: "payment_method_type",
+ })?;
+
+ match (pmt, create_intent_response) {
+ (
+ enums::PaymentMethodType::ApplePay,
+ InitResultData::AppleInitResultData(apple_pay_response),
+ ) => get_apple_pay_session(instance_id, &secrets, apple_pay_response, item),
+ (
+ enums::PaymentMethodType::GooglePay,
+ InitResultData::GoogleInitResultData(google_pay_response),
+ ) => get_google_pay_session(instance_id, &secrets, google_pay_response, item),
+ _ => Err(report!(errors::ConnectorError::InvalidWallet)),
+ }
+ }
+}
+
impl TryFrom<PaymentsPreprocessingResponseRouterData<TrustpayCreateIntentResponse>>
for PaymentsPreProcessingRouterData
{
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 3fd676625f..43a22f24e3 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -904,7 +904,6 @@ default_imp_for_create_order!(
connectors::Thunes,
connectors::Tokenex,
connectors::Tokenio,
- connectors::Trustpay,
connectors::Trustpayments,
connectors::Tsys,
connectors::UnifiedAuthenticationService,
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 2c0ea6c1d8..8445dda4b1 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -542,6 +542,7 @@ pub struct CreateOrderRequestData {
pub payment_method_data: Option<PaymentMethodData>,
pub order_details: Option<Vec<OrderDetailsWithAmount>>,
pub webhook_url: Option<String>,
+ pub payment_method_type: Option<common_enums::PaymentMethodType>,
pub router_return_url: Option<String>,
pub setup_mandate_details: Option<mandates::MandateData>,
pub capture_method: Option<storage_enums::CaptureMethod>,
@@ -565,6 +566,7 @@ impl TryFrom<PaymentsAuthorizeData> for CreateOrderRequestData {
fn try_from(data: PaymentsAuthorizeData) -> Result<Self, Self::Error> {
Ok(Self {
+ payment_method_type: data.payment_method_type,
minor_amount: data.minor_amount,
currency: data.currency,
payment_method_data: Some(data.payment_method_data),
@@ -582,6 +584,7 @@ impl TryFrom<ExternalVaultProxyPaymentsData> for CreateOrderRequestData {
fn try_from(data: ExternalVaultProxyPaymentsData) -> Result<Self, Self::Error> {
Ok(Self {
+ payment_method_type: data.payment_method_type,
minor_amount: data.minor_amount,
currency: data.currency,
payment_method_data: None,
diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs
index 3aaf658288..4e43ede2be 100644
--- a/crates/hyperswitch_domain_models/src/router_response_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_response_types.rs
@@ -301,6 +301,15 @@ pub enum PreprocessingResponseId {
ConnectorTransactionId(String),
}
+impl PreprocessingResponseId {
+ pub fn get_string_repr(&self) -> &String {
+ match self {
+ Self::PreProcessingId(value) => value,
+ Self::ConnectorTransactionId(value) => value,
+ }
+ }
+}
+
#[derive(Debug, Eq, PartialEq, Clone, Serialize, serde::Deserialize)]
pub enum RedirectForm {
Form {
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index afd1cf8178..5483bd668c 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -436,6 +436,10 @@ pub struct PreProcessingFlowResponse<'a> {
/// The trait that provides specifications about the connector
pub trait ConnectorSpecifications {
+ /// Check if pre-authentication flow is required
+ fn is_order_create_flow_required(&self, _current_flow: CurrentFlowInfo<'_>) -> bool {
+ false
+ }
/// Check if pre-authentication flow is required
fn is_pre_authentication_flow_required(&self, _current_flow: CurrentFlowInfo<'_>) -> bool {
false
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index 1365ad2ea5..733fd304ff 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -532,6 +532,12 @@ impl ConnectorValidation for ConnectorEnum {
}
impl ConnectorSpecifications for ConnectorEnum {
+ fn is_order_create_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match self {
+ Self::Old(connector) => connector.is_order_create_flow_required(current_flow),
+ Self::New(connector) => connector.is_order_create_flow_required(current_flow),
+ }
+ }
fn is_pre_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
match self {
Self::Old(connector) => connector.is_pre_authentication_flow_required(current_flow),
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 76377b34f4..a7a2d93e7d 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -186,8 +186,10 @@ pub struct Settings<S: SecretState> {
#[derive(Debug, Deserialize, Clone, Default)]
pub struct PreProcessingFlowConfig {
- #[serde(deserialize_with = "deserialize_hashset")]
+ #[serde(default, deserialize_with = "deserialize_hashset")]
pub authentication_bloated_connectors: HashSet<enums::Connector>,
+ #[serde(default, deserialize_with = "deserialize_hashset")]
+ pub order_create_bloated_connectors: HashSet<enums::Connector>,
}
#[derive(Debug, Deserialize, Clone, Default)]
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index a712634ec1..fe7558f717 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -4122,7 +4122,7 @@ where
// Set the response in routerdata response to carry forward
router_data
.update_router_data_with_create_order_response(create_order_response.clone());
- create_order_response.create_order_result.ok().is_some()
+ create_order_response.should_continue_further
}
// If create order is not required, then we can proceed with further processing
None => should_continue_further,
@@ -4214,6 +4214,25 @@ where
(router_data, false)
};
(router_data, should_continue_further)
+ } else if state
+ .conf
+ .preprocessing_flow_config
+ .as_ref()
+ .is_some_and(|config| {
+ // If order create flow is bloated up for the current connector
+ // order create call would have already happened in the previous step.
+ config
+ .order_create_bloated_connectors
+ .contains(&connector.connector_name)
+ })
+ {
+ // If order create flow is bloated up for the current connector
+ // So skip calling complete_preprocessing_steps_if_required function
+ logger::info!(
+ "skipping preprocessing steps for connector: {}",
+ connector.connector_name
+ );
+ (router_data, should_continue_further)
} else {
complete_preprocessing_steps_if_required(
state,
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index f0ba616821..0c1dd59789 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -530,9 +530,25 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
should_continue_payment: bool,
gateway_context: &gateway_context::RouterGatewayContext,
) -> RouterResult<Option<types::CreateOrderResult>> {
- if connector
+ let is_order_create_bloated_connector = connector.connector.is_order_create_flow_required(
+ api_interface::CurrentFlowInfo::Authorize {
+ auth_type: &self.auth_type,
+ request_data: &self.request,
+ },
+ ) && state
+ .conf
+ .preprocessing_flow_config
+ .as_ref()
+ .is_some_and(|config| {
+ // check order create flow is bloated up for the current connector
+ config
+ .order_create_bloated_connectors
+ .contains(&connector.connector_name)
+ });
+ if (connector
.connector_name
.requires_order_creation_before_payment(self.payment_method)
+ || is_order_create_bloated_connector)
&& should_continue_payment
{
let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
@@ -553,7 +569,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
response_data,
);
- let resp = gateway::execute_payment_gateway(
+ let order_create_response_router_data = gateway::execute_payment_gateway(
state,
connector_integration,
&createorder_router_data,
@@ -565,25 +581,72 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
.await
.to_payment_failed_response()?;
- let create_order_resp = match resp.response {
- Ok(res) => {
- if let types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id } =
- res
- {
- Ok(order_id)
+ let order_create_response = order_create_response_router_data.response.clone();
+
+ let create_order_resp = match &order_create_response {
+ Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id }) => {
+ types::CreateOrderResult {
+ create_order_result: Ok(order_id.clone()),
+ should_continue_further: should_continue_payment,
+ }
+ }
+ // Some connector return PreProcessingResponse and TransactionResponse response type
+ // Rest of the match statements are temporary fixes for satisfying current connector side response handling
+ // Create Order response must always be PaymentsResponseData::PaymentsCreateOrderResponse only
+ Ok(types::PaymentsResponseData::PreProcessingResponse {
+ pre_processing_id,
+ session_token,
+ ..
+ }) => {
+ let should_continue_further = if session_token.is_some() {
+ // if SDK session token is returned in order create response, do not continue and return control to SDK
+ false
} else {
- Err(error_stack::report!(ApiErrorResponse::InternalServerError)
- .attach_printable(format!(
- "Unexpected response format from connector: {res:?}",
- )))?
+ should_continue_payment
+ };
+ types::CreateOrderResult {
+ create_order_result: Ok(pre_processing_id.get_string_repr().clone()),
+ should_continue_further,
}
}
- Err(error) => Err(error),
+ Ok(types::PaymentsResponseData::TransactionResponse {
+ resource_id,
+ redirection_data,
+ ..
+ }) => {
+ let order_id = resource_id
+ .get_connector_transaction_id()
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable(
+ "unable to get connector_transaction_id during order create",
+ )?;
+ let should_continue_further = if redirection_data.is_some() {
+ // if redirection_data is returned in order create response, do not continue and return control to SDK
+ false
+ } else {
+ should_continue_payment
+ };
+ types::CreateOrderResult {
+ create_order_result: Ok(order_id),
+ should_continue_further,
+ }
+ }
+ Ok(res) => Err(error_stack::report!(ApiErrorResponse::InternalServerError)
+ .attach_printable(format!(
+ "Unexpected response format from connector: {res:?}",
+ )))?,
+ Err(error) => types::CreateOrderResult {
+ create_order_result: Err(error.clone()),
+ should_continue_further: false,
+ },
};
-
- Ok(Some(types::CreateOrderResult {
- create_order_result: create_order_resp,
- }))
+ // persist order create response
+ *self = helpers::router_data_type_conversion::<_, api::Authorize, _, _, _, _>(
+ order_create_response_router_data,
+ self.request.clone(),
+ order_create_response,
+ );
+ Ok(Some(create_order_resp))
} else {
// If the connector does not require order creation, return None
Ok(None)
@@ -597,12 +660,8 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
match create_order_result.create_order_result {
Ok(order_id) => {
self.request.order_id = Some(order_id.clone()); // ? why this is assigned here and ucs also wants this to populate data
- self.response =
- Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id });
- }
- Err(err) => {
- self.response = Err(err.clone());
}
+ Err(_err) => (),
}
}
}
diff --git a/crates/router/src/core/payments/flows/external_proxy_flow.rs b/crates/router/src/core/payments/flows/external_proxy_flow.rs
index f6b5087499..80fc62d00f 100644
--- a/crates/router/src/core/payments/flows/external_proxy_flow.rs
+++ b/crates/router/src/core/payments/flows/external_proxy_flow.rs
@@ -336,6 +336,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
Ok(Some(types::CreateOrderResult {
create_order_result: create_order_resp,
+ should_continue_further: should_continue_payment,
}))
} else {
// If the connector does not require order creation, return None
@@ -350,12 +351,8 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
match create_order_result.create_order_result {
Ok(order_id) => {
self.request.order_id = Some(order_id.clone()); // ? why this is assigned here and ucs also wants this to populate data
- self.response =
- Ok(types::PaymentsResponseData::PaymentsCreateOrderResponse { order_id });
- }
- Err(err) => {
- self.response = Err(err.clone());
}
+ Err(_err) => (),
}
}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index d50453cfb6..c22bdf7196 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -722,6 +722,7 @@ pub struct PaymentMethodTokenResult {
#[derive(Clone)]
pub struct CreateOrderResult {
pub create_order_result: Result<String, ErrorResponse>,
+ pub should_continue_further: bool,
}
pub struct PspTokenResult {