Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions api-reference/v2/openapi_spec_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -13283,6 +13283,23 @@
}
}
},
"MerchantConnectorAuthDetails": {
"type": "object",
"description": "Merchant connector details",
"required": [
"connector_name",
"merchant_connector_creds"
],
"properties": {
"connector_name": {
"$ref": "#/components/schemas/Connector"
},
"merchant_connector_creds": {
"type": "object",
"description": "The merchant connector credentials used for the payment"
}
}
},
"MerchantConnectorCreate": {
"type": "object",
"description": "Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc.\"",
Expand Down Expand Up @@ -13418,17 +13435,16 @@
},
"MerchantConnectorDetails": {
"type": "object",
"required": [
"connector_name",
"merchant_connector_creds"
],
"properties": {
"connector_name": {
"$ref": "#/components/schemas/Connector"
"connector_account_details": {
"type": "object",
"description": "Account details of the Connector. You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Useful for storing additional, structured information on an object.",
"nullable": true
},
"merchant_connector_creds": {
"metadata": {
"type": "object",
"description": "The merchant connector credentials used for the payment"
"description": "Metadata is useful for storing additional, unstructured information on an object.",
"nullable": true
}
}
},
Expand Down Expand Up @@ -18107,7 +18123,7 @@
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetails"
"$ref": "#/components/schemas/MerchantConnectorAuthDetails"
}
],
"nullable": true
Expand Down Expand Up @@ -18312,7 +18328,7 @@
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetails"
"$ref": "#/components/schemas/MerchantConnectorAuthDetails"
}
],
"nullable": true
Expand Down Expand Up @@ -19106,7 +19122,7 @@
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetails"
"$ref": "#/components/schemas/MerchantConnectorAuthDetails"
}
],
"nullable": true
Expand Down Expand Up @@ -19322,7 +19338,7 @@
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorDetails"
"$ref": "#/components/schemas/MerchantConnectorAuthDetails"
}
],
"nullable": true
Expand Down Expand Up @@ -22084,6 +22100,14 @@
"type": "object",
"description": "Metadata is useful for storing additional, unstructured information on an object.",
"nullable": true
},
"merchant_connector_details": {
"allOf": [
{
"$ref": "#/components/schemas/MerchantConnectorAuthDetails"
}
],
"nullable": true
}
},
"additionalProperties": false
Expand Down
29 changes: 8 additions & 21 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,24 +272,8 @@ pub struct PaymentsCreateIntentRequest {
pub force_3ds_challenge: Option<bool>,

/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<MerchantConnectorDetails>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
#[cfg(feature = "v2")]
pub struct MerchantConnectorDetails {
/// The connector used for the payment
#[schema(value_type = Connector)]
pub connector_name: api_enums::Connector,

/// The merchant connector credentials used for the payment
#[schema(value_type = Object, example = r#"{
"merchant_connector_creds": {
"auth_type": "HeaderKey",
"api_key":"sk_test_xxxxxexamplexxxxxx12345"
},
}"#)]
pub merchant_connector_creds: pii::SecretSerdeValue,
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}
#[cfg(feature = "v2")]
#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]
Expand Down Expand Up @@ -5361,7 +5345,8 @@ pub struct PaymentsConfirmIntentRequest {
pub payment_token: Option<String>,

/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<MerchantConnectorDetails>,
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -5536,7 +5521,8 @@ pub struct PaymentsRequest {
pub is_iframe_redirection_enabled: Option<bool>,

/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<MerchantConnectorDetails>,
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -5614,7 +5600,8 @@ pub struct PaymentsRetrieveRequest {
/// If enabled, provides whole connector response
pub all_keys_required: Option<bool>,
/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<MerchantConnectorDetails>,
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v2")]
Expand Down
20 changes: 19 additions & 1 deletion crates/api_models/src/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ pub struct RefundsCreateRequest {
/// Metadata is useful for storing additional, unstructured information on an object.
#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]
pub metadata: Option<pii::SecretSerdeValue>,

/// Merchant connector details used to make payments.
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v1")]
Expand All @@ -116,6 +120,16 @@ pub struct RefundsRetrieveBody {
pub force_sync: Option<bool>,
}

#[cfg(feature = "v2")]
#[derive(Default, Debug, Clone, Deserialize)]
pub struct RefundsRetrievePayload {
/// `force_sync` with the connector to get refund details
pub force_sync: Option<bool>,

/// Merchant connector details used to make payments.
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v1")]
#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
pub struct RefundsRetrieveRequest {
Expand Down Expand Up @@ -149,6 +163,10 @@ pub struct RefundsRetrieveRequest {
/// `force_sync` with the connector to get refund details
/// (defaults to false)
pub force_sync: Option<bool>,

/// Merchant connector details used to make payments.
#[schema(value_type = Option<MerchantConnectorAuthDetails>)]
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[derive(Default, Debug, ToSchema, Clone, Deserialize, Serialize)]
Expand Down Expand Up @@ -323,7 +341,7 @@ pub struct RefundResponse {
pub profile_id: common_utils::id_type::ProfileId,
/// The merchant_connector_id of the processor through which this payment went through
#[schema(value_type = String)]
pub merchant_connector_id: common_utils::id_type::MerchantConnectorAccountId,
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
/// The reference id of the connector for the refund
pub connector_refund_reference_id: Option<String>,
}
Expand Down
18 changes: 18 additions & 0 deletions crates/common_types/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,21 @@ pub struct AcquirerConfig {
pub struct AcquirerConfigMap(pub HashMap<common_utils::id_type::ProfileAcquirerId, AcquirerConfig>);

impl_to_sql_from_sql_json!(AcquirerConfigMap);

/// Merchant connector details
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
#[cfg(feature = "v2")]
pub struct MerchantConnectorAuthDetails {
/// The connector used for the payment
#[schema(value_type = Connector)]
pub connector_name: common_enums::connector_enums::Connector,

/// The merchant connector credentials used for the payment
#[schema(value_type = Object, example = r#"{
"merchant_connector_creds": {
"auth_type": "HeaderKey",
"api_key":"sk_test_xxxxxexamplexxxxxx12345"
},
}"#)]
pub merchant_connector_creds: common_utils::pii::SecretSerdeValue,
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl MerchantConnectorAccount {
#[derive(Clone, Debug)]
pub enum MerchantConnectorAccountTypeDetails {
MerchantConnectorAccount(Box<MerchantConnectorAccount>),
MerchantConnectorDetails(api_models::payments::MerchantConnectorDetails),
MerchantConnectorDetails(common_types::domain::MerchantConnectorAuthDetails),
}

#[cfg(feature = "v2")]
Expand Down
6 changes: 3 additions & 3 deletions crates/hyperswitch_domain_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::marker::PhantomData;

#[cfg(feature = "v2")]
use api_models::payments::{MerchantConnectorDetails, SessionToken, VaultSessionDetails};
use api_models::payments::{SessionToken, VaultSessionDetails};
#[cfg(feature = "v1")]
use common_types::primitive_wrappers::{
AlwaysRequestExtendedAuthorization, RequestExtendedAuthorizationBool,
Expand Down Expand Up @@ -865,7 +865,7 @@ where
pub payment_address: payment_address::PaymentAddress,
pub mandate_data: Option<api_models::payments::MandateIds>,
pub payment_method: Option<payment_methods::PaymentMethod>,
pub merchant_connector_details: Option<MerchantConnectorDetails>,
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -918,7 +918,7 @@ where
/// Should the payment status be synced with connector
/// This will depend on the payment status and the force sync flag in the request
pub should_sync_with_connector: bool,
pub merchant_connector_details: Option<MerchantConnectorDetails>,
pub merchant_connector_details: Option<common_types::domain::MerchantConnectorAuthDetails>,
}

#[cfg(feature = "v2")]
Expand Down
2 changes: 1 addition & 1 deletion crates/openapi/src/openapi_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Never share your secret api keys. Keep them guarded and secure.
common_types::payments::XenditMultipleSplitRequest,
common_types::domain::XenditSplitSubMerchantData,
common_types::domain::AdyenSplitItem,
common_types::domain::MerchantConnectorAuthDetails,
common_types::refunds::StripeSplitRefundRequest,
common_utils::types::ChargeRefunds,
common_types::payment_methods::PaymentMethodsEnabled,
Expand Down Expand Up @@ -425,7 +426,6 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::payments::PaymentsListResponseItem,
api_models::payments::PaymentRetrieveBody,
api_models::payments::PaymentsRetrieveRequest,
api_models::payments::MerchantConnectorDetails,
api_models::payments::PaymentsStatusRequest,
api_models::payments::PaymentsCaptureRequest,
api_models::payments::PaymentsSessionRequest,
Expand Down
12 changes: 6 additions & 6 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8884,7 +8884,7 @@ pub trait OperationSessionGetters<F> {
#[cfg(feature = "v2")]
fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails>;
) -> Option<common_types::domain::MerchantConnectorAuthDetails>;

fn get_connector_customer_id(&self) -> Option<String>;
fn get_whole_connector_response(&self) -> Option<String>;
Expand Down Expand Up @@ -9395,7 +9395,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentIntentData<F> {

fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails> {
) -> Option<common_types::domain::MerchantConnectorAuthDetails> {
todo!()
}

Expand Down Expand Up @@ -9591,7 +9591,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentConfirmData<F> {

fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails> {
) -> Option<common_types::domain::MerchantConnectorAuthDetails> {
self.merchant_connector_details.clone()
}

Expand Down Expand Up @@ -9887,7 +9887,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentStatusData<F> {

fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails> {
) -> Option<common_types::domain::MerchantConnectorAuthDetails> {
self.merchant_connector_details.clone()
}

Expand Down Expand Up @@ -10178,7 +10178,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentCaptureData<F> {

fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails> {
) -> Option<common_types::domain::MerchantConnectorAuthDetails> {
todo!()
}

Expand Down Expand Up @@ -10612,7 +10612,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentAttemptListData<F> {
}
fn get_merchant_connector_details(
&self,
) -> Option<api_models::payments::MerchantConnectorDetails> {
) -> Option<common_types::domain::MerchantConnectorAuthDetails> {
todo!()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ pub async fn get_connector_default(
#[cfg(feature = "v2")]
pub async fn get_connector_data_from_request(
state: &SessionState,
req: Option<api_models::payments::MerchantConnectorDetails>,
req: Option<common_types::domain::MerchantConnectorAuthDetails>,
) -> CustomResult<api::ConnectorData, errors::ApiErrorResponse> {
let connector = req
.as_ref()
Expand Down
Loading
Loading